game.bmx 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771
  1. Strict
  2. '
  3. ' Game Demo Coded By David Bird (Birdie)
  4. '
  5. Incbin "media/sand.png"
  6. Incbin "media/ship1.png"
  7. Incbin "media/cloud.png"
  8. Incbin "media/shot.png"
  9. Incbin "media/shot2.PNG"
  10. Incbin "media/mud.png"
  11. Incbin "media/smoke.png"
  12. Incbin "media/scan.png"
  13. Incbin "media/zombie_0.png"
  14. Incbin "media/zombie_1.png"
  15. Incbin "media/zombie_2.PNG"
  16. Incbin "media/zombie_3.PNG"
  17. Incbin "media/zombie_4.PNG"
  18. Incbin "media/zombie_5.PNG"
  19. Incbin "media/zombie_6.png"
  20. Incbin "media/zombie_7.PNG"
  21. Incbin "media/Title.png"
  22. Incbin "media/HitSpace.png"
  23. Global C_ScreenWidth# = 640, C_ScreenHeight# = 480
  24. Global C_ScreenMidX# =C_ScreenWidth/2
  25. Global C_ScreenMidY# =C_ScreenHeight/2
  26. Global MapPosition_X#=400, MapPosition_Y#=400
  27. Global WorldSize = 8192
  28. Global Scanner_Rot#
  29. Global Scanner_X#= C_ScreenWidth - 80
  30. Global Scanner_Y#= 80
  31. Global Scanner_Scale# = 0.5
  32. Global ObjectList:TList = New TList
  33. Global DetailList:TList = New TList
  34. Global CloudList:TList = New TList
  35. Global ScanList:TList = New TList
  36. Global TitleWidth#,TitleHeight#
  37. Graphics C_ScreenWidth, C_ScreenHeight ,32
  38. HideMouse
  39. AutoImageFlags MASKEDIMAGE|FILTEREDIMAGE|MIPMAPPEDIMAGE
  40. 'media globals
  41. Global media_sand:TImage
  42. Global media_ship1:TImage
  43. Global media_cloud:TImage
  44. Global media_shots:TImage
  45. Global media_shot2:TImage
  46. Global media_mud:TImage
  47. Global media_smoke:TImage
  48. Global Media_scan:TImage
  49. Global media_Title:TImage
  50. Global media_HitSP:TImage
  51. Global Media_zombie:TImage[8]
  52. LoadMedia()
  53. Local P1:Player = New Player
  54. ObjectList.AddLast p1
  55. 'title screen
  56. While Not KeyDown(KEY_SPACE)
  57. Cls
  58. SetBlend SOLIDBLEND
  59. SetColor 255,255,255
  60. TileImage Media_sand,MapPosition_X,MapPosition_Y
  61. MapPosition_X:+1
  62. SetRotation 0
  63. SetBlend ALPHABLEND
  64. SetColor 255,255,255
  65. SetAlpha 1
  66. SetScale TitleWidth,TitleHeight
  67. DrawImage Media_Title,C_ScreenMidX,C_ScreenMidY-24
  68. SetScale 1,1
  69. SetAlpha 0.5
  70. DrawImage media_HitSP, C_ScreenMidX, C_ScreenHeight - media_HitSP.height
  71. Flip
  72. Wend
  73. Local a
  74. For a=0 Until 100
  75. cloud.Create( Rnd(-WorldSize,WorldSize), Rnd(-WorldSize,WorldSize) )
  76. Next
  77. For a=0 Until 250
  78. Baddie.Create(Rnd(-1000,1000), Rnd(-1000,1000), 0)
  79. Next
  80. While Not KeyDown(KEY_ESCAPE)
  81. Cls
  82. UpdateObjects()
  83. DrawLevel(p1)
  84. DrawObjects()
  85. DrawScanner( P1 )
  86. Flip
  87. Wend
  88. End
  89. Function LoadMedia()
  90. SetHandle 0.5,0.5
  91. AutoMidHandle True
  92. media_sand = LoadImage("incbin::media/sand.png")
  93. media_ship1 = LoadImage("incbin::media/ship1.png")
  94. media_cloud = LoadImage("incbin::media/cloud.png")
  95. media_shots = LoadImage("incbin::media/shot.png")
  96. media_shot2 = LoadImage("incbin::media/shot2.PNG")
  97. media_scan = LoadImage("incbin::media/scan.png")
  98. media_mud = LoadImage("incbin::media/mud.png")
  99. media_smoke = LoadImage("incbin::media/smoke.png")
  100. media_Title = LoadImage("incbin::media/Title.png")
  101. media_HitSP = LoadImage("incbin::media/HitSpace.png")
  102. 'scale to fullscreen
  103. TitleWidth = media_title.width / C_ScreenWidth
  104. TitleHeight= media_title.height / (C_ScreenHeight+48)
  105. Media_zombie[0] = LoadAnimImage("incbin::media/zombie_0.png",32,64,0,17)
  106. Media_zombie[1] = LoadAnimImage("incbin::media/zombie_1.png",32,64,0,17)
  107. Media_zombie[2] = LoadAnimImage("incbin::media/zombie_2.PNG",32,64,0,17)
  108. Media_zombie[3] = LoadAnimImage("incbin::media/zombie_3.PNG",32,64,0,17)
  109. Media_zombie[4] = LoadAnimImage("incbin::media/zombie_4.PNG",32,64,0,17)
  110. Media_zombie[5] = LoadAnimImage("incbin::media/zombie_5.PNG",32,64,0,17)
  111. Media_zombie[6] = LoadAnimImage("incbin::media/zombie_6.png",32,64,0,17)
  112. Media_zombie[7] = LoadAnimImage("incbin::media/zombie_7.PNG",32,64,0,17)
  113. EndFunction
  114. Function DrawLevel(o:Entity)
  115. 'using the object{o} position and direction to draw the map
  116. ' MapPosition_X = MapPosition_X + ((o.x - MapPosition_X)*0.25)
  117. ' MapPosition_Y = MapPosition_Y + ((o.y - MapPosition_Y)*0.25)
  118. MapPosition_X = o.x
  119. MapPosition_Y = o.y
  120. SetBlend SOLIDBLEND
  121. SetColor 255,255,255
  122. SetScale 1,1
  123. TileImage Media_sand,MapPosition_X,MapPosition_Y
  124. EndFunction
  125. Function UpdateObjects()
  126. Local e:Entity
  127. For e=EachIn ObjectList
  128. e.Update()
  129. Next
  130. EndFunction
  131. Function DrawObjects()
  132. Local e:Entity
  133. Local c:Cloud
  134. For c=EachIn CloudList
  135. c.Update()
  136. Next
  137. 'Draw Shadows
  138. For e=EachIn ObjectList
  139. e.DrawShadow()
  140. Next
  141. 'Draw Details
  142. Local d:Detail
  143. For d=EachIn DetailList
  144. d.Update(MapPosition_X, MapPosition_Y)
  145. Next
  146. 'Draw objects without shadows
  147. For e=EachIn ObjectList
  148. e.DrawBody()
  149. Next
  150. 'DrawClouds
  151. For c=EachIn CloudList
  152. c.DrawShadow()
  153. Next
  154. For c=EachIn CloudList
  155. c.DrawBody()
  156. Next
  157. EndFunction
  158. Type Entity
  159. Field x#,y#
  160. Field height#
  161. Field rotation#
  162. Field spd#=1
  163. Method Update() Abstract
  164. Method DrawBody() Abstract
  165. Method DrawShadow() Abstract
  166. EndType
  167. Type Player Extends Entity
  168. Field RotationSpd#
  169. Field liftSpd#
  170. Field thrust#
  171. Field osc#
  172. Method Update()
  173. If KeyDown(KEY_UP)
  174. thrust:+0.01
  175. If thrust>0.5
  176. thrust = 0.5
  177. EndIf
  178. EndIf
  179. If KeyDown(KEY_DOWN)
  180. thrust:-0.05
  181. EndIf
  182. spd:+thrust
  183. If thrust<0
  184. thrust = 0
  185. EndIf
  186. If spd>8
  187. spd=8
  188. EndIf
  189. If spd<0.5 spd = 0.5
  190. If KeyHit(KEY_SPACE)
  191. Local a,thei#
  192. thei = height +(3.5*Cos(osc) )
  193. Shots.Create x, y, spd+5, thei, rotation
  194. For a=0 Until 3
  195. Shots.Create x, y, spd+5, thei, rotation+Rnd(-1.75,1.75)
  196. Next
  197. EndIf
  198. Local sz#=14*(1+(height/140.0))
  199. Local sd#=16
  200. Local cs#= Cos(rotation-90)
  201. Local sn#= Sin(rotation-90)
  202. Local ddx# = sz
  203. Local ddy# = 9
  204. Local tx1# = ddx*cs + ddy*sn
  205. Local ty1# = ddx*sn - ddy*cs
  206. ddx=-ddx
  207. Local tx2# = ddx*cs + ddy*sn
  208. Local ty2# = ddx*sn - ddy*cs
  209. Local thei#
  210. thei = height +(3.5*Cos(osc) )
  211. Local deltasm#= ( 0.5 * (spd/8.0))
  212. Trail.Create( x+tx1, y+ty1, thei, deltasm, rotation )
  213. Trail.Create( x+tx2, y+ty2, thei, deltasm, rotation )
  214. Local tx#= 20 * Cos(rotation)
  215. Local ty#= 20 * Sin(rotation)
  216. Local rd= 255*thrust*2
  217. Local gn= rd*0.7
  218. Local bl= gn*0.5
  219. ColTrail.Create( x-tx, y-ty, thei, 0.3, rotation, [rd, gn, bl] ,2.0)
  220. ColTrail.Create( x-tx, y-ty, thei, 0.3, rotation, [rd*2, 0, 0] ,1.0)
  221. If KeyDown(KEY_RIGHT)
  222. rotationSpd:+0.25
  223. If rotationSpd>2
  224. rotationSpd=2
  225. EndIf
  226. EndIf
  227. If KeyDown(KEY_LEFT)
  228. rotationSpd:-0.25
  229. If rotationSpd<-2
  230. rotationSpd=-2
  231. EndIf
  232. EndIf
  233. rotation:+rotationSpd
  234. rotationSpd:*0.95
  235. If KeyDown(KEY_A)
  236. liftSpd:-0.02
  237. If liftSpd<-1
  238. liftSpd=-1
  239. EndIf
  240. EndIf
  241. If KeyDown(KEY_Z)
  242. liftSpd:+0.02
  243. If liftSpd>1
  244. liftSpd=1
  245. EndIf
  246. EndIf
  247. height:+liftSpd
  248. liftspd:*0.985
  249. If height<4
  250. height = 4
  251. liftspd = 0
  252. EndIf
  253. If height>50
  254. height = 50
  255. liftspd=0
  256. EndIf
  257. x=x+(spd*Cos(rotation))
  258. y=y+(spd*Sin(rotation))
  259. If x>WorldSize x=-WorldSize
  260. If x<-WorldSize x=WorldSize
  261. If y>WorldSize y=-WorldSize
  262. If y<-WorldSize y=WorldSize
  263. osc:+1
  264. EndMethod
  265. Method DrawShadow()
  266. Local dx#,dy#,sz#,thei#
  267. thei = height +(3.5*Cos(osc) )
  268. sz =(0.002*thei)
  269. SetRotation rotation+90
  270. SetBlend ALPHABLEND
  271. SetScale 0.25+sz,0.25+sz
  272. SetColor 0,0,0
  273. SetAlpha 0.5
  274. DrawImage media_ship1,C_ScreenMidX + (x-MapPosition_X), C_ScreenMidY + ( y - MapPosition_Y )
  275. EndMethod
  276. Method DrawBody()
  277. Local dx#,dy#,sz#,thei#
  278. thei = height +(3.5*Cos(osc) )
  279. sz =(0.002*thei)
  280. SetAlpha 1
  281. SetRotation rotation+90
  282. SetBlend MASKBLEND
  283. SetColor 255,255,255
  284. dx=thei/3.0
  285. dy=thei
  286. SetScale 0.25+sz, 0.25+sz
  287. DrawImage media_ship1,(x-MapPosition_X+dx) + C_ScreenMidX,(y-MapPosition_Y+dy) + C_ScreenMidY
  288. EndMethod
  289. Function Create:Player(x#,y#)
  290. Local p:Player = New Player
  291. p.x=x
  292. p.y=y
  293. p.height = 4
  294. p.spd=1
  295. ObjectList.AddFirst p
  296. Return p
  297. EndFunction
  298. EndType
  299. Type Cloud
  300. Field x#,y#,height#, rotation
  301. Method Update()
  302. x:+1
  303. y:+0.1
  304. If x>WorldSize x=-WorldSize
  305. If x<-WorldSize x=WorldSize
  306. If y>WorldSize y=-WorldSize
  307. If y<-WorldSize y=WorldSize
  308. EndMethod
  309. Method DrawBody()
  310. Local dx#,dy#
  311. dx=height/2.0
  312. dy=height
  313. SetBlend LIGHTBLEND
  314. SetAlpha 1
  315. SetScale 2.4,2.4
  316. SetRotation rotation
  317. SetColor 255,255,255
  318. DrawImage media_cloud,(MapPosition_X+dx-x) + C_ScreenMidX,(MapPosition_Y+dy-y) + C_ScreenMidY
  319. EndMethod
  320. Method DrawShadow()
  321. SetBlend ALPHABLEND
  322. SetColor 0,0,0
  323. SetAlpha 0.2
  324. SetScale 4, 4
  325. SetRotation rotation
  326. DrawImage media_cloud,(MapPosition_X-x) + C_ScreenMidX,(MapPosition_Y-y) + C_ScreenMidY
  327. EndMethod
  328. Function Create:Cloud( x#, y# )
  329. Local c:Cloud = New Cloud
  330. c.x= x
  331. c.y= y
  332. c.rotation = Rnd(360)
  333. c.height = 75
  334. CloudList.AddLast c
  335. Return c
  336. EndFunction
  337. EndType
  338. Type Shots Extends Entity
  339. Field life
  340. Method DrawBody()
  341. Local dx#,dy#
  342. dx=height/3.0
  343. dy=height
  344. SetBlend MASKBLEND
  345. SetColor 255,255,255
  346. SetAlpha 1
  347. SetScale 1, 1
  348. SetRotation rotation + 90
  349. DrawImage media_shots,(MapPosition_X+dx-x) + C_ScreenMidX,(MapPosition_Y+dy-y) + C_ScreenMidY
  350. EndMethod
  351. Method DrawShadow()
  352. SetBlend ALPHABLEND
  353. SetColor 0,0,0
  354. SetAlpha 0.2
  355. SetScale 1, 1
  356. SetRotation rotation + 90
  357. DrawImage media_shots,(MapPosition_X-x) + C_ScreenMidX,(MapPosition_Y-y) + C_ScreenMidY
  358. EndMethod
  359. Method Update()
  360. x=x+(spd*Cos(rotation))
  361. y=y+(spd*Sin(rotation))
  362. If x>WorldSize x=-WorldSize
  363. If x<-WorldSize x=WorldSize
  364. If y>WorldSize y=-WorldSize
  365. If y<-WorldSize y=WorldSize
  366. If life<80
  367. height:-0.75
  368. EndIf
  369. Trail.Create( x, y, height, 0.3, rotation )
  370. If height<0
  371. ObjectList.Remove Self
  372. Mud.Create(x, y, rotation)
  373. Local ee#
  374. ee=1
  375. SmokeEmitter.create( x#,y#, 0,ee, ee, ee )
  376. Else
  377. life:-1
  378. If life<0
  379. ObjectList.Remove Self
  380. EndIf
  381. EndIf
  382. EndMethod
  383. Function Create:Shots(x#,y#,spd#,hei#,rot#)
  384. Local s:Shots = New Shots
  385. s.x=x
  386. s.y=y
  387. s.rotation = rot
  388. s.spd = spd
  389. s.height = hei
  390. s.life = 100
  391. ObjectList.AddFirst s
  392. Return s
  393. EndFunction
  394. EndType
  395. Type Detail
  396. Field life
  397. Field x#,y#,rot#,alp#
  398. Field col[3]
  399. Method Update( wx#, wy# ) Abstract
  400. EndType
  401. Type Trail Extends Detail
  402. Field height#
  403. Field size#
  404. Method Update( wx#, wy# )
  405. Local dx#, dy#
  406. alp:-0.005
  407. If alp<0
  408. life = 0
  409. EndIf
  410. life:-1
  411. If life<0
  412. DetailList.Remove Self
  413. Else
  414. dx=height/3.0
  415. dy=height
  416. SetAlpha alp
  417. SetBlend alphablend
  418. SetRotation rot
  419. SetColor 255,255,255
  420. size:+0.05
  421. SetScale 1,size
  422. DrawRect (wx-x+dx)+C_ScreenMidX,(wy-y+dy)+C_ScreenMidY,10,1
  423. EndIf
  424. EndMethod
  425. Function Create:Trail(x#,y#,hei#,alp#,rot#)
  426. Local t:Trail = New Trail
  427. t.x=x
  428. t.y=y
  429. t.height= hei
  430. t.alp = alp
  431. t.rot = rot
  432. t.life= 100
  433. t.size= 1
  434. DetailList.AddLast t
  435. EndFunction
  436. EndType
  437. Type ColTrail Extends Detail
  438. Field height#,size#
  439. Method Update( wx#, wy# )
  440. Local dx#, dy#
  441. alp:-0.01
  442. size:*0.9
  443. If alp<0
  444. life = 0
  445. EndIf
  446. life:-1
  447. If life<0
  448. DetailList.Remove Self
  449. Else
  450. dx=height/3.0
  451. dy=height
  452. SetAlpha alp
  453. SetBlend LIGHTBLEND
  454. SetRotation rot
  455. SetColor Col[0],Col[1],Col[2]
  456. SetScale size,size
  457. DrawRect (wx-x+dx)+C_ScreenMidX,(wy-y+dy)+C_ScreenMidY,10,4
  458. EndIf
  459. EndMethod
  460. Function Create:ColTrail(x#,y#,hei#,alp#,rot#,col[],size#)
  461. Local t:ColTrail = New ColTrail
  462. t.x=x
  463. t.y=y
  464. t.height= hei
  465. t.alp = alp
  466. t.rot = rot
  467. t.life= 100
  468. t.size=size
  469. t.col = col
  470. DetailList.AddLast t
  471. EndFunction
  472. EndType
  473. Type Mud Extends Detail
  474. Method Update( wx#, wy# )
  475. SetRotation rot
  476. SetBlend ALPHABLEND
  477. If life<50
  478. alp = Float(life)/100.0
  479. EndIf
  480. SetAlpha alp
  481. SetColor 0,0,0
  482. SetScale 0.5,0.5
  483. DrawImage media_mud,(wx-x)+C_ScreenMidX,(wy-y)+C_ScreenMidY
  484. life:-1
  485. If life<0
  486. DetailList.Remove Self
  487. EndIf
  488. EndMethod
  489. Function Create:Mud(x#,y#, rot#)
  490. Local m:Mud = New Mud
  491. m.x = x
  492. m.y = y
  493. m.rot = rot
  494. m.alp = 0.5
  495. m.life = 200
  496. DetailList.AddLast M
  497. EndFunction
  498. EndType
  499. Type smoke_prt
  500. Field x#,y#,height# 'local to emitter
  501. Field scl#
  502. Field alp#
  503. Field dx#,dy#
  504. Field life
  505. Field rot#, rotdir#
  506. Method Draw( tx#, ty# )
  507. y:-dy
  508. x:+dx
  509. life:-1
  510. alp:-0.005
  511. scl:+0.017
  512. If alp<=0
  513. life =0
  514. Return
  515. EndIf
  516. SetBlend LightBlend
  517. SetAlpha alp
  518. SetScale scl,scl
  519. SetRotation rot
  520. rot:+rotdir
  521. DrawImage media_smoke, tx+x, ty+y
  522. EndMethod
  523. Function Create:smoke_prt(scl#,alp#,x#,y#,dx#,dy#,life)
  524. Local s:Smoke_prt = New Smoke_prt
  525. s.x=x
  526. s.y=y
  527. s.dx=dx
  528. s.dy=dy
  529. s.life=life
  530. s.alp=alp
  531. s.scl=scl
  532. s.rotdir = Rnd(-4,4)
  533. s.rot = Rnd(360)
  534. Return s
  535. EndFunction
  536. EndType
  537. Type SmokeEmitter Extends Detail
  538. Field smlist:TList = New TList
  539. Field rd#,gn#,bl#, max_cnt=50, cur_cnt
  540. Method Update( wx#, wy# )
  541. Local sp:smoke_prt
  542. SetColor 255*rd,255*gn,255*bl
  543. For sp=EachIn smlist
  544. sp.Draw((wx-x)+C_ScreenMidX, (wy-y)+C_ScreenMidY)
  545. If sp.life<0
  546. 'remove it and add another
  547. smlist.remove sp
  548. cur_cnt:-1
  549. EndIf
  550. Next
  551. If cur_cnt<max_cnt
  552. smlist.addfirst( smoke_prt.Create( 0.2, 0.3, 0, 0, Rnd( -0.1, 0.1 ), Rnd(0.1,1), 40 ) )
  553. cur_cnt:+1
  554. EndIf
  555. life:-1
  556. If life<0
  557. DetailList.Remove Self
  558. smlist.clear()
  559. EndIf
  560. EndMethod
  561. Function Create:SmokeEmitter(x#,y#, rot#,cr#,cg#,cb#)
  562. Local sm:SmokeEmitter = New SmokeEmitter
  563. sm.x = x
  564. sm.y = y
  565. sm.rot = rot
  566. sm.alp = 0.20
  567. sm.life = 50
  568. sm.rd=cr
  569. sm.gn=cg
  570. sm.bl=cb
  571. DetailList.AddLast sm
  572. EndFunction
  573. EndType
  574. Type Baddie Extends Entity
  575. Field frame = 0
  576. Field frm_p = 2
  577. Field frm_t = 0
  578. Field direct= 0
  579. Field life
  580. Method Update()
  581. frm_t:+1
  582. If frm_t>frm_p
  583. frm_t= 0
  584. frame:+1
  585. If frame = 17 frame = 0
  586. EndIf
  587. x=x+(spd*Cos(rotation-90))
  588. y=y+(spd*Sin(rotation-90))
  589. If x>WorldSize x=-WorldSize
  590. If x<-WorldSize x=WorldSize
  591. If y>WorldSize y=-WorldSize
  592. If y<-WorldSize y=WorldSize
  593. spd=0.3
  594. rotation:+1
  595. If rotation<0 rotation:+360
  596. If rotation>=360 rotation:-360
  597. direct = rotation / 45
  598. EndMethod
  599. Method DrawShadow()
  600. Local dx = -12
  601. Local dy = -4
  602. SetBlend alphaBlend
  603. SetColor 0,0,0
  604. SetAlpha 0.3
  605. SetRotation -30
  606. SetScale 0.43,0.47
  607. DrawImage Media_zombie[direct],(MapPosition_X-x) + C_ScreenMidX+dx,(MapPosition_Y-y) + C_ScreenMidY+dy, frame
  608. EndMethod
  609. Method DrawBody()
  610. SetBlend alphaBlend
  611. SetColor 255,255,255
  612. SetAlpha 1
  613. SetRotation 0
  614. SetScale 0.4,0.4
  615. DrawImage Media_zombie[direct],(MapPosition_X-x) + C_ScreenMidX,(MapPosition_Y-y) + C_ScreenMidY, frame
  616. EndMethod
  617. Function Create:Baddie(x#,y#,spd#)
  618. Local s:Baddie = New Baddie
  619. s.x=x
  620. s.y=y
  621. s.rotation = Rand(350)
  622. s.spd = Rnd(1,2)
  623. s.height = 0
  624. s.life = 100
  625. ObjectList.AddFirst s
  626. Return s
  627. EndFunction
  628. EndType
  629. Type Scan_Object
  630. Field alp#,x#,y#,typ
  631. Method Update(cx#, cy#)
  632. alp:-0.01
  633. If alp<0
  634. ScanList.Remove Self
  635. Else
  636. SetAlpha alp
  637. DrawRect cx+x,cy+y,5,5
  638. EndIf
  639. EndMethod
  640. Function Create:Scan_Object(x#, y#, typ )
  641. Local so:Scan_Object = New Scan_Object
  642. so.x=x
  643. so.y=y
  644. so.typ=typ
  645. so.alp=0.4
  646. ScanList.AddLast so
  647. EndFunction
  648. EndType
  649. Function DrawScanner(p:Player) 'according to a certain player
  650. SetBlend LightBlend
  651. SetColor 255,255,255
  652. SetAlpha 0.5
  653. SetRotation Scanner_Rot+90
  654. Scanner_rot:-5
  655. If scanner_rot<0 scanner_rot:+360
  656. SetScale Scanner_Scale,Scanner_Scale
  657. DrawImage media_scan,Scanner_X,Scanner_Y
  658. Local b:Baddie
  659. Local so:Scan_Object
  660. Local dx#,dy#,ang#,ln#
  661. For b=EachIn ObjectList
  662. 'get angle to object
  663. dx=p.x-b.x
  664. dy=p.y-b.y
  665. ln=Sqr(dx*dx+dy*dy)
  666. If ln<1200
  667. ang = ATan2(dx,dy)
  668. If ang<0 ang=360+ang
  669. If Abs(ang-(Scanner_rot))<2
  670. 'add a new dot on the scanner
  671. Scan_Object.Create(dx/20.0, dy/20.0, 0 )
  672. EndIf
  673. EndIf
  674. Next
  675. SetBlend LightBlend
  676. SetAlpha 0.25
  677. SetColor 48,64,48
  678. SetRotation 0
  679. DrawRect Scanner_X-64,Scanner_Y-64,256,256
  680. SetColor 0,255,0
  681. For so=EachIn ScanList
  682. so.Update(scanner_x,Scanner_Y)
  683. Next
  684. EndFunction