Guest User

Untitled

a guest
Jan 23rd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 33.42 KB | None | 0 0
  1. // movement.c
  2. // Created 5/8/2009; 11:14:51 PM
  3. //31
  4. #include "all.h"
  5.  
  6. #define BOB_LEFT_BOUND 3
  7. #define BOB_RIGHT_BOUND 12
  8. #define BOB_UP_BOUND 0
  9. #define BOB_DOWN_BOUND 20
  10.  
  11. #define ENEMY1_LEFT_BOUND_FACING_LEFT 1
  12. #define ENEMY1_RIGHT_BOUND_FACING_LEFT 12
  13. #define ENEMY1_UP_BOUND 0
  14. #define ENEMY1_DOWN_BOUND 16
  15.  
  16.  
  17. //This function helps slow down movement
  18. void delay(short time)
  19. {
  20. short int randNum;
  21. // generate random numbers to slow down the program...
  22. while (time-- > 0) {
  23. randNum = rand() % time;
  24. }
  25. }
  26.  
  27. /*
  28. void moveTile (void)
  29. {
  30. static short x;
  31. if (x == 0)x=1;
  32. else x = 0;
  33. fg_map[3+1][9] = x;
  34. }*/
  35.  
  36.  
  37.  
  38.  
  39. void Die ()
  40. {
  41. if (bob.health == 0)
  42. {
  43. if (fishx-10 < bob.coordinates.xLocal)
  44. {
  45. GrayClipSprite16_MASK_R (fishx, fishy, 16, fish[2], &fish[2][16], fish[3], &fish[3][16], dBufHPL_G, dBufHPD_G);
  46. }
  47. else
  48. {
  49. GrayClipSprite16_MASK_R (fishx, fishy, 16, fish[0], &fish[0][16], fish[1], &fish[1][16], dBufHPL_G, dBufHPD_G);
  50. }
  51. fishx--;
  52. }
  53. }
  54.  
  55. void firstBulletMovement (BULLET *bullet)
  56. {
  57. /*(*blist)->xLocal+=((*blist)->direction*((BULLET_TYPE*)(*blist)->type)->speed+globs->shiftfgx);
  58. ((BULLET*)bullet)->xLocal+=
  59. (*blist)->yLocal+=globs->shiftfgy;
  60. (*blist)->xGlobal+=((*blist)->direction*((BULLET_TYPE*)(*blist)->type)->speed);*/
  61. }
  62.  
  63. void secondBulletMovement (BULLET *bullet)
  64. {
  65.  
  66. }
  67.  
  68. static inline BOOL collision (BOB *bob, short direction, char *map)
  69. {
  70. //int x;
  71. //GrayClipSprite8_MASK_R (bob->xLocal+10+random (10), bob->y+random (10), 8, Blood[0], &Blood[0][8], Blood[1], &Blood[1][8], dBufAPL_G, dBufAPD_G);
  72. switch (direction)
  73. {
  74. case M_DOWN:
  75. return
  76. *(map+((bob->coordinates.yGlobal+20)>>3)*((Plane*)RunningLevel->planes[1])->width+((bob->coordinates.xGlobal+5)>>3)) > 0
  77. ||
  78. *(map+((bob->coordinates.yGlobal+20)>>3)*((Plane*)RunningLevel->planes[1])->width+((bob->coordinates.xGlobal+10)>>3)) > 0;
  79. case M_UP:
  80. //return map[(bob->coordinates.yGlobal)/8][(bob->coordinates.xGlobal+5)/8] || map[(bob->coordinates.yGlobal)/8][(bob->coordinates.xGlobal+10)/8];
  81. return
  82. *(map+((bob->coordinates.yGlobal)>>3)*((Plane*)RunningLevel->planes[1])->width+((bob->coordinates.xGlobal+5)>>3)) > 0
  83. ||
  84. *(map+((bob->coordinates.yGlobal)>>3)*((Plane*)RunningLevel->planes[1])->width+((bob->coordinates.xGlobal+10)>>3)) > 0;
  85. case M_LEFT:
  86. //return map[(bob->coordinates.yGlobal)/8][(bob->coordinates.xGlobal+3)/8] || map[(bob->coordinates.yGlobal+8)/8][(bob->coordinates.xGlobal+3)/8] || map[(bob->coordinates.yGlobal+16)/8][(bob->coordinates.xGlobal+3)/8] || map[(bob->coordinates.yGlobal+19)/8][(bob->coordinates.xGlobal+3)/8];
  87. return
  88. *(map+((bob->coordinates.yGlobal)>>3)*((Plane*)RunningLevel->planes[1])->width+((bob->coordinates.xGlobal+3)>>3)) > 0
  89. ||
  90. *(map+((bob->coordinates.yGlobal+8)>>3)*((Plane*)RunningLevel->planes[1])->width+((bob->coordinates.xGlobal+3)>>3)) > 0
  91. ||
  92. *(map+((bob->coordinates.yGlobal+16)>>3)*((Plane*)RunningLevel->planes[1])->width+((bob->coordinates.xGlobal+3)>>3)) > 0
  93. ||
  94. *(map+((bob->coordinates.yGlobal+19)>>3)*((Plane*)RunningLevel->planes[1])->width+((bob->coordinates.xGlobal+3)>>3)) > 0;
  95. case M_RIGHT:
  96. //return map[(bob->coordinates.yGlobal)/8][(bob->coordinates.xGlobal+12)/8] || map[(bob->coordinates.yGlobal+8)/8][(bob->coordinates.xGlobal+12)/8] || map[(bob->coordinates.yGlobal+16)/8][(bob->coordinates.xGlobal+12)/8] || map[(bob->coordinates.yGlobal+19)/8][(bob->coordinates.xGlobal+12)/8];
  97. return
  98. *(map+((bob->coordinates.yGlobal)>>3)*((Plane*)RunningLevel->planes[1])->width+((bob->coordinates.xGlobal+12)>>3)) > 0
  99. ||
  100. *(map+((bob->coordinates.yGlobal+8)>>3)*((Plane*)RunningLevel->planes[1])->width+((bob->coordinates.xGlobal+12)>>3)) > 0
  101. ||
  102. *(map+((bob->coordinates.yGlobal+16)>>3)*((Plane*)RunningLevel->planes[1])->width+((bob->coordinates.xGlobal+12)>>3)) > 0
  103. ||
  104. *(map+((bob->coordinates.yGlobal+19)>>3)*((Plane*)RunningLevel->planes[1])->width+((bob->coordinates.xGlobal+12)>>3)) > 0;
  105. }
  106. }
  107.  
  108. //for bob:
  109. /*
  110. LEFT_BOUND = 4 (FOR UP AND DOWN IT IS 5!!!!)
  111. RIGHT_BOUND = 11 (FOR UP AND DOWN IT IS 10!!!!!)
  112. UP_BOUND = 0
  113. DOWN_BOUND = 20
  114. */
  115.  
  116.  
  117. //collision (bob->coordinates.xGlobal, bob->y, BOB_LEFT_BOUND, BOB_RIGHT_BOUND, BOB_UP_BOUND, BOB_DOWN_BOUND, M_DOWN, fg_map);
  118.  
  119. static BOOL collisionEnemy (short x, short y, short LEFT_BOUND, short RIGHT_BOUND, short UP_BOUND, short DOWN_BOUND, short direction, char *map)
  120. {
  121. switch (direction)
  122. {
  123. case M_DOWN:
  124. return
  125. *(map+((y+DOWN_BOUND)>>3)*((Plane*)RunningLevel->planes[1])->width+((x+LEFT_BOUND+1)>>3)) > 0
  126. ||
  127. *(map+((y+DOWN_BOUND)>>3)*((Plane*)RunningLevel->planes[1])->width+((x+RIGHT_BOUND)>>3)) > 0
  128. ||
  129. *(map+((y+DOWN_BOUND)>>3)*((Plane*)RunningLevel->planes[1])->width+((x+RIGHT_BOUND-1)>>3)) > 0;
  130. case M_UP:
  131. return
  132. *(map+((y+UP_BOUND)>>3)*((Plane*)RunningLevel->planes[1])->width+((x+LEFT_BOUND+1)>>3)) > 0
  133. ||
  134. *(map+((y+UP_BOUND)>>3)*((Plane*)RunningLevel->planes[1])->width+((x+9)>>3)) > 0
  135. ||
  136. *(map+((y+UP_BOUND)>>3)*((Plane*)RunningLevel->planes[1])->width+((x+RIGHT_BOUND-1)>>3)) > 0;
  137. case M_LEFT:
  138. return
  139. *(map+((y+UP_BOUND)>>3)*((Plane*)RunningLevel->planes[1])->width+((x+LEFT_BOUND)>>3)) > 0
  140. ||
  141. *(map+((y+(DOWN_BOUND/3)-1)>>3)*((Plane*)RunningLevel->planes[1])->width+((x+LEFT_BOUND)>>3)) > 0
  142. ||
  143. *(map+(((y+(2/3)*DOWN_BOUND)-1)>>3)*((Plane*)RunningLevel->planes[1])->width+((x+LEFT_BOUND)>>3)) > 0
  144. ||
  145. *(map+((y+DOWN_BOUND-1)>>3)*((Plane*)RunningLevel->planes[1])->width+((x+LEFT_BOUND)>>3)) > 0;
  146. case M_RIGHT:
  147. return
  148. *(map+((y+UP_BOUND)>>3)*((Plane*)RunningLevel->planes[1])->width+((x+RIGHT_BOUND)>>3)) > 0
  149. ||
  150. *(map+((y+(DOWN_BOUND>>1))>>3)*((Plane*)RunningLevel->planes[1])->width+((x+RIGHT_BOUND)>>3)) > 0
  151. ||
  152. *(map+((y+DOWN_BOUND-1)>>3)*((Plane*)RunningLevel->planes[1])->width+((x+RIGHT_BOUND)>>3)) > 0
  153. ||
  154. *(map+((y+(DOWN_BOUND>>1))>>3)*((Plane*)RunningLevel->planes[1])->width+((x+RIGHT_BOUND)>>3)) > 0;
  155. }
  156. }
  157.  
  158. void follow(ENEMY *enemies)
  159. {
  160. if (enemies->xGlobal > bob.coordinates.xGlobal)
  161. {
  162. enemies->moveDirectionX = -1;
  163. enemies->facing = 0;
  164. }
  165. else if (enemies->xGlobal < bob.coordinates.xGlobal)
  166. {
  167. enemies->moveDirectionX = 1;
  168. enemies->facing = 2;
  169. }
  170. }
  171.  
  172. void movePear(ENEMY *enemies)
  173. {
  174. if (collisionEnemy (enemies->xGlobal, enemies->yGlobal, enemies->type->left_bound, enemies->type->right_bound, enemies->type->up_bound, enemies->type->down_bound, M_RIGHT, (char*)((Plane*)RunningLevel->planes[1])->matrix))
  175. {
  176. enemies->moveDirectionX = -1;
  177. enemies->facing = 0;
  178. }
  179. else if (collisionEnemy (enemies->xGlobal, enemies->yGlobal, enemies->type->left_bound, enemies->type->right_bound, enemies->type->up_bound, enemies->type->down_bound, M_LEFT, (char*)((Plane*)RunningLevel->planes[1])->matrix))
  180. {
  181. enemies->moveDirectionX = 1;
  182. enemies->facing = 2;
  183. }
  184. }
  185.  
  186. void moveJump(ENEMY *enemies)
  187. {
  188. follow(enemies);
  189. if ((collisionEnemy (enemies->xGlobal, enemies->yGlobal, enemies->type->left_bound, enemies->type->right_bound, enemies->type->up_bound, enemies->type->down_bound, M_RIGHT, (char*)((Plane*)RunningLevel->planes[1])->matrix) && enemies->moveDirectionX == 1) || (collisionEnemy (enemies->xGlobal, enemies->yGlobal, enemies->type->left_bound, enemies->type->right_bound, enemies->type->up_bound, enemies->type->down_bound, M_LEFT, (char*)((Plane*)RunningLevel->planes[1])->matrix) && enemies->moveDirectionX == -1))
  190. {
  191. enemies->moveDirectionX = 0;
  192. }
  193. if (collisionEnemy (enemies->xGlobal, enemies->yGlobal, enemies->type->left_bound, enemies->type->right_bound, enemies->type->up_bound, enemies->type->down_bound, M_DOWN, (char*)((Plane*)RunningLevel->planes[1])->matrix))
  194. {
  195. enemies->jumping = TRUE;
  196. }
  197. if (enemies->jumping && enemies->jumpCount < enemies->type->jumpHeight && !collisionEnemy (enemies->xGlobal, enemies->yGlobal, enemies->type->left_bound, enemies->type->right_bound, enemies->type->up_bound, enemies->type->down_bound, M_UP, (char*)((Plane*)RunningLevel->planes[1])->matrix))
  198. {
  199. enemies->jumpCount++;
  200. enemies->yGlobal--;
  201. enemies->yLocal--;
  202. }
  203. else
  204. {
  205. enemies->jumping = FALSE;
  206. enemies->jumpCount = 0;
  207. }
  208. }
  209.  
  210. void smartJump(ENEMY *enemies)
  211. {
  212. if ((collisionEnemy (enemies->xGlobal, enemies->yGlobal, enemies->type->left_bound, enemies->type->right_bound, enemies->type->up_bound, enemies->type->down_bound, M_RIGHT, (char*)((Plane*)RunningLevel->planes[1])->matrix) && enemies->moveDirectionX == 1) || (collisionEnemy (enemies->xGlobal, enemies->yGlobal, enemies->type->left_bound, enemies->type->right_bound, enemies->type->up_bound, enemies->type->down_bound, M_LEFT, (char*)((Plane*)RunningLevel->planes[1])->matrix) && enemies->moveDirectionX == -1) && !enemies->jumping)
  213. {
  214. enemies->moveDirectionX = 0;
  215. if (collisionEnemy (enemies->xGlobal, enemies->yGlobal, enemies->type->left_bound, enemies->type->right_bound, enemies->type->up_bound, enemies->type->down_bound, M_DOWN, (char*)((Plane*)RunningLevel->planes[1])->matrix))
  216. {
  217. enemies->jumping = TRUE;
  218. }
  219. }
  220. else
  221. {
  222. if (!enemies->jumping)
  223. follow (enemies);
  224. }
  225. if (enemies->jumping && enemies->jumpCount < enemies->type->jumpHeight && !collisionEnemy (enemies->xGlobal, enemies->yGlobal, enemies->type->left_bound, enemies->type->right_bound, enemies->type->up_bound, enemies->type->down_bound, M_UP, (char*)((Plane*)RunningLevel->planes[1])->matrix))
  226. {
  227. enemies->jumpCount++;
  228. enemies->yGlobal--;
  229. enemies->yLocal--;
  230. }
  231. else
  232. {
  233. enemies->jumpCount = 0;
  234. enemies->jumping = FALSE;
  235. }
  236. }
  237.  
  238. short radarUP = 0;
  239. short radarDOWN = 0;
  240. BOOL travel = FALSE;
  241.  
  242.  
  243. void evil (ENEMY *enemies)
  244. {
  245. if (!travel)
  246. {
  247. follow (enemies);
  248. }
  249. if (enemies->xGlobal == bob.coordinates.xGlobal && !travel)
  250. {
  251. if (enemies->yGlobal > bob.coordinates.yGlobal)
  252. {
  253. travel = TRUE;
  254. }
  255. }
  256. if (travel)
  257. {
  258. for (radarUP = enemies->yGlobal; radarUP > bob.coordinates.yGlobal; radarUP--, radarDOWN++)
  259. {
  260. if (collisionEnemy (enemies->xGlobal-5, radarUP, 0, 8, 0, 8, M_UP, (char*)((Plane*)RunningLevel->planes[1])->matrix))
  261. {
  262. break;
  263. }
  264. }
  265. if (radarUP <= bob.coordinates.yGlobal)
  266. {
  267. //enemies->type->jumpHeight = radarDOWN + 8;
  268. enemies->jumping = TRUE;
  269. enemies->moveDirectionX = 0;
  270. enemies->facing = 0;
  271. }
  272. else
  273. {
  274. enemies->moveDirectionX = 1;
  275. enemies->facing = 2;
  276. }
  277. }
  278. if ((collisionEnemy (enemies->xGlobal, enemies->yGlobal, enemies->type->left_bound, enemies->type->right_bound, enemies->type->up_bound, enemies->type->down_bound, M_RIGHT, (char*)((Plane*)RunningLevel->planes[1])->matrix) && enemies->moveDirectionX == 1) || (collisionEnemy (enemies->xGlobal, enemies->yGlobal, enemies->type->left_bound, enemies->type->right_bound, enemies->type->up_bound, enemies->type->down_bound, M_LEFT, (char*)((Plane*)RunningLevel->planes[1])->matrix) && enemies->moveDirectionX == -1) && !enemies->jumping)
  279. {
  280. enemies->moveDirectionX = 0;
  281. if (collisionEnemy (enemies->xGlobal, enemies->yGlobal, enemies->type->left_bound, enemies->type->right_bound, enemies->type->up_bound, enemies->type->down_bound, M_DOWN, (char*)((Plane*)RunningLevel->planes[1])->matrix))
  282. {
  283. enemies->jumping = TRUE;
  284. }
  285. }
  286. if (enemies->jumping && enemies->jumpCount < enemies->type->jumpHeight && !collisionEnemy (enemies->xGlobal, enemies->yGlobal, enemies->type->left_bound, enemies->type->right_bound, enemies->type->up_bound, enemies->type->down_bound, M_UP, (char*)((Plane*)RunningLevel->planes[1])->matrix))
  287. {
  288. enemies->jumpCount++;
  289. enemies->yGlobal--;
  290. enemies->yLocal--;
  291. }
  292. else
  293. {
  294. enemies->jumpCount = 0;
  295. enemies->jumping = FALSE;
  296. }
  297. if (enemies->yGlobal+5 == bob.coordinates.yGlobal)
  298. {
  299. travel = FALSE;
  300. radarUP = 0;
  301. radarDOWN = 0;
  302. }
  303. }
  304.  
  305. void moveGhost (ENEMY *enemies)
  306. {
  307. if (enemies->xGlobal > bob.coordinates.xGlobal)
  308. {
  309. enemies->moveDirectionX = -1;
  310. enemies->facing = 0;
  311. }
  312. else if (enemies->xGlobal < bob.coordinates.xGlobal)
  313. {
  314. enemies->moveDirectionX = 1;
  315. enemies->facing = 2;
  316. }
  317. if (enemies->yGlobal > bob.coordinates.yGlobal)
  318. {
  319. enemies->moveDirectionY = -1;
  320. }
  321. else if (enemies->yGlobal < bob.coordinates.yGlobal)
  322. {
  323. enemies->moveDirectionY = 1;
  324. }
  325. }
  326. /*
  327. static inline BOOL collisionBullet(BULLET* bullet, short direction, char** map)
  328. {
  329. switch(direction)
  330. {
  331. case M_RIGHT:
  332. return map[(bullet->yGlobal)/8][(bullet->xGlobal+7)/8] || map[(bullet->yGlobal+3)/8][(bullet->xGlobal+7)/8];
  333. }
  334. }*/
  335.  
  336. static inline BOOL collisionBullet (BULLET *bullet, short direction, char *map)
  337. {
  338. switch (direction)
  339. {
  340. case M_RIGHT:
  341. return
  342. *(map+((bullet->yGlobal+0)>>3)*((Plane*)RunningLevel->planes[1])->width+((bullet->xGlobal+6)>>3)) > 0
  343. ||
  344. *(map+((bullet->yGlobal+(6>>1))>>3)*((Plane*)RunningLevel->planes[1])->width+((bullet->xGlobal+6)>>3)) > 0;
  345. case M_LEFT:
  346. return
  347. *(map+((bullet->yGlobal+(0))>>3)*((Plane*)RunningLevel->planes[1])->width+((bullet->xGlobal)>>3)) > 0
  348. ||
  349. *(map+((bullet->yGlobal+(6>>1))>>3)*((Plane*)RunningLevel->planes[1])->width+((bullet->xGlobal)>>3)) > 0;
  350. }
  351. }
  352.  
  353. void renderBullets (void)
  354. {
  355. {
  356.  
  357. /*for (;i < BULLETS_ALLOWED; i++)
  358. {
  359. if (Bullets_On_Screen[i].x < 1 || Bullets_On_Screen[i].x > 160 || Bullets_On_Screen[i].x == DEAD_BULLET || collisionBullet(&Bullets_On_Screen[i], M_RIGHT, fg_map))
  360. {
  361. Bullets_On_Screen[i].x = DEAD_BULLET;
  362. }
  363. else
  364. {
  365. GrayClipSprite8_MASK_R (Bullets_On_Screen[i].x, Bullets_On_Screen[i].y, 3, Bullets[Bullets_On_Screen[i].bullet], &Bullets[Bullets_On_Screen[i].bullet][3], guns[Bullets_On_Screen[i].bullet+1], &Bullets[Bullets_On_Screen[i].bullet+1][6], dBufAPL_G, dBufAPD_G);
  366. Bullets_On_Screen[i].x+=Bullets_On_Screen[i].countValue;
  367. Bullets_On_Screen[i].xGlobal+=Bullets_On_Screen[i].countValue;
  368. }
  369. }*/
  370. int i = BULLETS_ALLOWED-1;
  371. do
  372. {
  373. Bullets_On_Screen[i].y+=globs->shiftfgy;
  374. Bullets_On_Screen[i].x+=globs->shiftfgx;
  375. if (Bullets_On_Screen[i].x == DEAD_BULLET || collisionBullet(&Bullets_On_Screen[i], M_RIGHT, fg_map))
  376. {
  377. Bullets_On_Screen[i].x = DEAD_BULLET;
  378. }
  379. else
  380. {
  381. GrayClipSprite8_MASK_R (Bullets_On_Screen[i].x, Bullets_On_Screen[i].y, 8, Bullets[Bullets_On_Screen[i].bullet], &Bullets[Bullets_On_Screen[i].bullet][8], Bullets[Bullets_On_Screen[i].bullet+1], &Bullets[Bullets_On_Screen[i].bullet+1][8], dBufHPL_G, dBufHPD_G);
  382. if (Bullets_On_Screen[i].counter < bullet_speed)
  383. {
  384. Bullets_On_Screen[i].counter++;
  385. }
  386. else
  387. {
  388. Bullets_On_Screen[i].x+=Bullets_On_Screen[i].countValue;
  389. Bullets_On_Screen[i].xGlobal+=Bullets_On_Screen[i].countValue;
  390. Bullets_On_Screen[i].counter = 0;
  391. }
  392. }
  393. i--;
  394. }
  395. while (i >= 0);
  396. }
  397. }
  398.  
  399. //Display Bob
  400. inline void display_BOB (BOB* bob, short position, short facing)
  401. {
  402. short gun_side = 0;
  403. if (gun_facing == 2)
  404. {
  405. gun_side = -22;
  406. }
  407. int val = 0;
  408. if (facing == LEFT_NORMAL && position == 1)
  409. {
  410. val = 2;
  411. }
  412. else
  413. {
  414. val = 0;
  415. }
  416. //GrayDBufToggle ();
  417. //GrayDBufToggleSync ();
  418. switch(position)
  419. {
  420. case 0:
  421. {
  422. GrayClipSprite16_MASK_R (bob->coordinates.xLocal, bob->coordinates.yLocal, 20, sprite_BOB[facing], &sprite_BOB[facing][20], sprite_BOB[facing+1], &sprite_BOB[facing+1][20], dBufHPD_G, dBufHPL_G);
  423. //GrayClipSprite16_SMASK_R(bob->coordinates.xLocal, bob->y, 20, sprite_BOB[facing], &sprite_BOB[facing][20], &sprite_BOB[facing+2], dBufAPD_G, dBufAPL_G);
  424. GrayClipSprite8_MASK_R (bob->coordinates.xLocal+15+gun_side, bob->coordinates.yLocal+11, 6, guns[gun_facing], &guns[gun_facing][6], guns[gun_facing+1], &guns[gun_facing+1][6], dBufHPD_G, dBufHPL_G);
  425. //GrayClipSprite8_MASK_R (bob->coordinates.xLocal+4+val, bob->coordinates.yLocal-6, 8, hats[0], &hats[0][8], hats[1], &hats[1][8], dBufHPL_G, dBufHPD_G);
  426. break;
  427. }
  428. case 1:
  429. {
  430. //FastCopyScreen (dBufHPL_G, dBufAPL_G);FastCopyScreen (dBufHPD_G, dBufAPD_G);
  431. //GrayDBufToggleSync(); //set drawbuffer as active screen
  432. //dBufHPL_G = GrayDBufGetHiddenPlane(LIGHT_PLANE);
  433. //dBufHPD_G = GrayDBufGetHiddenPlane(DARK_PLANE);
  434.  
  435. GrayClipSprite16_MASK_R (bob->coordinates.xLocal, bob->coordinates.yLocal, 20, sprite_BOB[facing+2], &sprite_BOB[facing+2][20], sprite_BOB[facing+3], &sprite_BOB[facing+3][20], dBufHPL_G, dBufHPD_G);
  436. GrayClipSprite8_MASK_R (bob->coordinates.xLocal+15+gun_side, bob->coordinates.yLocal+8, 6, guns[gun_facing], &guns[gun_facing][6], guns[gun_facing+1], &guns[gun_facing+1][6], dBufHPL_G, dBufHPD_G);
  437. //GrayClipSprite8_MASK_R (bob->coordinates.xLocal+3+val, bob->coordinates.yLocal-6, 8, hats[0], &hats[0][8], hats[1], &hats[1][8], dBufHPL_G, dBufHPD_G);
  438. break;
  439. }
  440. }
  441. //GrayClipSprite16_TRANW_R (bob->coordinates.xLocal + 20, bob->y, 20, sprite_BOB[facing+2], &sprite_BOB[facing+2][20], dBufAPL_G, dBufAPD_G);
  442. //GrayClipSprite16_SMASK_R(bob->coordinates.xLocal, bob->y, 20, sprite_BOB[facing], &sprite_BOB[facing][20], sprite_BOB[facing+1], dBufAPL_G, dBufAPD_G);
  443. //GrayDBufToggleSync ();
  444. }
  445.  
  446. static inline void spawnEnemy (ENEMY *enemy)
  447. {
  448. // enemy->type = &pear;
  449. enemy->health = 31;
  450. enemy->moveDirectionX = -1;
  451. enemy->moveSpeed = 0;
  452. enemy->onscreen =TRUE;
  453. enemy->xLocal = bob.coordinates.xLocal;//154;
  454. enemy->xGlobal = bob.coordinates.xGlobal;
  455. enemy->yGlobal = 0;
  456. enemy->yLocal = 0 - y_fg;
  457. enemyCount++;
  458.  
  459. //enemy->health = enemySpawnPoints;
  460. }
  461.  
  462. //short earthx = 0;
  463. //short earthy = 0;
  464. short increment = 0;
  465. short earthrange = 10;
  466. short earthcount = 0;
  467. short earthspeed = 20;
  468.  
  469. void earthquake (void)
  470. {
  471. if (earthcount < earthspeed)
  472. {
  473. earthcount++;
  474. }
  475. else
  476. {
  477. increment = random (earthrange) - 5;
  478. x_fg += increment;
  479. if (collision (&bob, M_LEFT, ((Plane*)RunningLevel->planes[1])->matrix))
  480. {
  481. bob.coordinates.xLocal-=increment;
  482. }
  483. else if (collision (&bob, M_RIGHT, ((Plane*)RunningLevel->planes[1])->matrix))
  484. {
  485. bob.coordinates.xLocal-=increment;
  486. }
  487. else
  488. bob.coordinates.xGlobal += increment;
  489. earthcount = 0;
  490. }
  491. }
  492.  
  493. static inline void display_ENEMY (void)
  494. {
  495. ENEMY* backup = *enemyList;
  496. if (*enemyList != NULL)
  497. do
  498. {
  499.  
  500. // if ((*enemyList)->yGlobal > y_fg - (*enemyList)->type->height && (*enemyList)->yGlobal < y_fg+100)
  501. GrayClipSprite16_MASK_R ((*enemyList)->xLocal, (*enemyList)->yLocal, (*enemyList)->type->height,
  502. &gfx.enemy_gfx[(*enemyList)->type->index][(2*(*enemyList)->facing*(*enemyList)->type->height)],
  503. &gfx.enemy_gfx[(*enemyList)->type->index][(*enemyList)->type->height+2*(*enemyList)->facing*(*enemyList)->type->height],
  504. &gfx.enemy_gfx[(*enemyList)->type->index][2*(*enemyList)->facing*(*enemyList)->type->height+2*(*enemyList)->type->height],
  505. &gfx.enemy_gfx
  506. [(*enemyList)->type->index][(*enemyList)->type->height+2*(*enemyList)->type->height*(*enemyList)->facing+2*(*enemyList)->type->height],
  507. dBufHPL_G, dBufHPD_G);
  508. *enemyList = (*enemyList)->next;
  509. }
  510. while ((*enemyList) != backup);
  511. }
  512.  
  513. static inline void display_STATUS (void)
  514. {
  515. GrayClipSprite32_MASK_R (0, 91, 9, Status[0], &Status[0][9], StatusMask[0], &StatusMask[0][9], dBufHPL_G, dBufHPD_G);
  516. GraySprite32_RPLC_R(32, 91, 9, Status[1], &Status[1][9], dBufHPL_G, dBufHPD_G);
  517. GraySprite32_RPLC_R(64, 91, 9, Status[2], &Status[2][9], dBufHPL_G, dBufHPD_G);
  518. GraySprite32_RPLC_R(96, 91, 9, Status[3], &Status[3][9], dBufHPL_G, dBufHPD_G);
  519. GrayClipSprite32_MASK_R (128, 91, 9, Status[4], &Status[4][9], StatusMask[1], &StatusMask[1][9], dBufHPL_G, dBufHPD_G);
  520. GrayFastFillRect_R(dBufHPL_G, dBufHPD_G, 28, 94, 28+bob.health, 96, COLOR_BLACK);
  521. if (bob.health == 0)
  522. GrayFastFillRect_R(dBufHPL_G, dBufHPD_G, 27, 94, 30, 96, COLOR_WHITE);
  523. GrayFastOutlineRect_R(dBufHPL_G, dBufHPD_G, 27, 93, 58, 97, COLOR_WHITE);
  524. }
  525.  
  526. static void handleBullets (BLIST **blist, LEVEL *level)
  527. {
  528. BLIST *backup = NULL;
  529. if (level->bulletTimer > 0)
  530. {
  531. if (level->bulletTimer == (*blist)->type->period)
  532. level->bulletTimer = 0;
  533. else
  534. level->bulletTimer++;
  535. }
  536. if (_keytest (RR_SHIFT))
  537. {
  538. if (level->bulletTimer == 0)
  539. {
  540. PullTrigger (blist, &bob, facing, &gfx.bullet_types[0]);
  541. level->bulletTimer++;
  542. }
  543. }
  544.  
  545. backup = *blist;
  546. if (*blist != NULL)
  547. do
  548. {
  549. (*blist)->xLocal+=((*blist)->direction*(*blist)->type->speed+globs->shiftfgx);
  550. (*blist)->yLocal+=globs->shiftfgy;
  551. (*blist)->xGlobal+=((*blist)->direction*(*blist)->type->speed);
  552.  
  553. if (collisionEnemy ((*blist)->xGlobal, (*blist)->yGlobal, 0, 8, 0, 6,M_LEFT, (char*)((Plane*)RunningLevel->planes[1])->matrix) || collisionEnemy ((*blist)->xGlobal, (*blist)->yGlobal, 0, 8, 0, 6, M_RIGHT, (char*)((Plane*)RunningLevel->planes[1])->matrix) || (*blist)->xLocal < -100 || (*blist)->xLocal > 200)
  554. {
  555.  
  556. if (*blist == backup)
  557. {
  558. backup = (*blist)->next;
  559. }
  560. deleteBullet (blist);
  561. //temporary fix
  562. if (*blist == NULL)
  563. {
  564. level->bulletTimer = 0;
  565. return;
  566. }
  567. }
  568.  
  569. //pick sprite for bullet direction
  570. int base_offset = ((*blist)->direction > 0) ? 0 : 4*(*blist)->type->height;
  571.  
  572. GrayClipSprite8_MASK_R ((*blist)->xLocal, (*blist)->yLocal,
  573. (*blist)->type->height,
  574. (char*)(((*blist)->type)->data + base_offset),
  575. (char*)((*blist)->type->data+(*blist)->type->height + base_offset),
  576. (char*)((*blist)->type->data+2*(*blist)->type->height + base_offset),
  577. (char*)((*blist)->type->data+3*(*blist)->type->height + base_offset),
  578. dBufHPL_G, dBufHPD_G);
  579.  
  580. *blist = (*blist)->next;
  581.  
  582. }
  583. while (*blist != backup);
  584. }
  585.  
  586. static inline void render(LEVEL *level)
  587. {
  588. RenderPlane (x_fg, y_fg, level);
  589. int i = 0;
  590. for (;i < 4; i++)
  591. GrayClipSprite8_MASK_R (moving_tiles[i].xLocal, moving_tiles[i].yLocal, 5, moving_tiles_sprites[0], &moving_tiles_sprites[0][5], moving_tiles_sprites[1], &moving_tiles_sprites[1][5], dBufHPL_G, dBufHPD_G);
  592. display_ENEMY();
  593. display_BOB (&bob, position, facing);
  594. display_STATUS();
  595. Die();
  596. handleBullets(level->bullets,level);
  597. //renderBullets();
  598. //GrayClipSprite16_MASK_R (30, 50, 16, Enemies[8], &Enemies[8][16], Enemies[9], &Enemies[9][16], dBufHPL_G, dBufHPD_G);
  599. //GrayDBufToggle ();
  600. //UpsideDownGrayClipSprite16_MASK_R(bob.coordinates.xLocal, bob.coordinates.yLocal, 20, sprite_BOB[facing+2], &sprite_BOB[facing+2][20], sprite_BOB[facing+3], &sprite_BOB[facing+3][20], dBufHPL_G, dBufHPD_G);
  601. FastCopyScreen (dBufHPL_G, dBufAPL_G);
  602. FastCopyScreen (dBufHPD_G, dBufAPD_G);
  603. }
  604.  
  605. BOOL collisionTile (void)
  606. {
  607. int i = 0;
  608. for (;i < MOVING_TILE_NUMBER; i++)
  609. {
  610. if (bob.coordinates.xGlobal+12 >= moving_tiles[i].xGlobal && bob.coordinates.xGlobal+3 <= moving_tiles[i].xGlobal+8)
  611. {
  612. if(bob.coordinates.yGlobal+20 >= moving_tiles[i].yGlobal && bob.coordinates.yGlobal+20 <= moving_tiles[i].yGlobal+5)
  613. {
  614. tile_index = i;
  615. return TRUE;
  616. }
  617. }
  618. }
  619. tile_index = -1;
  620. return FALSE;
  621. }
  622.  
  623. BOOL calibrate = FALSE;
  624. BOOL calibrate2 = FALSE;
  625. short midpoint = 0;
  626. //keep Bob towards the ground
  627. static void gravity (void)
  628. {
  629. if (!collision (&bob, M_DOWN, (char*)((Plane*)RunningLevel->planes[1])->matrix) && !collisionTile() && jumping == JUMP_DISTANCE)
  630. {
  631. if (Gravity_Step == 2)
  632. {
  633. if (bob.coordinates.yGlobal%2)
  634. {
  635. bob.coordinates.yGlobal--;
  636. bob.coordinates.yLocal--;
  637. }
  638. }
  639. else if (Gravity_Step == 4)
  640. {
  641. if (!calibrate)
  642. {
  643. while ((bob.coordinates.yGlobal)%4)
  644. {
  645. bob.coordinates.yGlobal--;
  646. bob.coordinates.yLocal--;
  647. }
  648. calibrate = TRUE;
  649. }
  650. }
  651. bob.coordinates.yGlobal+=Gravity_Step;
  652. short i = 0;
  653. if (bob.coordinates.yLocal > 33 && y_fg+100 < LITERAL_MAP_HEIGHT)
  654. {
  655. y_fg+=Gravity_Step;
  656. globs->shiftfgy-=Gravity_Step;
  657. }
  658. else
  659. {
  660. bob.coordinates.yLocal+=Gravity_Step;
  661. }
  662. bob.Gravity_Counter++;
  663. if (bob.Gravity_Counter > 20 && bob.Gravity_Counter < 40)
  664. {
  665. Gravity_Step = 2;
  666. }
  667. else if (bob.Gravity_Counter >= 40)
  668. {
  669. Gravity_Step = 4;
  670. }
  671. }
  672. else
  673. {
  674. bob.Gravity_Limit = GRAVITY_SPEED;
  675. Gravity_Step = 1;
  676. bob.Gravity_Counter = 0;
  677. calibrate = FALSE;
  678. calibrate2 = FALSE;
  679. }
  680.  
  681. }
  682.  
  683. short global_count = 0;
  684. #define healthWait 500
  685. short healthcount = healthWait;
  686.  
  687.  
  688.  
  689. //Initiate a keytest sequence. This function must run in a loop!
  690. inline void move_BOB (BOB *bob, LEVEL *level)
  691. {
  692.  
  693. Scankeys();
  694. if (keymap.run)
  695. {
  696. accel = 1;
  697. }
  698. else
  699. {
  700. accel = 0;
  701. }
  702. if (jumping < JUMP_DISTANCE)
  703. {
  704. if (keymap.jump && !collision (bob, M_UP, (char*)((Plane*)RunningLevel->planes[1])->matrix)) //up
  705. {
  706. if (jump_counter < JUMP_SPEED)
  707. {
  708. jump_counter++;
  709. }
  710. else if (jumping < JUMP_DISTANCE)
  711. {
  712. if (bob->coordinates.yGlobal%2)
  713. {
  714. bob->coordinates.yGlobal++;
  715. bob->coordinates.yLocal++;
  716. }
  717. bob->coordinates.yGlobal-=2;
  718. if (bob->coordinates.yLocal < 35 && bob->coordinates.yGlobal > 33)
  719. {
  720. y_fg-=2;
  721. globs->shiftfgy+=2;
  722. }
  723. else
  724. {
  725. bob->coordinates.yLocal-=2;
  726. }
  727. if (position == 0)position = 1;
  728. else position = 0;
  729. jump_counter = 0;
  730. jumping+=2;
  731. }
  732. }
  733. else
  734. {
  735. jumping = JUMP_DISTANCE;
  736. }
  737. }
  738. if (keymap.right)
  739. {
  740. facing = RIGHT_NORMAL;
  741. if (!collision (bob, M_RIGHT, (char*)((Plane*)RunningLevel->planes[1])->matrix) && bob->health > 0) //If right key is pressed, then move right
  742. {
  743. gun_facing = 0;
  744. if (accel == 1)
  745. {
  746. if (bob->coordinates.xGlobal % 2)
  747. {
  748. bob->coordinates.xGlobal--;
  749. bob->coordinates.xLocal--;
  750. }
  751. }
  752. if (right_counter < RIGHT_SPEED)
  753. {
  754. right_counter++;
  755. }
  756. else if (bob->coordinates.xLocal >= 50 && bob->coordinates.xGlobal < ((Plane*)level->planes[1])->width*8-111)
  757. {
  758. x_fg+=(1+accel);
  759. globs->shiftfgx+=-(1+accel);
  760. bob->coordinates.xGlobal+=(1+accel);
  761. right_counter = 0;
  762. }
  763. else
  764. {
  765. bob->coordinates.xLocal+=(1+accel);
  766. bob->coordinates.xGlobal+=(1+accel);
  767. right_counter = 0;
  768. }
  769. if (position == 0)position = 1;
  770. else position = 0;
  771. }
  772. }
  773. else if (keymap.left)
  774. {
  775. facing = LEFT_NORMAL;
  776. if (bob->coordinates.xGlobal > LEFT && !collision (bob, M_LEFT, (char*)((Plane*)RunningLevel->planes[1])->matrix) && bob->health > 0) //If left key is pressed, then move left
  777. {
  778. gun_facing = 2;
  779. if (accel == 1)
  780. {
  781. if (bob->coordinates.xGlobal % 2)
  782. {
  783. bob->coordinates.xGlobal--;
  784. bob->coordinates.xLocal--;
  785. }
  786. }
  787. if (left_counter < LEFT_SPEED)
  788. {
  789. left_counter++;
  790. }
  791. else if (bob->coordinates.xLocal > 30 || bob->coordinates.xGlobal <= 30)
  792. {
  793. bob->coordinates.xLocal-=(1+accel);
  794. bob->coordinates.xGlobal-=(1+accel);
  795. left_counter = 0;
  796. }
  797. else if (bob->coordinates.xGlobal > 30)
  798. {
  799. x_fg-=(1+accel);
  800. short i = 19;
  801. globs->shiftfgx=1+accel;
  802. bob->coordinates.xGlobal-=(1+accel);
  803. left_counter = 0;
  804. }
  805. if (position == 0)position = 1;
  806. else position = 0;
  807. }
  808. }
  809. if (keymap.plus)
  810. {
  811. OSContrastUp();
  812. }
  813. if (keymap.minus)
  814. {
  815. OSContrastDn ();
  816. }
  817. //handleBullets (level->bullets);
  818. gravity ();
  819. if (collision (bob, M_DOWN, (char*)((Plane*)RunningLevel->planes[1])->matrix) || collisionTile())
  820. {
  821. jumping = 0;
  822. if (position == 1 && !_rowread(0)) //put Bob in his default position
  823. {
  824. position = 0;
  825. }
  826. }
  827. if (_keytest(RR_ENTER) && bob->health != 0)
  828. {
  829. bob->health--;
  830. }
  831. int counter = 19;
  832. int bleh;
  833. fishy = bob->coordinates.yLocal+5;
  834. int tilei = 0;
  835. for (;tilei < MOVING_TILE_NUMBER; tilei++)
  836. {
  837. if (moving_tiles[tilei].yGlobal == moving_tiles[tilei].yspawnpoint+moving_tiles[tilei].range && moving_tiles[tilei].sum == 1)
  838. moving_tiles[tilei].sum = -1;
  839. if (moving_tiles[tilei].yGlobal == moving_tiles[tilei].yspawnpoint && moving_tiles[tilei].sum == -1)
  840. moving_tiles[tilei].sum = 1;
  841. moving_tiles[tilei].xLocal+=globs->shiftfgx;
  842. }
  843. tileshiftfgy = globs->shiftfgy;
  844. if (collisionTile())
  845. {
  846. if (bob->coordinates.yLocal > 33 && y_fg+100 < LITERAL_MAP_HEIGHT)
  847. {
  848. y_fg++;
  849. tileshiftfgy--;
  850. globs->shiftfgy--;
  851. }
  852. if (bob->coordinates.yLocal < 35 && bob->coordinates.yGlobal > 33)
  853. {
  854. y_fg--;
  855. tileshiftfgy++;
  856. globs->shiftfgy++;
  857. }
  858. moving_tiles[tile_index].yLocal+=moving_tiles[tile_index].sum+tileshiftfgy;
  859. moving_tiles[tile_index].yGlobal+=moving_tiles[tile_index].sum;
  860. if (!collision (bob, M_DOWN, fg_map) || moving_tiles[tile_index].sum == -1)
  861. {
  862. bob->coordinates.yGlobal=moving_tiles[tile_index].yGlobal-20;
  863. bob->coordinates.yLocal=moving_tiles[tile_index].yLocal-20;
  864. }
  865. }
  866. for (tilei = 0;tilei < MOVING_TILE_NUMBER; tilei++)
  867. {
  868. if (tilei != tile_index)
  869. {
  870. moving_tiles[tilei].yGlobal+=moving_tiles[tilei].sum;
  871. moving_tiles[tilei].yLocal+=moving_tiles[tilei].sum+globs->shiftfgy;
  872. }
  873. }
  874. static int var = 0;
  875. ENEMY *ebackup = *enemyList;
  876. if (*enemyList != NULL)
  877. do
  878. {
  879. OUTERLOOP:
  880. (*enemyList)->type->move(*enemyList);
  881.  
  882. //Move the enemy in the x direction calculated in the previous executed function.
  883. if ((*enemyList)->moveCounter < (*enemyList)->moveSpeed)
  884. {
  885. (*enemyList)->moveCounter++;
  886. }
  887. else// if (counter < enemyCount)
  888. {
  889. (*enemyList)->xLocal+=(*enemyList)->moveDirectionX;
  890. (*enemyList)->xGlobal+=(*enemyList)->moveDirectionX;
  891. (*enemyList)->moveCounter = 0;
  892. }
  893.  
  894. //Move enemies in the y direction. Currently I have not decided if this should be timed or not.
  895. (*enemyList)->yLocal+=(*enemyList)->moveDirectionY;
  896. (*enemyList)->yGlobal+=(*enemyList)->moveDirectionY;
  897.  
  898. //Make sure the enemies' x,y coordinates remain relative to bo. Move the enemies whenever the screen moves.
  899. (*enemyList)->xLocal+=globs->shiftfgx;
  900. (*enemyList)->yLocal+=globs->shiftfgy;
  901.  
  902. //Test collision for enemies
  903. if (!collisionEnemy ((*enemyList)->xGlobal, (*enemyList)->yGlobal, (*enemyList)->type->left_bound, (*enemyList)->type->right_bound, (*enemyList)->type->up_bound, (*enemyList)->type->down_bound, M_DOWN, ((Plane*)RunningLevel->planes[1])->matrix) && !(*enemyList)->jumping)
  904. {
  905. (*enemyList)->yLocal++;
  906. (*enemyList)->yGlobal++;
  907. }
  908.  
  909. //This is both a timer for intervals when to test for enemy collision (to give the player time to move). If there is a collision, take away health.
  910. if (healthcount < healthWait)
  911. {
  912. healthcount++;
  913. }
  914. if (TestCollide162h_R((*enemyList)->xLocal, (*enemyList)->yLocal, bob->coordinates.xLocal, bob->coordinates.yLocal, 16, 20, gfx.enemy_gfx[0], gfx.bob_gfx[0]))
  915. {
  916. if (healthcount >= 10)
  917. {
  918. bob->health -= (*enemyList)->type->damage;
  919. healthcount = 0;
  920. }
  921. }
  922.  
  923. //Move game objects:
  924. GameObject *gobackup = *level->gobjects;
  925. if (*level->gobjects != NULL)
  926. do
  927. {
  928.  
  929. (*level->gobjects)->type->action(*level->gobjects, level);
  930. (*level->gobjects)->type->render(*level->gobjects, level);
  931. *level->gobjects = (*level->gobjects)->next;
  932. }
  933. while (gobackup != *level->gobjects);
  934.  
  935. //test collsion with bullets
  936. BLIST *bbackup = *level->bullets;
  937. if (*level->bullets != NULL)
  938. do
  939. {
  940. if (TestCollide162h_R((*enemyList)->xLocal, (*enemyList)->yLocal,(*level->bullets)->xLocal , (*level->bullets)->yLocal, 16, 6, gfx.enemy_gfx[0], gfx.bullet_gfx[1]))
  941. {
  942. if (*level->bullets == bbackup)
  943. bbackup = (*level->bullets)->next;
  944. if (*enemyList == ebackup)
  945. ebackup = (*enemyList)->next;
  946. ENEMY *b = *enemyList;
  947. deleteEnemyFromLList(enemyList);
  948. free (b);
  949.  
  950. deleteBullet (level->bullets);
  951.  
  952. if (*enemyList == NULL && *level->bullets == NULL)
  953. {
  954. level->bulletTimer = 0;
  955. goto DOUBLE_BREAK;
  956. }
  957.  
  958. if (*enemyList == NULL)
  959. {
  960. *level->bullets = bbackup;
  961. goto DOUBLE_BREAK;
  962. }
  963.  
  964. if (*level->bullets == NULL)
  965. {
  966. level->bulletTimer = 0;
  967. goto OUTERLOOP;
  968. }
  969.  
  970. }
  971. *level->bullets = (*level->bullets)->next;
  972. }
  973. while (*level->bullets != bbackup);
  974.  
  975. *level->bullets = bbackup;
  976.  
  977. if (*enemyList == NULL)
  978. break;
  979.  
  980.  
  981. *enemyList = (*enemyList)->next;
  982. //Prune List of active enemies:m
  983. if ((*enemyList)->xLocal < -100)
  984. {
  985. ENEMY *b = *enemyList;
  986. if (*enemyList == ebackup)
  987. {
  988. ebackup = (*enemyList)->next;
  989. }
  990. deleteEnemyFromLList(enemyList);
  991. pushEnemy(enemyStackLeft,b);
  992. }
  993. else if ((*enemyList)->xLocal > 260)
  994. {
  995. ENEMY *b = *enemyList;
  996. if (*enemyList == ebackup)
  997. {
  998. ebackup = (*enemyList)->next;
  999. }
  1000. deleteEnemyFromLList(enemyList);
  1001. pushEnemy(enemyStackRight,b);
  1002. }
  1003. }
  1004. while ((*enemyList)!= ebackup && *enemyList != NULL);
  1005. DOUBLE_BREAK:
  1006. if (bob->coordinates.xGlobal >= (*enemyStackRight)->xGlobal-110 && (*enemyStackRight != NULL))
  1007. {
  1008. if (*enemyList != NULL)
  1009. *enemyList = (*enemyList)->prev;
  1010. addEnemyToLList (enemyList, popEnemy(enemyStackRight));
  1011. (*enemyList)->xLocal = bob->coordinates.xLocal + ((*enemyList)->xGlobal - bob->coordinates.xGlobal);
  1012. (*enemyList)->yLocal = bob->coordinates.yLocal + ((*enemyList)->yGlobal - bob->coordinates.yGlobal);
  1013. (*enemyList) = (*enemyList)->next;
  1014. (*enemyList)->onscreen = TRUE;
  1015. }
  1016. if (bob->coordinates.xGlobal <= (*enemyStackLeft)->xGlobal+110 && (*enemyStackLeft != NULL))
  1017. {
  1018. if (*enemyList != NULL)
  1019. *enemyList = (*enemyList)->prev;
  1020. addEnemyToLList (enemyList, popEnemy(enemyStackLeft));
  1021. (*enemyList)->xLocal = bob->coordinates.xLocal + ((*enemyList)->xGlobal - bob->coordinates.xGlobal);
  1022. (*enemyList)->yLocal = bob->coordinates.yLocal + ((*enemyList)->yGlobal - bob->coordinates.yGlobal);
  1023. (*enemyList) = (*enemyList)->next;
  1024. (*enemyList)->onscreen = TRUE;
  1025. }
  1026.  
  1027. render(level);
  1028. tileshiftfgy=globs->shiftfgx=globs->shiftfgy=0;
  1029.  
  1030. if (bob->health <= 0)
  1031. {
  1032. renderPicture();
  1033. while(!_keytest(RR_DIAMOND))
  1034. {
  1035. delay(5000);
  1036. }
  1037. }
  1038. }
Add Comment
Please, Sign In to add comment