forked from keendreams/keen
-
Notifications
You must be signed in to change notification settings - Fork 2
/
kd_keen.c
2528 lines (2125 loc) · 56 KB
/
kd_keen.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Keen Dreams Source Code
* Copyright (C) 2014 Javier M. Chavez
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
// KD_KEEN.C
#include "KD_DEF.H"
#pragma hdrstop
/*
player->temp1 = pausetime / pointer to zees when sleeping
player->temp2 = pausecount / stagecount
player->temp3 =
player->temp4 =
*/
/*
=============================================================================
LOCAL CONSTANTS
=============================================================================
*/
#define KEENPRIORITY 1
#define PLACESPRITE RF_PlaceSprite (&ob->sprite,ob->x,ob->y,ob->shapenum, \
spritedraw,KEENPRIORITY);
#define MINPOLEJUMPTICS 19 // wait tics before allowing a pole regram
#define SPDRUNJUMP 16
#define SPDPOLESIDEJUMP 8
#define WALKAIRSPEED 8
#define DIVESPEED 32
#define JUMPTIME 16
#define POLEJUMPTIME 10
#define SPDJUMP 40
#define SPDDIVEUP 16
#define SPDPOLEJUMP 20
#define SPDPOWERUP -64
#define SPDPOWER 64
#define SPDPOWERY -20
#define POWERCOUNT 50
#define MAXXSPEED 24
/*
=============================================================================
GLOBAL VARIABLES
=============================================================================
*/
int singlegravity;
unsigned bounceangle[8][8] =
{
{0,0,0,0,0,0,0,0},
{7,6,5,4,3,2,1,0},
{5,4,3,2,1,0,15,14},
{5,4,3,2,1,0,15,14},
{3,2,1,0,15,14,13,12},
{9,8,7,6,5,4,3,2},
{9,8,7,6,5,4,3,2},
{11,10,9,8,7,6,5,4}
};
/*
=============================================================================
LOCAL VARIABLES
=============================================================================
*/
int jumptime;
long leavepoletime; // TimeCount when jumped off pole
/*
=============================================================================
SCORE BOX ROUTINES
=============================================================================
*/
void SpawnScore (void);
void ScoreThink (objtype *ob);
void ScoreReact (objtype *ob);
void MemDrawChar (int char8,byte far *dest,unsigned width,unsigned planesize);
statetype s_score = {NULL,NULL,think,false,
false,0, 0,0, ScoreThink , NULL, ScoreReact, NULL};
/*
======================
=
= SpawnScore
=
======================
*/
void SpawnScore (void)
{
scoreobj->obclass = inertobj;
scoreobj->active = allways;
scoreobj->needtoclip = false;
*((long *)&(scoreobj->temp1)) = -1; // force score to be updated
scoreobj->temp3 = -1; // and flower power
scoreobj->temp4 = -1; // and lives
NewState (scoreobj,&s_score);
}
void FixScoreBox (void)
{
unsigned width, planesize;
unsigned smallplane,bigplane;
spritetype _seg *block;
byte far *dest;
// draw boobus bomb if on level 15, else flower power
block = (spritetype _seg *)grsegs[SCOREBOXSPR];
width = block->width[0];
planesize = block->planesize[0];
dest = (byte far *)grsegs[SCOREBOXSPR]+block->sourceoffset[0]
+ planesize + width*16 + 4*CHARWIDTH;
if (mapon == 15)
{
MemDrawChar (20,dest,width,planesize);
MemDrawChar (21,dest+CHARWIDTH,width,planesize);
MemDrawChar (22,dest+width*8,width,planesize);
MemDrawChar (23,dest+width*8+CHARWIDTH,width,planesize);
}
else
{
MemDrawChar (28,dest,width,planesize);
MemDrawChar (29,dest+CHARWIDTH,width,planesize);
MemDrawChar (30,dest+width*8,width,planesize);
MemDrawChar (31,dest+width*8+CHARWIDTH,width,planesize);
}
}
/*
======================
=
= MemDrawChar
=
======================
*/
#if GRMODE == EGAGR
void MemDrawChar (int char8,byte far *dest,unsigned width,unsigned planesize)
{
asm mov si,[char8]
asm shl si,1
asm shl si,1
asm shl si,1
asm shl si,1
asm shl si,1 // index into char 8 segment
asm mov ds,[WORD PTR grsegs+STARTTILE8*2]
asm mov es,[WORD PTR dest+2]
asm mov cx,4 // draw four planes
asm mov bx,[width]
asm dec bx
planeloop:
asm mov di,[WORD PTR dest]
asm movsb
asm add di,bx
asm movsb
asm add di,bx
asm movsb
asm add di,bx
asm movsb
asm add di,bx
asm movsb
asm add di,bx
asm movsb
asm add di,bx
asm movsb
asm add di,bx
asm movsb
asm mov ax,[planesize]
asm add [WORD PTR dest],ax
asm loop planeloop
asm mov ax,ss
asm mov ds,ax
}
#endif
#if GRMODE == CGAGR
void MemDrawChar (int char8,byte far *dest,unsigned width,unsigned planesize)
{
asm mov si,[char8]
asm shl si,1
asm shl si,1
asm shl si,1
asm shl si,1 // index into char 8 segment
asm mov ds,[WORD PTR grsegs+STARTTILE8*2]
asm mov es,[WORD PTR dest+2]
asm mov bx,[width]
asm sub bx,2
asm mov di,[WORD PTR dest]
asm movsw
asm add di,bx
asm movsw
asm add di,bx
asm movsw
asm add di,bx
asm movsw
asm add di,bx
asm movsw
asm add di,bx
asm movsw
asm add di,bx
asm movsw
asm add di,bx
asm movsw
asm mov ax,ss
asm mov ds,ax
planesize++; // shut the compiler up
}
#endif
/*
====================
=
= ShiftScore
=
====================
*/
#if GRMODE == EGAGR
void ShiftScore (void)
{
spritetabletype far *spr;
spritetype _seg *dest;
spr = &spritetable[SCOREBOXSPR-STARTSPRITES];
dest = (spritetype _seg *)grsegs[SCOREBOXSPR];
CAL_ShiftSprite (FP_SEG(dest),dest->sourceoffset[0],
dest->sourceoffset[1],spr->width,spr->height,2);
CAL_ShiftSprite (FP_SEG(dest),dest->sourceoffset[0],
dest->sourceoffset[2],spr->width,spr->height,4);
CAL_ShiftSprite (FP_SEG(dest),dest->sourceoffset[0],
dest->sourceoffset[3],spr->width,spr->height,6);
}
#endif
/*
===============
=
= ScoreThink
=
===============
*/
void ScoreThink (objtype *ob)
{
char str[10],*ch;
spritetype _seg *block;
byte far *dest;
unsigned i, length, width, planesize, number;
//
// score changed
//
if ((gamestate.score>>16) != ob->temp1
|| (unsigned)gamestate.score != ob->temp2 )
{
block = (spritetype _seg *)grsegs[SCOREBOXSPR];
width = block->width[0];
planesize = block->planesize[0];
dest = (byte far *)grsegs[SCOREBOXSPR]+block->sourceoffset[0]
+ planesize + width*4 + 1*CHARWIDTH;
ltoa (gamestate.score,str,10);
// erase leading spaces
length = strlen(str);
for (i=6;i>length;i--)
MemDrawChar (0,dest+=CHARWIDTH,width,planesize);
// draw digits
ch = str;
while (*ch)
MemDrawChar (*ch++ - '0'+1,dest+=CHARWIDTH,width,planesize);
#if GRMODE == EGAGR
ShiftScore ();
#endif
ob->needtoreact = true;
ob->temp1 = gamestate.score>>16;
ob->temp2 = gamestate.score;
}
//
// flower power changed
//
if (mapon == 15)
number = gamestate.boobusbombs;
else
number = gamestate.flowerpowers;
if (number != ob->temp3)
{
block = (spritetype _seg *)grsegs[SCOREBOXSPR];
width = block->width[0];
planesize = block->planesize[0];
dest = (byte far *)grsegs[SCOREBOXSPR]+block->sourceoffset[0]
+ planesize + width*20 + 5*CHARWIDTH;
if (number > 99)
strcpy (str,"99");
else
ltoa (number,str,10);
// erase leading spaces
length = strlen(str);
for (i=2;i>length;i--)
MemDrawChar (0,dest+=CHARWIDTH,width,planesize);
// draw digits
ch = str;
while (*ch)
MemDrawChar (*ch++ - '0'+1,dest+=CHARWIDTH,width,planesize);
#if GRMODE == EGAGR
ShiftScore ();
#endif
ob->needtoreact = true;
ob->temp3 = gamestate.flowerpowers;
}
//
// lives changed
//
if (gamestate.lives != ob->temp4)
{
block = (spritetype _seg *)grsegs[SCOREBOXSPR];
width = block->width[0];
planesize = block->planesize[0];
dest = (byte far *)grsegs[SCOREBOXSPR]+block->sourceoffset[0]
+ planesize + width*20 + 2*CHARWIDTH;
if (gamestate.lives>9)
MemDrawChar ('9' - '0'+1,dest,width,planesize);
else
MemDrawChar (gamestate.lives +1,dest,width,planesize);
#if GRMODE == EGAGR
ShiftScore ();
#endif
ob->needtoreact = true;
ob->temp4 = gamestate.lives;
}
if (originxglobal != ob->x || originyglobal != ob->y)
ob->needtoreact = true;
}
/*
===============
=
= ScoreReact
=
===============
*/
void ScoreReact (objtype *ob)
{
ob->x = originxglobal;
ob->y = originyglobal;
#if GRMODE == EGAGR
RF_PlaceSprite (&ob->sprite
,ob->x+4*PIXGLOBAL
,ob->y+4*PIXGLOBAL
,SCOREBOXSPR
,spritedraw
,PRIORITIES-1);
#endif
#if GRMODE == CGAGR
RF_PlaceSprite (&ob->sprite
,ob->x+8*PIXGLOBAL
,ob->y+8*PIXGLOBAL
,SCOREBOXSPR
,spritedraw
,PRIORITIES-1);
#endif
}
/*
=============================================================================
FLOWER POWER ROUTINES
temp1 = 8, same as power bonus
temp2 = initial direction
=============================================================================
*/
void PowerCount (objtype *ob);
void PowerContact (objtype *ob, objtype *hit);
void PowerReact (objtype *ob);
extern statetype s_flowerpower1;
extern statetype s_flowerpower2;
extern statetype s_boobusbomb1;
extern statetype s_boobusbomb2;
extern statetype s_bombexplode;
extern statetype s_bombexplode2;
extern statetype s_bombexplode3;
extern statetype s_bombexplode4;
extern statetype s_bombexplode5;
extern statetype s_bombexplode6;
extern statetype s_powerblink1;
extern statetype s_powerblink2;
statetype s_flowerpower1 = {FLOWERPOWER1SPR,FLOWERPOWER1SPR,stepthink,false,
false,10, 0,0, ProjectileThink, PowerContact, PowerReact, &s_flowerpower2};
statetype s_flowerpower2 = {FLOWERPOWER2SPR,FLOWERPOWER2SPR,stepthink,false,
false,10, 0,0, ProjectileThink, PowerContact, PowerReact, &s_flowerpower1};
statetype s_boobusbomb1 = {BOOBUSBOMB1SPR,BOOBUSBOMB1SPR,stepthink,false,
false,5, 0,0, ProjectileThink, PowerContact, PowerReact, &s_boobusbomb2};
statetype s_boobusbomb2 = {BOOBUSBOMB3SPR,BOOBUSBOMB3SPR,stepthink,false,
false,5, 0,0, ProjectileThink, PowerContact, PowerReact, &s_boobusbomb1};
statetype s_bombexplode = {BOOBUSBOOM1SPR,BOOBUSBOOM1SPR,step,false,
false,5, 0,0, NULL, NULL, DrawReact, &s_bombexplode2};
statetype s_bombexplode2= {BOOBUSBOOM2SPR,BOOBUSBOOM2SPR,step,false,
false,5, 0,0, NULL, NULL, DrawReact, &s_bombexplode3};
statetype s_bombexplode3= {BOOBUSBOOM1SPR,BOOBUSBOOM1SPR,step,false,
false,5, 0,0, NULL, NULL, DrawReact, &s_bombexplode4};
statetype s_bombexplode4= {BOOBUSBOOM2SPR,BOOBUSBOOM2SPR,step,false,
false,5, 0,0, NULL, NULL, DrawReact, &s_bombexplode5};
statetype s_bombexplode5= {BOOBUSBOOM1SPR,BOOBUSBOOM1SPR,step,false,
false,5, 0,0, NULL, NULL, DrawReact, &s_bombexplode6};
statetype s_bombexplode6= {BOOBUSBOOM2SPR,BOOBUSBOOM2SPR,step,false,
false,5, 0,0, NULL, NULL, DrawReact, NULL};
statetype s_powerblink1 = {FLOWERPOWER1SPR,FLOWERPOWER1SPR,step,false,
false,5, 0,0, PowerCount, NULL, DrawReact, &s_powerblink2};
statetype s_powerblink2 = {-1,-1,step,false,
false,5, 0,0, PowerCount, NULL, DrawReact, &s_powerblink1};
/*
===============
=
= ThrowPower
=
===============
*/
void ThrowPower (unsigned x, unsigned y, int dir)
{
statetype *startstate;
if (mapon == 15)
{
if (!gamestate.boobusbombs)
{
SD_PlaySound (NOWAYSND);
return; // no bombs to throw
}
SD_PlaySound (THROWBOMBSND);
gamestate.bombsthislevel--;
gamestate.boobusbombs--;
}
else
{
if (!gamestate.flowerpowers)
{
SD_PlaySound (NOWAYSND);
return; // no flower power to throw
}
SD_PlaySound (THROWSND);
gamestate.flowerpowers--;
}
GetNewObj (true);
new->obclass = powerobj;
new->temp2 = dir;
new->x = x;
new->y = y;
new->tileleft = new->tileright = x>>G_T_SHIFT;
new->tiletop = new->tilebottom = y>>G_T_SHIFT;
new->ydir = -1;
switch (dir)
{
case dir_North:
new->xspeed = 0;
new->yspeed = SPDPOWERUP;
break;
case dir_East:
new->xspeed = SPDPOWER;
new->yspeed = SPDPOWERY;
break;
case dir_South:
new->xspeed = 0;
new->yspeed = SPDPOWER;
break;
case dir_West:
new->xspeed = -SPDPOWER;
new->yspeed = SPDPOWERY;
break;
default:
Quit ("ThrowPower: Bad dir!");
}
if (mapon != 15)
{
new->temp1 = 8; // flower power bonus
startstate = &s_flowerpower1;
}
else
{
new->temp1 = 10; // boobus bomb bonus
startstate = &s_boobusbomb1;
}
new->active = removable;
#if 0
new->x -= 5*new->xspeed; // make sure they hit nearby walls
new->y -= 5*new->yspeed;
#endif
NewState (new,startstate);
#if 0
new->xmove = 5*new->xspeed;
new->ymove = 5*new->yspeed;
ClipToWalls (new);
#endif
}
/*
============================
=
= PowerCount
=
============================
*/
void PowerCount (objtype *ob)
{
ob->temp2+=tics;
ob->shapenum = 0;
if (ob->temp2 > POWERCOUNT)
RemoveObj(ob);
}
/*
============================
=
= CalcSingleGravity
=
============================
*/
void CalcSingleGravity (void)
{
unsigned speed;
long i;
//
// only accelerate on odd tics, because of limited precision
//
speed = 0;
singlegravity = 0;
for (i=lasttimecount-tics;i<lasttimecount;i++)
{
if (i&1)
{
speed+=ACCGRAVITY;
if (speed>SPDMAXY)
speed=SPDMAXY;
}
singlegravity+=speed;
}
singlegravity/=2;
}
/*
============================
=
= PowerContact
=
============================
*/
void PowerContact (objtype *ob, objtype *hit)
{
unsigned x,y,yspot,xspot;
switch (hit->obclass)
{
case broccoobj:
case tomatobj:
case carrotobj:
case celeryobj:
case asparobj:
case taterobj:
case frenchyobj:
case squashobj:
case apelobj:
case peapodobj:
case peabrainobj:
ChangeToFlower (hit);
RemoveObj (ob);
break;
case boobusobj:
if (!--hit->temp4)
{
// killed boobus
GivePoints (50000);
GivePoints (50000);
hit->obclass = inertobj;
ChangeState (hit,&s_boobusdie);
hit->temp1 = 0; // death count
}
SD_PlaySound (BOMBBOOMSND);
ChangeState (ob,&s_bombexplode);
break;
}
}
/*
============================
=
= PowerReact
=
============================
*/
void PowerReact (objtype *ob)
{
unsigned wall,absx,absy,angle,newangle;
unsigned long speed;
PLACESPRITE;
if (ob->hiteast || ob->hitwest)
{
ob->xspeed= -ob->xspeed/2;
ob->obclass = bonusobj;
}
if (ob->hitsouth)
{
if ( ob->hitsouth == 17) // go through pole holes
{
if (ob->temp2 != dir_North)
ob->obclass = bonusobj;
ob->top-=32;
ob->y-=32;
ob->xspeed = 0;
ob->x = ob->tilemidx*TILEGLOBAL + 4*PIXGLOBAL;
}
else
{
ob->yspeed= -ob->yspeed/2;
}
return;
}
wall = ob->hitnorth;
if ( wall == 17) // go through pole holes
{
if (ob->temp2 != dir_South)
ob->obclass = bonusobj;
ob->bottom+=32;
ob->y+=32;
ob->xspeed = 0;
ob->x = ob->tilemidx*TILEGLOBAL + 4*PIXGLOBAL;
}
else if (wall)
{
ob->obclass = bonusobj;
if (ob->yspeed < 0)
ob->yspeed = 0;
absx = abs(ob->xspeed);
absy = ob->yspeed;
if (absx>absy)
{
if (absx>absy*2) // 22 degrees
{
angle = 0;
speed = absx*286; // x*sqrt(5)/2
}
else // 45 degrees
{
angle = 1;
speed = absx*362; // x*sqrt(2)
}
}
else
{
if (absy>absx*2) // 90 degrees
{
angle = 3;
speed = absy*256;
}
else
{
angle = 2; // 67 degrees
speed = absy*286; // y*sqrt(5)/2
}
}
if (ob->xspeed > 0)
angle = 7-angle;
speed >>= 1;
newangle = bounceangle[ob->hitnorth][angle];
switch (newangle)
{
case 0:
ob->xspeed = speed / 286;
ob->yspeed = -ob->xspeed / 2;
break;
case 1:
ob->xspeed = speed / 362;
ob->yspeed = -ob->xspeed;
break;
case 2:
ob->yspeed = -(speed / 286);
ob->xspeed = -ob->yspeed / 2;
break;
case 3:
case 4:
ob->xspeed = 0;
ob->yspeed = -(speed / 256);
break;
case 5:
ob->yspeed = -(speed / 286);
ob->xspeed = ob->yspeed / 2;
break;
case 6:
ob->xspeed = ob->yspeed = -(speed / 362);
break;
case 7:
ob->xspeed = -(speed / 286);
ob->yspeed = ob->xspeed / 2;
break;
case 8:
ob->xspeed = -(speed / 286);
ob->yspeed = -ob->xspeed / 2;
break;
case 9:
ob->xspeed = -(speed / 362);
ob->yspeed = -ob->xspeed;
break;
case 10:
ob->yspeed = speed / 286;
ob->xspeed = -ob->yspeed / 2;
break;
case 11:
case 12:
ob->xspeed = 0;
ob->yspeed = -(speed / 256);
break;
case 13:
ob->yspeed = speed / 286;
ob->xspeed = ob->yspeed / 2;
break;
case 14:
ob->xspeed = speed / 362;
ob->yspeed = speed / 362;
break;
case 15:
ob->xspeed = speed / 286;
ob->yspeed = ob->xspeed / 2;
break;
}
if (speed < 256*16)
{
if (mapon == 15)
{
ob->ydir = -1; // bonus stuff flies up when touched
ob->temp2 = ob->shapenum = BOOBUSBOMB1SPR;
ob->temp3 = ob->temp2 + 2;
ob->needtoclip = 0;
ChangeState (ob,&s_bonus);
}
else
{
ChangeState (ob,&s_powerblink1);
ob->needtoclip = 0;
ob->temp2 = 0; // blink time
}
}
}
}
/*
=============================================================================
MINI KEEN
player->temp1 = dir
player->temp2 = animation stage
#define WORLDKEENSLEEP1SPR 238
#define WORLDKEENSLEEP2SPR 239
#define WORLDKEENWAVE1SPR 240
#define WORLDKEENWAVE2SPR 241
=============================================================================
*/
void SpawnWorldKeen (int tilex, int tiley);
void KeenWorldThink (objtype *ob);
void KeenWorldWalk (objtype *ob);
extern statetype s_worldkeen;
extern statetype s_worldkeenwave1;
extern statetype s_worldkeenwave2;
extern statetype s_worldkeenwave3;
extern statetype s_worldkeenwave4;
extern statetype s_worldkeenwave5;
extern statetype s_worldkeenwait;
extern statetype s_worldkeensleep1;
extern statetype s_worldkeensleep2;
extern statetype s_worldwalk;
#pragma warn -sus
statetype s_worldkeen = {NULL,NULL,stepthink,false,
false,360, 0,0, KeenWorldThink, NULL, DrawReact, &s_worldkeenwave1};
statetype s_worldkeenwave1= {WORLDKEENWAVE1SPR,WORLDKEENWAVE1SPR,stepthink,false,
false,20, 0,0, KeenWorldThink, NULL, DrawReact, &s_worldkeenwave2};
statetype s_worldkeenwave2= {WORLDKEENWAVE2SPR,WORLDKEENWAVE2SPR,stepthink,false,
false,20, 0,0, KeenWorldThink, NULL, DrawReact, &s_worldkeenwave3};
statetype s_worldkeenwave3= {WORLDKEENWAVE1SPR,WORLDKEENWAVE1SPR,stepthink,false,
false,20, 0,0, KeenWorldThink, NULL, DrawReact, &s_worldkeenwave4};
statetype s_worldkeenwave4= {WORLDKEENWAVE2SPR,WORLDKEENWAVE2SPR,stepthink,false,
false,20, 0,0, KeenWorldThink, NULL, DrawReact, &s_worldkeenwave5};
statetype s_worldkeenwave5= {WORLDKEENWAVE1SPR,WORLDKEENWAVE1SPR,stepthink,false,
false,20, 0,0, KeenWorldThink, NULL, DrawReact, &s_worldkeenwait};
statetype s_worldkeenwait = {WORLDKEEND3SPR,WORLDKEEND3SPR,stepthink,false,
false,400, 0,0, KeenWorldThink, NULL, DrawReact, &s_worldkeensleep1};
statetype s_worldkeensleep1 = {WORLDKEENSLEEP1SPR,WORLDKEENSLEEP1SPR,stepthink,false,
false,30, 0,0, KeenWorldThink, NULL, DrawReact, &s_worldkeensleep2};
statetype s_worldkeensleep2 = {WORLDKEENSLEEP2SPR,WORLDKEENSLEEP2SPR,stepthink,false,
false,90, 0,0, KeenWorldThink, NULL, DrawReact, &s_worldkeensleep2};
statetype s_worldwalk = {NULL,NULL,slide,false,
false,4, 16,16, KeenWorldWalk, NULL, DrawReact, &s_worldwalk};
#pragma warn +sus
/*
======================
=
= SpawnWorldKeen
=
======================
*/
void SpawnWorldKeen (int tilex, int tiley)
{
player->obclass = keenobj;
if (!gamestate.worldx)
{
player->x = tilex<<G_T_SHIFT;
player->y = tiley<<G_T_SHIFT;
}
else
{
player->x = gamestate.worldx;
player->y = gamestate.worldy;
}
player->active = yes;
player->needtoclip = true;
player->xdir = 0;
player->ydir = 0;
player->temp1 = dir_West;
player->temp2 = 3;
player->shapenum = 3+WORLDKEENL1SPR-1; // feet together
NewState (player,&s_worldkeen);
}
/*
======================
=
= CheckEnterLevel
=
======================
*/
void CheckEnterLevel (objtype *ob)
{
int x,y,tile;
for (y=ob->tiletop;y<=ob->tilebottom;y++)
for (x=ob->tileleft;x<=ob->tileright;x++)
{
tile = *((unsigned _seg *)mapsegs[2]+mapbwidthtable[y]/2+x);
if (tile >= 3 && tile <=18)
{
//
// enter level!
//
if (tile == 17)
{
if (gamestate.boobusbombs < 12)
{
VW_FixRefreshBuffer ();
US_CenterWindow (26,6);
PrintY+= 8;
US_CPrint ("You can't possibly\n"
"defeat King Boobus Tuber\n"
"with less than 12 bombs!");
VW_UpdateScreen ();
IN_Ack ();
RF_ForceRefresh ();
return;
}
}
gamestate.worldx = ob->x;
gamestate.worldy = ob->y;
gamestate.mapon = tile-2;
playstate = levelcomplete;
SD_PlaySound (ENTERLEVELSND);
}
}
}
/*