Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2010
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.76 KB | None | 0 0
  1. // Updates objects
  2. VOID Updater()
  3. {
  4. // Update the shots
  5.  
  6. // Update shots2
  7. else if(iShots==1)
  8. {
  9. for(long index=0; index < (long)shots2.vshots.size(); ++index)
  10. {
  11. shots2.vshots[index].y-=2;
  12. shots2.vshots[index].x-=2;
  13. // Delete shots2
  14. if(shots2.vshots[index].y<-11||shots2.vshots[index].x<-11)
  15. {
  16. shots2.vshots.erase(shots2.vshots.begin()+index);
  17. }
  18. }
  19. for(long index=0; index < (long)shots2.v2shots.size(); ++index)
  20. {
  21. shots2.v2shots[index].y-=2;
  22. shots2.v2shots[index].x+=2;
  23. // Delete shots2
  24. if(shots2.v2shots[index].y<-11||shots2.v2shots[index].x>236)
  25. {
  26. shots2.v2shots.erase(shots2.v2shots.begin()+index);
  27. }
  28. }
  29. }
  30.  
  31. // Update bounce
  32. if(bounce.aBounce==0)
  33. {
  34. if(bounce.vBounce[0].x<250)
  35. {
  36. bounce.vBounce[0].x+=2;
  37. bounce.vBounce[0].y+=2;
  38. }
  39. else{ bounce.aBounce=1; }
  40. }
  41.  
  42. // Update New shots
  43. if(newshot.aNshots==0)
  44. {
  45. if(newshot.vNshots[0].x<250)
  46. {
  47. newshot.vNshots[0].x+=2;
  48. newshot.vNshots[0].y+=2;
  49. }
  50. else{ newshot.aNshots=1; }
  51. }
  52.  
  53. // Update enemies
  54. // Enemy1
  55. if(Enemy1.aEnemy==0)
  56. {
  57. for(long index=0; index < (long)Enemy1.vS1Enemy.size(); index++)
  58. {
  59. Enemy1.vS1Enemy[index].x+=2;
  60. Enemy1.vS1Enemy[index].y+=2;
  61. if(Enemy1.vS1Enemy[index].x>225)
  62. {
  63. Enemy1.vS1Enemy.erase(Enemy1.vS1Enemy.begin()+index);
  64. }
  65. }
  66. for(long index=0; index < (long)Enemy1.vS2Enemy.size(); index++)
  67. {
  68. Enemy1.vS2Enemy[index].x-=2;
  69. Enemy1.vS2Enemy[index].y+=2;
  70. if(Enemy1.vS2Enemy[index].x<-21)
  71. {
  72. Enemy1.vS2Enemy.erase(Enemy1.vS2Enemy.begin()+index);
  73. }
  74. }
  75. }
  76. // Enemy2
  77. for(long index=0; index < (long)Enemy2.vS1Enemy.size(); index++)
  78. {
  79. Enemy2.vS1Enemy[index].y+=2;
  80. if(Enemy2.vS1Enemy[index].y>325)
  81. {
  82. Enemy2.vS1Enemy.erase(Enemy2.vS1Enemy.begin()+index);
  83. }
  84. }
  85. for(long index=0; index < (long)Enemy2.vS2Enemy.size(); index++)
  86. {
  87. Enemy2.vS2Enemy[index].y+=2;
  88. if(Enemy2.vS2Enemy[index].y>325)
  89. {
  90. Enemy2.vS2Enemy.erase(Enemy2.vS2Enemy.begin()+index);
  91. }
  92. }
  93. }
  94.  
  95. /////////////////////////////////////
  96. case WM_PAINT:
  97. hdc = BeginPaint(hWnd, &ps);
  98. Paint(hdc, hWnd);
  99. EndPaint(hWnd, &ps);
  100. break;
  101. case WM_LBUTTONDOWN:
  102. GetCursorPos(&pt);
  103. ScreenToClient(hWnd, &pt);
  104. if(conno==1)
  105. {
  106. if(cursor==0)
  107. {
  108. conno++;
  109. }
  110. else if(cursor==1)
  111. {
  112. pt.x+=2;
  113. conno++;
  114. }
  115. if(iShots==1)
  116. {
  117. shots2.vshots.push_back(pt);
  118. }
  119. }
  120. else
  121. {
  122. if(cursor==0)
  123. {
  124. pt.x+=18;
  125. }
  126. else if(cursor==1)
  127. {
  128. pt.x+=15;
  129. }
  130. conno--;
  131. if(iShots==1)
  132. {
  133. shots2.v2shots.push_back(pt);
  134. }
  135. }
  136. if(iShots==0)
  137. {
  138. RegularShots.vshots.push_back(pt);
  139. }
  140. SetTimer(hWnd, LBUTTONDOWN_ID, 350, NULL);
  141. InvalidateRect(hWnd, rect, false);
  142. break;
  143. case WM_LBUTTONUP:
  144. KillTimer(hWnd, LBUTTONDOWN_ID);
  145. break;
  146. case WM_KEYDOWN:
  147. SetTimer(hWnd, EVERYTHING_ID, 1, NULL);
  148. break;
  149. case WM_TIMER:
  150. switch(wParam)
  151. {
  152. case EVERYTHING_ID:
  153. if(Enemy1.e1==true)
  154. {
  155. Enemy1.now=time(NULL);
  156. Enemy1.tEnemy=Enemy1.now+1;
  157. Enemy1.e1=false;
  158. }
  159. Enemy1.now=time(NULL);
  160. if(Enemy1.now==Enemy1.tEnemy)
  161. {
  162. SetTimer(hWnd, TAENEMIE1_ID, 30, NULL);
  163. InvalidateRect(hWnd, rect, false);
  164. }
  165. break;
  166. case LBUTTONDOWN_ID:
  167. GetCursorPos(&pt);
  168. ScreenToClient(hWnd, &pt);
  169. if(conno==1)
  170. {
  171. if(cursor==0)
  172. {
  173. conno++;
  174. }
  175. else if(cursor==1)
  176. {
  177. pt.x+=2;
  178. conno++;
  179. }
  180. if(iShots==1)
  181. {
  182. shots2.vshots.push_back(pt);
  183. }
  184. }
  185. else
  186. {
  187. if(cursor==0)
  188. {
  189. pt.x+=18;
  190. }
  191. else if(cursor==1)
  192. {
  193. pt.x+=15;
  194. }
  195. conno--;
  196. if(iShots==1)
  197. {
  198. shots2.v2shots.push_back(pt);
  199. }
  200. }
  201. if(iShots==0)
  202. {
  203. RegularShots.vshots.push_back(pt);
  204. }
  205. break;
  206. case TAENEMIE1_ID:
  207. KillTimer(hWnd, EVERYTHING_ID);
  208. Timer();
  209. Updater();
  210. CreateEnemies(pt2, x, y, x2, y2);
  211.  
  212. if(pHits!=550)
  213. {
  214. pHits+=50;
  215. }
  216.  
  217. // if regular cursor
  218. GetCursorPos(&pt);
  219. ScreenToClient(hWnd, &pt);
  220. if(cursor==0)
  221. {
  222. // player hits
  223. if(pHits==550)
  224. {
  225. // Bounce
  226. if(bounce.aBounce==0)
  227. {
  228. if(.......)
  229. bounce.vBounce.erase(bounce.vBounce.begin());
  230. score+=1000;
  231. bounce.aBounce=1;
  232. pHits=0;
  233. break;
  234. }
  235. }
  236. // New shots
  237. if(newshot.aNshots==0)
  238. {
  239. if(......)
  240. {
  241. newshot.vNshots.erase(newshot.vNshots.begin());
  242. iShots++;
  243. newshot.aNshots=1;
  244. pHits=0;
  245. break;
  246. }
  247. }
  248. // Enemy1
  249. for(long index=0; index < (long)Enemy1.vS1Enemy.size(); index++)
  250. {
  251. if(....)
  252. {
  253. Enemy1.vS1Enemy[index].y=326;
  254. health+=30;
  255. pHits=0;
  256. break;
  257. }
  258. }
  259. for(long index=0; index < (long)Enemy1.vS2Enemy.size(); index++)
  260. {
  261. if(....)
  262. {
  263. Enemy1.vS2Enemy[index].y=326;
  264. health+=30;
  265. pHits=0;
  266. break;
  267. }
  268. }
  269. // Enemy2
  270. for(long index=0; index < (long)Enemy2.vS1Enemy.size(); index++)
  271. {
  272. if(....)
  273. {
  274. Enemy2.vS1Enemy[index].y=326;
  275. health+=30;
  276. pHits=0;
  277. break;
  278. }
  279. }
  280. for(long index=0; index < (long)Enemy2.vS2Enemy.size(); index++)
  281. {
  282. if(.....)
  283. {
  284. Enemy2.vS2Enemy[index].y=326;
  285. health+=30;
  286. pHits=0;
  287. break;
  288. }
  289. }
  290. }
  291. }
  292. ..........
  293.  
  294. // Hits
  295. ........
  296. else if(iShots==1)
  297. {
  298. // Enemy1
  299. // shots side one
  300. for(long index=0; index < (long)shots2.vshots.size(); index++)
  301. {
  302. for(long indexs=0; indexs < (long)Enemy1.vS1Enemy.size(); indexs++)
  303. {
  304. if(.....)
  305. {
  306. Enemy1.vS1Enemy[indexs].x=226;
  307. shots2.vshots[index].y=-17;
  308. score+=100;
  309. break;
  310. }
  311. }
  312. for(long indexs=0; indexs < (long)Enemy1.vS2Enemy.size(); indexs++)
  313. {
  314. if(.....)
  315. {
  316. Enemy1.vS2Enemy[indexs].x=-25;
  317. shots2.vshots[index].y=-17;
  318. score+=100;
  319. break;
  320. }
  321. }
  322. }
  323. // shots side two
  324. for(long index=0; index < (long)shots2.v2shots.size(); index++)
  325. {
  326. for(long indexs=0; indexs < (long)Enemy1.vS1Enemy.size(); indexs++)
  327. {
  328. if(......)
  329. {
  330. Enemy1.vS1Enemy[indexs].x=226;
  331. shots2.v2shots[index].y=-17;
  332. score+=100;
  333. break;
  334. }
  335. }
  336. for(long indexs=0; indexs < (long)Enemy1.vS2Enemy.size(); indexs++)
  337. {
  338. if(.....)
  339. {
  340. Enemy1.vS2Enemy[indexs].x=-25;
  341. shots2.v2shots[index].y=-17;
  342. score+=100;
  343. break;
  344. }
  345. }
  346. }
  347.  
  348. // Enemy2
  349. if(Enemy2.aEnemy==0)
  350. {
  351. // shots side one
  352. for(long index=0; index < (long)shots2.vshots.size(); index++)
  353. {
  354. for(long indexs=0; indexs < (long)Enemy2.vS1Enemy.size(); indexs++)
  355. {
  356. if(.....)
  357. {
  358. Enemy2.vS1Enemy[indexs].y=326;
  359. shots2.vshots[index].y=-17;
  360. score+=100;
  361. break;
  362. }
  363. }
  364. for(long indexs=0; indexs < (long)Enemy2.vS2Enemy.size(); indexs++)
  365. {
  366. if(....)
  367. {
  368. Enemy2.vS2Enemy[indexs].y=326;
  369. shots2.vshots[index].y=-17;
  370. score+=100;
  371. break;
  372. }
  373. }
  374. }
  375. // shots side two
  376. for(long index=0; index < (long)shots2.v2shots.size(); index++)
  377. {
  378. for(long indexs=0; indexs < (long)Enemy2.vS1Enemy.size(); indexs++)
  379. {
  380. if(.....)
  381. {
  382. Enemy2.vS1Enemy[indexs].y=326;
  383. shots2.v2shots[index].y=-17;
  384. score+=100;
  385. break;
  386. }
  387. }
  388. for(long indexs=0; indexs < (long)Enemy2.vS2Enemy.size(); indexs++)
  389. {
  390. if(.....)
  391. {
  392. Enemy2.vS2Enemy[indexs].y=326;
  393. shots2.v2shots[index].y=-17;
  394. score+=100;
  395. break;
  396. }
  397. }
  398. }
  399. }
  400. }
  401.  
  402. if(Enemy1.vS1Enemy.size()==0&&Enemy1.vS2Enemy.size()==0&&Enemy2.cEnemy==0)
  403. {
  404. Enemy2.cEnemy=1;
  405. Enemy2.dEnemy=true;
  406. }
  407.  
  408. if(health>225)
  409. {
  410. cursor=1;
  411. SetTimer(hWnd, PROTECTED_ID, 1000, NULL);
  412. life--;
  413. health=0;
  414. }
  415.  
  416. InvalidateRect(hWnd, rect, false);
  417. break;
  418. case PROTECTED_ID:
  419. protect++;
  420. break;
  421. }
  422. break;
  423. case WM_SETCURSOR:
  424. SetCursor(hCursor[cursor]);
  425. return 0;
  426. break;
  427. case WM_DESTROY:
  428. PostQuitMessage(0);
  429. break;
  430. default:
  431. return DefWindowProc(hWnd, message, wParam, lParam);
  432. }
  433. return 0;
  434. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement