-
Notifications
You must be signed in to change notification settings - Fork 0
/
koules.c
executable file
·2052 lines (1900 loc) · 53.7 KB
/
koules.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
/***********************************************************
* K O U L E S *
*----------------------------------------------------------*
* C1995 JAHUSOFT *
* Jan Hubicka *
* Dukelskych Bojovniku 1944 *
* 390 03 Tabor *
* Czech Republic *
* Phone: 0041-361-32613 *
* eMail: [email protected] *
*----------------------------------------------------------*
* Copyright(c)1995,1996 by Jan Hubicka.See README for *
* licence details. *
*----------------------------------------------------------*
* koules.c main game routines *
***********************************************************/
/* Changes for OS/2 Warp with Dive. *
* Copyright(c)1996 by Thomas A. K. Kjaer *
***********************************************************/
/* Changes for joystick "accelerate by deflection" *
* (c) 1997 by Ludvik Tesar (Ludv\'{\i}k Tesa\v{r}) *
************************LT*********************************/
#include <unistd.h>
#define VARIABLES_HERE
#include "koules.h"
#include "server.h"
#include "client.h"
#include <sys/time.h>
#include "framebuffer.h"
int nobjects = 8;
int nrockets = 0;
int drawpointer = 1;
//DKS - changed default difficulty from 2 (medium) to 1 (hard) because medium is just too easy and slow-paced
//int difficulty = 2;
int difficulty = 1;
int cit = 0;
#ifdef NETSUPPORT
int client = 0, server = 0;
#endif
Object object[MAXOBJECT];
Point point[MAXPOINT];
// DKS - modified for SDL
//BitmapType bball_bitmap, apple_bitmap, inspector_bitmap, mouse_bitmap,
// lunatic_bitmap, lball_bitmap[NLETTERS], circle_bitmap,
// hole_bitmap, ball_bitmap, eye_bitmap[MAXROCKETS], rocket_bitmap[MAXROCKETS],
// ehole_bitmap;
SDL_Surface *bball_bitmap = NULL,
*apple_bitmap = NULL,
*inspector_bitmap = NULL,
*mouse_bitmap = NULL,
*lunatic_bitmap = NULL,
*lball_bitmap[NLETTERS],
*circle_bitmap = NULL,
*hole_bitmap = NULL,
*ball_bitmap = NULL,
*eye_bitmap[MAXROCKETS],
*rocket_bitmap[MAXROCKETS],
*ehole_bitmap = NULL;
// DKS - original, had to change for platforms not supporting unaligned access
//unsigned char rocketcolor[5] =
//{96, 160, 64, 96, 128};
unsigned int rocketcolor[5] =
{96, 160, 64, 96, 128};
// 64 = red, 96 = yellow
// 128 seems to be invisible.. why!? .. should be green
// 160 also seems to be invisible.. why!? .. should be blue
#ifdef SOUND
int sndinit = 1;
#endif
int lastlevel = 0, maxlevel = 0;
// DKS - original, had to change for platforms not supporting unaligned access
//unsigned char control[MAXROCKETS];
unsigned int control[MAXROCKETS];
struct control controls[MAXROCKETS];
int dosprings = 0;
int randsprings = 0;
int nomouse = 0;
int textcolor;
int sound = 1;
int tbreak;
int gameplan = COOPERATIVE;
int npoint = 0;
int gamemode;
int keys[5][4];
int rotation[MAXROCKETS];
int a_bballs, a_rockets, a_balls, a_holes, a_apples, a_inspectors,
a_lunatics, a_eholes;
//DKS
//#ifdef MOUSE
//int mouseplayer = -1;
//#endif
#ifdef JOYSTICK
int joystickplayer[2] =
{-1, -1};
int joystickdevice[2] =
{-1, -1};
int calibrated[2];
int center[2][2];
float joystickmul[2]={1.5,1.5};
float joystickthresh[2]={0.1,0.1};
#endif
//DKS - default difficulty has been changed from medium level to hard level:
//float ROCKET_SPEED = 1.2;
//float BALL_SPEED = 1.2;
//float BBALL_SPEED = 1.2;
//float SLOWDOWN = 0.8;
//float GUMM = 20;
//float BALLM = 3;
//float LBALLM = 3;
//float BBALLM = 8;
//float APPLEM = 34;
//float ROCKETM = 4;
float ROCKET_SPEED = 1.0;
float BALL_SPEED = 1.2;
float BBALL_SPEED = 1.2;
float SLOWDOWN = 0.9;
float GUMM = 20;
float BALLM = 3;
float LBALLM = 3;
float BBALLM = 8;
float APPLEM = 40;
float ROCKETM = 3.6;
float INSPECTORM = 2;
float LUNATICM = 3.14;
void
addpoint (CONST int x, CONST int y, CONST int xp, CONST int yp, CONST int color, CONST int time)
{
point[npoint].x = x / DIV;
point[npoint].y = y / DIV;
point[npoint].xp = xp / DIV;
point[npoint].yp = yp / DIV;
point[npoint].time = time;
point[npoint].color = color;
npoint++;
if (npoint >= MAXPOINT)
npoint = 0;
}
//DKS
//#ifdef XSUPPORT /*fast code for slow X :) */
//#define CCONST 3
//#define PCONST 0
//XPoint mypixels[256 >> CCONST][MAXPOINT];
//int nmypixels[256 >> CCONST];
//#ifdef MITSHM
//void
//shmpoints ()
//{
// register unsigned int x, y;
// Point *p, *lp;
// lp = &point[MAXPOINT];
// for (p = point; p < lp; p++)
// {
// if (p->time > 0)
// {
// p->time--;
// x = (p->x += p->xp) >> 8;
// y = (p->y += p->yp);
// if (x > 0 && x < MAPWIDTH &&
// y > 0 && y >> 8 < MAPHEIGHT)
// SMySetPixel (backscreen, x, y, p->color);
// else
// p->time = 0;
// }
// }
//}
//#endif
//
//void
//points ()
//{
// register unsigned int x, y, c;
// Point *p, *lp;
//
//
//#ifdef MITSHM
// if (shm)
// {
// shmpoints ();
// return;
// }
//#endif
//
// for (x = 0; x < 256 >> CCONST; x++)
// nmypixels[x] = 0;
// lp = &point[MAXPOINT];
// for (p = point; p < lp; p++)
// {
// if (p->time > 0)
// {
// p->time--;
// x = (p->x += p->xp) >> 8;
// y = (p->y += p->yp) >> 8;
// if (x > 0 && x < MAPWIDTH &&
// y > 0 && y < MAPHEIGHT)
// {
// c = p->color >> CCONST;
// mypixels[c][nmypixels[c]].x = x;
// mypixels[c][nmypixels[c]].y = y;
// nmypixels[c]++;
// }
// else
// p->time = 0;
// }
// }
// for (x = 0; x < 256 >> CCONST; x++)
// {
// if (nmypixels[x])
// {
// SetColor ((x << CCONST) + PCONST);
// XDrawPoints (dp, current.pixmap, gc, mypixels[x], nmypixels[x], CoordModeOrigin);
// }
// }
//}
//#else
void
points ()
{
//DEBUG
//if (0) {
if SDL_MUSTLOCK(physicalscreen)
SDL_LockSurface(physicalscreen);
//DKS these two are from me:
// Uint16 *pixels_ptr = (Uint16 *)(physicalscreen->pixels);
// Uint16 surface_width = physicalscreen->w;
#ifdef SDL32BPP
Uint32 *pixels_ptr = (Uint32 *)(physicalscreen->pixels);
Uint32 surface_width = physicalscreen->w;
#else
Uint16 *pixels_ptr = (Uint16 *)(physicalscreen->pixels);
Uint32 surface_width = physicalscreen->w;
#endif
register unsigned int x, y;
Point *p, *lp;
lp = &point[MAXPOINT];
for (p = point; p < lp; p++)
{
if (p->time > 0)
{
p->time--;
//DKS
// x = (p->x += p->xp) >> 8;
// y = (p->y += p->yp);
// if (x > 0 && x < MAPWIDTH &&
// y > 0 && y >> 8 < MAPHEIGHT)
//DKS - had to fix a bug here, both need to be divided by 256
x = (p->x += p->xp) >> 8;
y = (p->y += p->yp) >> 8;
if (x > 0 && x < MAPWIDTH &&
y > 0 && y < MAPHEIGHT)
// SMySetPixel (backscreen, x, y, p->color);
//DKS
#ifndef SDL32BPP
pixels_ptr[y * surface_width + x] = colors_16bit[p->color];
#else
pixels_ptr[y * surface_width + x] = colors_RGBA[p->color];
#endif
else
p->time = 0;
}
}
if SDL_MUSTLOCK(physicalscreen)
SDL_UnlockSurface(physicalscreen);
}
//DKS
//#endif
void
points1 ()
{
Point *p, *lp;
lp = &point[MAXPOINT];
for (p = point; p < lp; p++)
{
if (p->time > 0)
{
p->time--;
p->x += p->xp;
p->y += p->yp;
}
}
}
INLINE int
radius (CONST int type)
{
switch (type)
{
case EHOLE:
case HOLE:
return (HOLE_RADIUS);
case ROCKET:
return (ROCKET_RADIUS);
case BALL:
case LBALL:
return (BALL_RADIUS);
case BBALL:
return (BBALL_RADIUS);
case APPLE:
return (APPLE_RADIUS);
case INSPECTOR:
return (INSPECTOR_RADIUS);
case LUNATIC:
return (LUNATIC_RADIUS);
}
return (0);
}
static INLINE int
color (CONST int type, CONST int i, CONST int letter)
{
switch (type)
{
case EHOLE:
return (128);
case HOLE:
return (64);
case ROCKET:
return (rocketcolor[i]);
case BALL:
return (64);
case LBALL:
switch (letter)
{
case L_ACCEL:
return (128);
case L_GUMM:
return (160);
case L_THIEF:
return (192);
case L_FINDER:
return (3 * 32);
case L_TTOOL:
return (3 * 32);
}
case BBALL:
return (128);
case APPLE:
return (64);
case INSPECTOR:
return (160);
case LUNATIC:
return (3 * 32);
}
return (0);
}
INLINE float
M (CONST int type)
{
switch (type)
{
case APPLE:
return (APPLEM);
case INSPECTOR:
return (INSPECTORM);
case LUNATIC:
return (LUNATICM);
case HOLE:
case EHOLE:
return (BBALLM);
case ROCKET:
return (ROCKETM);
case BALL:
case LBALL:
return (BALLM);
case BBALL:
return (BBALLM);
}
return (0);
}
int
find_possition (float *x, float *y, CONST float radius)
{
int x1, y1, i, y2 = 0;
float xp, yp;
rerand:;
x1 = rand () % (GAMEWIDTH - 60) + 30;
y1 = rand () % (GAMEHEIGHT - 60) + 30;
for (i = 0; i < nobjects; i++)
{
xp = x1 - object[i].x;
yp = y1 - object[i].y;
if (xp * xp + yp * yp < (radius + object[i].radius) *
(radius + object[i].radius))
{
y2++;
if (y2 > 10000)
return (0);
goto rerand;
}
}
*x = (float) x1;
*y = (float) y1;
return (1);
}
INLINE void
normalize (float *x, float *y, CONST float size)
{
float length = sqrt ((*x) * (*x) + (*y) * (*y));
if (length == 0)
length = 1;
*x *= size / length;
*y *= size / length;
}
static void
move_objects ()
{
int i;
for (i = 0; i < nobjects; i++)
if (object[i].type == CREATOR)
{
object[i].time--;
if (object[i].time <= 0)
{
Effect (S_CREATOR2, next);
object[i].live = object[i].live1;
object[i].type = object[i].ctype;
if (object[i].type == ROCKET)
object[i].time = 200;
object[i].radius = radius (object[i].ctype);
object[i].M = M (object[i].ctype);
}
}
else if (object[i].live)
{
object[i].x += object[i].fx * (GAMEWIDTH / 640.0 + 1) / 2;
object[i].y += object[i].fy * (GAMEWIDTH / 640.0 + 1) / 2;
}
}
static int helpmode;
//DKS - modified & replaced
//static void help(int x,int y,int radius,char *text)
//{
// int x1=x+radius+2,y1=y-4*DIV,x2=x1+strlen(text)*8*DIV,y2=y1+8*DIV;
// if(helpmode&&x1>0&&x2<=GAMEWIDTH-DIV&&y1>0&&y2<GAMEHEIGHT-DIV) {
// DrawBlackMaskedText(x1/DIV+1,y1/DIV+1,text);
// DrawWhiteMaskedText(x1/DIV,y1/DIV,text);
// }
//}
//DKS
static void help(int x,int y,int radius,char *text)
{
int x1=x+radius+2,y1=y-4*DIV,x2=x1+strlen(text)*8*DIV,y2=y1+8*DIV;
if(helpmode&&x1>0&&x2<=GAMEWIDTH-DIV&&y1>0&&y2<GAMEHEIGHT-DIV) {
DrawBlackMaskedText(physicalscreen, x1/DIV+1,y1/DIV+1,text);
DrawWhiteMaskedText(physicalscreen, x1/DIV,y1/DIV,text);
}
}
char str[2];
static void
draw_objects (CONST int draw)
{
char s[80];
int i;
if (draw)
{
//CopyVSToVS (background, backscreen);
#ifdef GCW
copybackground(background,physicalscreen);
// Line (physicalscreen, 0, MAPHEIGHT, MAPWIDTH - 1, MAPHEIGHT, back (16));
SDL_DrawLine(physicalscreen,0,MAPHEIGHT,MAPWIDTH-1,MAPHEIGHT,colors_RGBA[ball(2)]);
#else
CopyVSToVS (background, physicalscreen);
#endif
//SetScreen (backscreen);
/* Now draw the objects in backscreen. */
points ();
//DKS
// help(0,9,0,"Help - press 'H' to disable");
//DKS - decided help was more of a hindrance:
// help(0,MAPHEIGHT+21,0,"Help - press right trigger to disable");
//DKS
//#ifdef XSUPPORT
//#ifdef MITSHM
// if (!shm)
//#else
// if (1)
//#endif
// {
// XSegment lines[MAXOBJECT];
// int nlines = 0;
// for (i = 0; i < nobjects; i++)
// if (object[i].live && object[i].lineto != -1 && object[object[i].lineto].live)
// {
// lines[nlines].x1 = object[i].x / DIV;
// lines[nlines].y1 = object[i].y / DIV;
// lines[nlines].x2 = object[object[i].lineto].x / DIV;
// lines[nlines].y2 = object[object[i].lineto].y / DIV;
// nlines++;
// }
// SetColor (255);
// XDrawSegments (dp, current.pixmap, gc, lines, nlines);
//
// }
// else
//#endif
for (i = 0; i < nobjects; i++)
if (object[i].live && object[i].lineto != -1 && object[object[i].lineto].live) {
//DKS
// Line (object[i].x / DIV,
// object[i].y / DIV,
// object[object[i].lineto].x / DIV,
// object[object[i].lineto].y / DIV,
// 255);
Line (physicalscreen, object[i].x / DIV,
object[i].y / DIV,
object[object[i].lineto].x / DIV,
object[object[i].lineto].y / DIV,
255);
help((object[i].x+object[object[i].lineto].x)/2,
(object[i].y+object[object[i].lineto].y)/2,
2,"Spit");
}
for (i = 0; i < nobjects; i++)
if (object[i].live)
{
switch (object[i].type)
{
case BALL:
//DKS
// PutBitmap ((int) (object[i].x - BALL_RADIUS) / DIV, (int) (object[i].y - BALL_RADIUS) / DIV,
// BALL_RADIUS * 2 / DIV, BALL_RADIUS * 2 / DIV, ball_bitmap);
PutBitmap ((int) (object[i].x - BALL_RADIUS) / DIV, (int) (object[i].y - BALL_RADIUS) / DIV,
ball_bitmap, physicalscreen);
help(object[i].x,object[i].y,object[i].radius,"Koules");
break;
case LBALL:
switch (object[i].letter)
{
case L_ACCEL:
//DKS
// PutBitmap ((int) (object[i].x - BALL_RADIUS) / DIV, (int) (object[i].y - BALL_RADIUS) / DIV,
// BALL_RADIUS * 2 / DIV, BALL_RADIUS * 2 / DIV, lball_bitmap[0]);
PutBitmap ((int) (object[i].x - BALL_RADIUS) / DIV, (int) (object[i].y - BALL_RADIUS) / DIV,
lball_bitmap[0], physicalscreen);
help(object[i].x,object[i].y,object[i].radius,"Acceleration");
break;
case L_GUMM:
////DKS
// PutBitmap ((int) (object[i].x - BALL_RADIUS) / DIV, (int) (object[i].y - BALL_RADIUS) / DIV,
// BALL_RADIUS * 2 / DIV, BALL_RADIUS * 2 / DIV, lball_bitmap[1]);
PutBitmap ((int) (object[i].x - BALL_RADIUS) / DIV, (int) (object[i].y - BALL_RADIUS) / DIV,
lball_bitmap[1], physicalscreen);
help(object[i].x,object[i].y,object[i].radius,"Weight");
break;
case L_THIEF:
//DKS
// PutBitmap ((int) (object[i].x - BALL_RADIUS) / DIV, (int) (object[i].y - BALL_RADIUS) / DIV,
// BALL_RADIUS * 2 / DIV, BALL_RADIUS * 2 / DIV, lball_bitmap[2]);
PutBitmap ((int) (object[i].x - BALL_RADIUS) / DIV, (int) (object[i].y - BALL_RADIUS) / DIV,
lball_bitmap[2], physicalscreen);
help(object[i].x,object[i].y,object[i].radius,"Thief");
break;
case L_FINDER:
//DKS
// PutBitmap ((int) (object[i].x - BALL_RADIUS) / DIV, (int) (object[i].y - BALL_RADIUS) / DIV,
// BALL_RADIUS * 2 / DIV, BALL_RADIUS * 2 / DIV, lball_bitmap[3]);
PutBitmap ((int) (object[i].x - BALL_RADIUS) / DIV, (int) (object[i].y - BALL_RADIUS) / DIV,
lball_bitmap[3], physicalscreen);
help(object[i].x,object[i].y,object[i].radius,"Goodie");
break;
case L_TTOOL:
//DKS
// PutBitmap ((int) (object[i].x - BALL_RADIUS) / DIV, (int) (object[i].y - BALL_RADIUS) / DIV,
// BALL_RADIUS * 2 / DIV, BALL_RADIUS * 2 / DIV, lball_bitmap[4]);
PutBitmap ((int) (object[i].x - BALL_RADIUS) / DIV, (int) (object[i].y - BALL_RADIUS) / DIV,
lball_bitmap[4], physicalscreen);
help(object[i].x,object[i].y,object[i].radius,"Thief toolkit");
break;
}
//DKS - This is for when running at higher resolutions, where a letter is placed over the balls..
// we don't need this..
//
//#if !defined(XSUPPORT)||defined(MITSHM)
//#ifdef MITSHM
// if (DIV == 1 && shm)
//#else
// if (DIV == 1)
//#endif
// {
// str[0] = object[i].letter;
// DrawBlackMaskedText ((int) object[i].x / DIV - 4, (int) object[i].y / DIV - 4, str);
// }
//#endif
break;
case HOLE:
EnableClipping ();
//DKS
// PutBitmap ((int) (object[i].x - HOLE_RADIUS) / DIV, (int) (object[i].y - HOLE_RADIUS) / DIV,
// HOLE_RADIUS * 2, HOLE_RADIUS * 2, hole_bitmap);
PutBitmap ((int) (object[i].x - HOLE_RADIUS) / DIV, (int) (object[i].y - HOLE_RADIUS) / DIV,
hole_bitmap, physicalscreen);
DisableClipping ();
help(object[i].x,object[i].y,object[i].radius,"Black hole");
break;
case EHOLE:
EnableClipping ();
//DKS
// PutBitmap ((int) (object[i].x - HOLE_RADIUS) / DIV, (int) (object[i].y - HOLE_RADIUS) / DIV,
// HOLE_RADIUS * 2, HOLE_RADIUS * 2, ehole_bitmap);
PutBitmap ((int) (object[i].x - HOLE_RADIUS) / DIV, (int) (object[i].y - HOLE_RADIUS) / DIV,
ehole_bitmap, physicalscreen);
DisableClipping ();
help(object[i].x,object[i].y,object[i].radius,"Magnetic hole");
break;
case BBALL:
//DKS
// PutBitmap ((int) (object[i].x - BBALL_RADIUS) / DIV, (int) (object[i].y - BBALL_RADIUS) / DIV,
// BBALL_RADIUS * 2 / DIV, BBALL_RADIUS * 2 / DIV, bball_bitmap);
PutBitmap ((int) (object[i].x - BBALL_RADIUS) / DIV, (int) (object[i].y - BBALL_RADIUS) / DIV,
bball_bitmap, physicalscreen);
help(object[i].x,object[i].y,object[i].radius,"BBALL!");
break;
case INSPECTOR:
//DKS
// PutBitmap ((int) (object[i].x - INSPECTOR_RADIUS) / DIV, (int) (object[i].y - INSPECTOR_RADIUS) / DIV,
// INSPECTOR_RADIUS * 2 / DIV, INSPECTOR_RADIUS * 2 / DIV, inspector_bitmap);
PutBitmap ((int) (object[i].x - INSPECTOR_RADIUS) / DIV, (int) (object[i].y - INSPECTOR_RADIUS) / DIV,
inspector_bitmap, physicalscreen);
help(object[i].x,object[i].y,object[i].radius,"Inspector");
break;
case LUNATIC:
//DKS
// PutBitmap ((int) (object[i].x - LUNATIC_RADIUS) / DIV, (int) (object[i].y - LUNATIC_RADIUS) / DIV,
// LUNATIC_RADIUS * 2 / DIV, LUNATIC_RADIUS * 2 / DIV, lunatic_bitmap);
PutBitmap ((int) (object[i].x - LUNATIC_RADIUS) / DIV, (int) (object[i].y - LUNATIC_RADIUS) / DIV,
lunatic_bitmap, physicalscreen);
help(object[i].x,object[i].y,object[i].radius,"Lunatic");
break;
case APPLE:
//DKS
// PutBitmap ((int) (object[i].x - APPLE_RADIUS) / DIV, (int) (object[i].y - APPLE_RADIUS) / DIV,
// APPLE_RADIUS * 2 / DIV, APPLE_RADIUS * 2 / DIV, apple_bitmap);
PutBitmap ((int) (object[i].x - APPLE_RADIUS) / DIV, (int) (object[i].y - APPLE_RADIUS) / DIV,
apple_bitmap, physicalscreen);
EnableClipping ();
//DKS
// Line ((int) (object[i].x + 10) / DIV, (int) (object[i].y - APPLE_RADIUS - 10) / DIV,
// (int) (object[i].x) / DIV, (int) (object[i].y - APPLE_RADIUS + 10) / DIV, 150);
// Line ((int) (object[i].x + 10) / DIV + 1, (int) (object[i].y - APPLE_RADIUS - 10) / DIV,
// (int) (object[i].x) / DIV + 1, (int) (object[i].y - APPLE_RADIUS + 10) / DIV, 150);
Line (physicalscreen, (int) (object[i].x + 10) / DIV, (int) (object[i].y - APPLE_RADIUS - 10) / DIV,
(int) (object[i].x) / DIV, (int) (object[i].y - APPLE_RADIUS + 10) / DIV, 150);
Line (physicalscreen, (int) (object[i].x + 10) / DIV + 1, (int) (object[i].y - APPLE_RADIUS - 10) / DIV,
(int) (object[i].x) / DIV + 1, (int) (object[i].y - APPLE_RADIUS + 10) / DIV, 150);
//DKS no DIV of 1 on GP2X
// if (DIV == 1)
// Line ((int) (object[i].x + 10) / DIV + 2, (int) (object[i].y - APPLE_RADIUS - 10) / DIV,
// (int) (object[i].x) / DIV + 2, (int) (object[i].y - APPLE_RADIUS + 10) / DIV, 150);
DisableClipping ();
//DKS
// PutBitmap ((int) (object[i].x - EYE_RADIUS) / DIV,
// (int) (object[i].y + APPLE_RADIUS - 15) / DIV,
// EYE_RADIUS * 2 / DIV, EYE_RADIUS * 2 / DIV, eye_bitmap[0]);
PutBitmap ((int) (object[i].x - EYE_RADIUS) / DIV,
(int) (object[i].y + APPLE_RADIUS - 15) / DIV,
eye_bitmap[0], physicalscreen);
help(object[i].x,object[i].y,object[i].radius,"APPLEPOLISHER");
break;
case ROCKET:
{
int x1, y1;
help(object[i].x,object[i].y,object[i].radius,"Player");
//DKS
// PutBitmap ((int) (object[i].x - ROCKET_RADIUS) / DIV, (int) (object[i].y - ROCKET_RADIUS) / DIV,
// ROCKET_RADIUS * 2 / DIV, ROCKET_RADIUS * 2 / DIV, rocket_bitmap[i]);
PutBitmap ((int) (object[i].x - ROCKET_RADIUS) / DIV, (int) (object[i].y - ROCKET_RADIUS) / DIV,
rocket_bitmap[i], physicalscreen);
EnableClipping ();
if (!object[i].thief)
{
x1 = object[i].x + sin (object[i].rotation - RAD (30)) * EYE_RADIUS1 - EYE_RADIUS;
y1 = object[i].y + cos (object[i].rotation - RAD (30)) * EYE_RADIUS1 - EYE_RADIUS;
//DKS
// PutBitmap ((int) (x1 / DIV), (int) (y1 / DIV),
// (int) (EYE_RADIUS * 2 / DIV), (EYE_RADIUS * 2 / DIV), eye_bitmap[i]);
PutBitmap ((int) (x1 / DIV), (int) (y1 / DIV),
eye_bitmap[i], physicalscreen);
x1 = object[i].x + sin (object[i].rotation + RAD (30)) * EYE_RADIUS1 - EYE_RADIUS;
y1 = object[i].y + cos (object[i].rotation + RAD (30)) * EYE_RADIUS1 - EYE_RADIUS;
//DKS
// PutBitmap ((int) (x1 / DIV), (int) (y1 / DIV),
// (int) (EYE_RADIUS * 2 / DIV), (EYE_RADIUS * 2 / DIV), eye_bitmap[i]);
PutBitmap ((int) (x1 / DIV), (int) (y1 / DIV),
eye_bitmap[i], physicalscreen);
}
else
{
x1 = object[i].x + sin (object[i].rotation - RAD (30)) * EYE_RADIUS1 - BALL_RADIUS;
y1 = object[i].y + cos (object[i].rotation - RAD (30)) * EYE_RADIUS1 - BALL_RADIUS;
//DKS
// PutBitmap ((int) (x1 / DIV), (int) (y1 / DIV),
// (int) (BALL_RADIUS * 2 / DIV), (BALL_RADIUS * 2 / DIV), lball_bitmap[2]);
PutBitmap ((int) (x1 / DIV), (int) (y1 / DIV),
lball_bitmap[2], physicalscreen);
x1 = object[i].x + sin (object[i].rotation + RAD (30)) * EYE_RADIUS1 - BALL_RADIUS;
y1 = object[i].y + cos (object[i].rotation + RAD (30)) * EYE_RADIUS1 - BALL_RADIUS;
//DKS
// PutBitmap ((int) (x1 / DIV), (int) (y1 / DIV),
// (int) (BALL_RADIUS * 2 / DIV), (BALL_RADIUS * 2 / DIV), lball_bitmap[2]);
PutBitmap ((int) (x1 / DIV), (int) (y1 / DIV),
lball_bitmap[2], physicalscreen);
}
DisableClipping ();
}
break;
}
}
}
/*if draw */
else
points1 ();
switch (gamemode)
{
case MENU:
draw_menu (draw);
break;
case KEYS:
draw_keys (draw);
break;
#ifdef JOYSTICK
case JOY:
draw_joy (draw);
break;
#endif
}
//DKS - blit a shaded bottom bar on the screen before the score/lives are blitted:
SDL_Rect dest_rect = {.x=0, .y=MAPHEIGHT+1, .w=320, .h=320-MAPHEIGHT};
SDL_BlitSurface(bottom_bar, NULL, physicalscreen, &dest_rect);
//DKS
//#ifdef MOUSE
// if (draw && (gamemode == MENU || (gamemode == GAME && mouseplayer != -1)) &&
// MouseX () >= 0 && MouseY () >= 0 && MouseX () < MAPWIDTH &&
// MouseY () < MAPHEIGHT && drawpointer)
// {
// EnableClipping ();
// if (!nomouse)
// {
// PutBitmap (MouseX () - MOUSE_RADIUS, MouseY () - MOUSE_RADIUS,
// MOUSE_RADIUS * 2, MOUSE_RADIUS * 2, mouse_bitmap);
// DisableClipping ();
// }
// }
//#endif
if (draw)
{
EnableClipping ();
if (gameplan == COOPERATIVE && gamemode == GAME && DIV == 1)
{
sprintf (s, "Level: %3i", lastlevel + 1);
//DKS
//DrawWhiteMaskedText ((MAPWIDTH / 2 - 38 * 4) / 2 - strlen (s) * 4, MAPHEIGHT + 2, s);
DrawWhiteMaskedText (physicalscreen, (MAPWIDTH / 2 - 38 * 4) / 2 - strlen (s) * 4, MAPHEIGHT + 2, s);
}
//DKS
// sprintf (s, " lives: %6i%6i%6i%6i%6i",
// nrockets >= 1 ? object[0].live1 : 0,
// nrockets >= 2 ? object[1].live1 : 0,
// nrockets >= 3 ? object[2].live1 : 0,
// nrockets >= 4 ? object[3].live1 : 0,
// nrockets >= 5 ? object[4].live1 : 0);
//DKS - altered game to only display lives/score when we're actually playing the game
if (in_actual_game) {
if (nrockets > 1)
sprintf (s, "P1 Lives: %6i", object[0].live1 );
else
sprintf (s, "Lives: %6i", object[0].live1 );
//DKS
//DrawWhiteMaskedText (MAPWIDTH / 2 - strlen (s) * 4, MAPHEIGHT + 2, s);
DrawBlackMaskedText (physicalscreen, 2+1 , MAPHEIGHT + 2+1, s);
DrawWhiteMaskedText (physicalscreen, 2 , MAPHEIGHT + 2, s);
if (nrockets == 2) {
sprintf(s, "P2 Lives: %6i", object[1].live1);
DrawBlackMaskedText (physicalscreen, MAPWIDTH - strlen(s)*8-1, MAPHEIGHT + 2+1, s);
DrawWhiteMaskedText (physicalscreen, MAPWIDTH - strlen(s)*8-2, MAPHEIGHT + 2, s);
}
//DKS
// DrawWhiteMaskedText (physicalscreen, MAPWIDTH / 2 - strlen (s) * 4, MAPHEIGHT + 2, s);
// sprintf (s, "scores: %6i%6i%6i%6i%6i",
// object[0].score,
// object[1].score,
// object[2].score,
// object[3].score,
// object[4].score);
if (nrockets > 1)
sprintf (s, " Score: %6i",
object[0].score);
else
sprintf (s, "Score: %6i",
object[0].score);
//DKS
//DrawWhiteMaskedText (MAPWIDTH / 2 - strlen (s) * 4, MAPHEIGHT + 11, s);
DrawBlackMaskedText (physicalscreen, 2+1 , MAPHEIGHT + 11+1, s);
DrawWhiteMaskedText (physicalscreen, 2 , MAPHEIGHT + 11, s);
if (nrockets == 2) {
sprintf(s, "Score: %6i", object[1].score);
DrawBlackMaskedText (physicalscreen, MAPWIDTH - strlen(s)*8-1 , MAPHEIGHT + 11+1, s);
DrawWhiteMaskedText (physicalscreen, MAPWIDTH - strlen(s)*8-2 , MAPHEIGHT + 11, s);
}
}
/* Copy backscreen to physical screen. */
//DKS
//CopyToScreen (backscreen);
//DKS - added
flippage();
fadein ();
DisableClipping ();
}
}
void
explosion (CONST int x, CONST int y, CONST int type, CONST int letter, CONST int n)
{
float i;
int speed;
int color1;
int radius1 = radius (type);
#ifdef NETSUPPORT
if (server)
{
Explosion (x, y, type, letter, n);
return;
}
#endif
for (i = 0; i < RAD (360); i += RAD (360.0) * DIV * DIV / radius1 / radius1 / M_PI)
{
speed = rand () % 3096 + 10;
if (DIV == 1)
color1 = color (type, n, letter) + (rand () % 16);
else
color1 = color (type, n, letter) + (rand () % 32);
addpoint (x * 256, y * 256,
sin (i) * (speed),
cos (i) * (speed),
color1,
rand () % 100 + 10);
}
}
static void
rocket_destroyed (CONST int player)
{
int i, nalive = 0, igagnant = 0;
if (gamemode == GAME)
switch (gameplan)
{
case DEATHMATCH:
if (nrockets == 1)
return;
for (i = 0; i < nrockets; i++)
if (object[i].type == ROCKET && object[i].live && i != player)
{
object[i].score += 100;
nalive++;
igagnant = i;
}
if (nalive == 1) /* winner bonus */
object[igagnant].score += 50;
}
}
void
destroy (CONST int i)
{
int y;
if (object[i].x - object[i].radius < 0)
object[i].x = object[i].radius + 1, object[i].fx *= -1;
if (object[i].y - object[i].radius < 0)
object[i].y = object[i].radius + 1, object[i].fy *= -1;
if (object[i].x + object[i].radius > GAMEWIDTH)
object[i].x = GAMEWIDTH - object[i].radius - 1, object[i].fx *= -1;
if (object[i].y + object[i].radius > GAMEHEIGHT)
object[i].y = GAMEHEIGHT - object[i].radius - 1, object[i].fy *= -1;
switch (object[i].type)
{
case LBALL:
Effect (S_DESTROY_BALL, next);
object[i].live = 0, explosion (object[i].x, object[i].y, object[i].type, object[i].letter, i);
if (object[i].letter == L_THIEF && allow_finder ())
{
object[i].live = 1;
object[i].letter = L_FINDER;
} /* else
if (object[i].letter == L_FINDER )
{
object[i].live = 1;
object[i].letter = L_THIEF;
} */
break;
case APPLE:
Effect (S_DESTROY_ROCKET, 0);
object[i].live = 0, explosion (object[i].x, object[i].y, object[i].type, object[i].letter, i);
break;
case BALL:
case EHOLE:
case BBALL:
case INSPECTOR:
case LUNATIC:
Effect (S_DESTROY_BALL, next);
if ((y = create_letter ()) != 0)
{
object[i].type = LBALL;
object[i].M = LBALLM;
switch (y)
{
case 1:
object[i].letter = L_ACCEL;
break;
case 2:
object[i].letter = L_GUMM;
break;