Author Topic: Hunter's Revenge by Ashish  (Read 703 times)

Offline Qwerkey

  • Moderator
  • Forum Resident
  • Posts: 736
Hunter's Revenge by Ashish
« on: March 05, 2020, 05:50:56 AM »
Hunter's Revenge

Author: @Ashish
Source: qb64.org Forum
URL: https://www.qb64.org/forum/index.php?topic=345.msg2322#msg2322
Version: « Reply #7 on: July 18, 2018, 12:48:12 PM »
Tags: [Graphics], [2D], [Shoot 'Em]

Description:
You got a gun, and what you have to do is shoot down the objects you see on screen.  The game have different weather conditions as well as different areas.

Controls:
Use mouse movement to change your target. Use left click to shoot and right click to change gun. Use 'Esc' or Middle button to pause during gameplay.

Source Code:
Code: QB64: [Select]
  1. '################################################################
  2. '      H U N T E R ' S    R E V E N G E    2 0 1 7 - 1 8
  3. '                  By Ashish Kushwaha
  4. '         **** Hit F5 and Enjoy the Game!! ****
  5. 'Note :-
  6. 'The executable should be inside Hunter-Revenge folder
  7. 'If you are facing any problem, report it at Qb64.org Forum
  8. '
  9. '*** Tell Me You You Think About This Game On Twitter with @KingOfCoders ***
  10. '
  11. '################################################################
  12.  
  13. '$CONSOLE
  14. '_CONSOLETITLE "Hunter's Revenge [DEBUG_OUTPUT]"
  15.  
  16. IF COMMAND$(1) = "--reset" THEN
  17.     INPUT "Are you sure that you want to reset the game? (Y/N) ", dummy$1
  18.     IF UCASE$(dummy$1) = "Y" THEN KILL "Save_Game/save.dat": createConfig: SYSTEM
  19.  
  20. 'App icon
  21. $EXEICON:'Hunter-Revenge-master/Images/game.ico'
  22. tmp_icon& = _LOADIMAGE("Images/cursor.png", 32)
  23. _CLEARCOLOR _RGB(255, 255, 255), tmp_icon&
  24. _ICON tmp_icon&
  25. _FREEIMAGE tmp_icon&
  26.  
  27. '$include:'Vendor/spritetop.bi'
  28.  
  29. _TITLE "Hunter's Revenge"
  30.  
  31. SCREEN _NEWIMAGE(800, 600, 32)
  32.  
  33. ' ON ERROR GOTO 404
  34.  
  35.  
  36. 'Notification Section
  37. DIM SHARED NEvent, NFPSCount%, NImage&, NText$, NShow AS _BYTE
  38.  
  39. 'Frame Rate Section
  40. DIM SHARED FPSEvent, FPSEvt, FPSCurrent%, FPSRate%, FPSBg&
  41.  
  42. 'Loader Section
  43. DIM SHARED Loader&, LoaderX%, LoaderY%, LoaderCF%, LoaderEvt!
  44. LoaderX% = 730: LoaderY% = 500
  45.  
  46. 'Game Types
  47. TYPE GameMenu
  48.     click AS _BYTE
  49.     hover AS _BYTE
  50.     y AS INTEGER
  51.     img AS LONG
  52.     img2 AS LONG 'software image
  53.  
  54. TYPE Mousetype
  55.     x AS INTEGER
  56.     y AS INTEGER
  57.     lclick AS _BYTE
  58.     rclick AS _BYTE
  59.     mclick AS _BYTE
  60.     cursor AS LONG
  61.     cursor2 AS LONG
  62.     hovering AS _BYTE
  63.  
  64. TYPE fonttype
  65.     smaller AS LONG
  66.     normal AS LONG
  67.     bigger AS LONG
  68.     biggest AS LONG
  69. 'game objects
  70.  
  71. TYPE explosiontype
  72.     x AS INTEGER
  73.     y AS INTEGER
  74.     img AS INTEGER
  75.     active AS _BYTE
  76.     currentFrame AS INTEGER
  77.     totalFrames AS INTEGER
  78.     f AS INTEGER
  79.     n AS INTEGER
  80.  
  81. TYPE guntype
  82.     NAME AS STRING * 32
  83.     damage AS INTEGER
  84.     id AS INTEGER
  85.     img AS LONG
  86.  
  87. TYPE Enemies
  88.     x AS INTEGER ' x position
  89.     y AS INTEGER ' y position
  90.     typ AS STRING * 16 'type of enemie
  91.     life AS INTEGER 'life of the enemie
  92.     life2 AS INTEGER 'backup of life
  93.     damage AS INTEGER 'useless
  94.     ending AS _BYTE 'enemie is dead or not
  95.     img AS INTEGER 'sprite handle
  96.     active AS _BYTE 'enemie is active or not
  97.     u AS LONG 'delay (in milliseconds) after which enemie will show up in his scene in gameplay
  98.     n AS INTEGER 'delay between change of frame of animation
  99.     f AS INTEGER 'increment varible, if greater than above 'n', then frame is change
  100.     m AS DOUBLE 'movement speed
  101.     points AS INTEGER 'holds point
  102.     scene AS INTEGER 'hold scene
  103.     snd AS LONG 'hold sound handle
  104.     sndPaused AS _BYTE ' = true when sound is paused.
  105.  
  106. TYPE Levels
  107.     enemies AS INTEGER 'total enemies in a level
  108.     scenes AS INTEGER 'total scenes in a level
  109.     currentScene AS INTEGER 'current scene of the gameplay
  110.     completed AS _BYTE 'level has been completed or not
  111.     u AS LONG 'current frame of the gameplay (always increases during gameplay)
  112.     over AS _BYTE ' level has been over or not
  113.     background AS STRING * 64 'background image path of the level
  114.     bg AS LONG 'background image handle of the level
  115.     mode AS INTEGER 'MODs of the game. Can be either THUNDERMODE, STORMMODE, FOGMODE, THUNDERMODE+FOGMODE, THUNDERMODE+STORMMODE
  116.     cancel AS _BYTE 'level has been cancel or not
  117.     time AS _UNSIGNED INTEGER 'number of seconds a level has to be completed in (in seconds).
  118.  
  119. TYPE fog
  120.     x AS INTEGER
  121.     move AS INTEGER
  122.     handle AS LONG
  123.  
  124. TYPE drops
  125.     x AS INTEGER
  126.     y AS INTEGER
  127.     z AS INTEGER
  128.     LEN AS DOUBLE
  129.     yspeed AS DOUBLE
  130.     gravity AS DOUBLE
  131.  
  132. TYPE Settings
  133.     fullscreen AS _BYTE
  134.     music AS _BYTE
  135.     sfx AS _BYTE
  136.     musicV AS DOUBLE
  137.     sfxV AS DOUBLE
  138.     SE AS _BYTE
  139.     fps AS INTEGER
  140.     done AS _BYTE
  141.  
  142. 'score flasher
  143. TYPE scoreFlasher
  144.     x AS SINGLE
  145.     y AS SINGLE
  146.     img AS LONG
  147.     active AS _BYTE
  148.     sclX AS SINGLE
  149.     sclY AS SINGLE
  150.     __ops AS SINGLE
  151.  
  152. ' TYPE Vector_Particles_Text_Type
  153. ' x AS SINGLE 'x position
  154. ' y AS SINGLE 'y position
  155. ' vx AS SINGLE 'visual x
  156. ' vy AS SINGLE 'visual y
  157. ' delX AS SINGLE 'delta velocity
  158. ' delY AS SINGLE 'delta velocity
  159. ' dist AS SINGLE 'distance
  160. ' distX AS SINGLE ' distance x
  161. ' distY AS SINGLE 'distance y
  162. ' k AS SINGLE
  163. ' END TYPE
  164.  
  165. '$DYNAMIC
  166.  
  167. DIM SHARED W AS Settings
  168. readConfig
  169.  
  170. 'DIM SHARED Paused AS _BYTE
  171.  
  172. 'REDIM SHARED Text_Particles(1) AS Vector_Particles_Text_Type
  173.  
  174. 'DIM SHARED Text_Particles_Status, Text_Particles_Color AS _UNSIGNED LONG
  175.  
  176. DIM SHARED randomLevels AS _BYTE 'Computer chooses level! ^_*
  177.  
  178. DIM SHARED Menubg&, GlobalEvent, TimerEvent, GameRenderingEvent, Minutes%, Seconds%
  179.  
  180. DIM SHARED Mouse AS Mousetype
  181.  
  182. DIM SHARED Fonts AS fonttype
  183.  
  184. DIM SHARED GameMenus(19) AS GameMenu
  185.  
  186. DIM SHARED MenuBlood%, MenuChoice
  187.  
  188. DIM SHARED ShotScore(5) AS scoreFlasher
  189.  
  190. DIM SHARED explosions(20) AS explosiontype, Gun AS guntype, Bloods(50) AS explosiontype
  191.  
  192. DIM SHARED Level AS Levels
  193.  
  194. DIM SHARED HighScore%, LevelStage%, LevelStage2%, CurrentScore%
  195.  
  196. DIM SHARED ScoreBoard&, GunImg&(1), OldScore%, OldSeconds%
  197.  
  198. DIM SHARED Musics&(2)
  199.  
  200. 'Rains
  201. DIM SHARED Drop(700) AS drops
  202. DIM SHARED Rainx8&, Rainx16&, RainLight&, RainSound&, RainVol#, ThunderCount, ThunderEvent
  203.  
  204.  
  205.  
  206. 'max level
  207. CONST MAX_LEVEL = 14
  208. 'storm
  209. DIM SHARED StormImg&, StormX%
  210.  
  211. 'Sparks
  212. DIM SHARED ExplosionsZ(1) AS explosiontype
  213.  
  214. 'MODS
  215. CONST FOGMODE = 1
  216. CONST THUNDERMODE = 3
  217. CONST STORMMODE = 5
  218. DIM SHARED Fogs AS fog
  219.  
  220. 'SFXs
  221. DIM SHARED Eagle&
  222. DIM SHARED Bird&
  223. DIM SHARED Crow&
  224. DIM SHARED Expos&
  225. DIM SHARED Jet&
  226. DIM SHARED Gun1&
  227. DIM SHARED Gun2&
  228.  
  229. 'Enemies scores image
  230. DIM SHARED scoresImage(5) AS LONG
  231.  
  232. REDIM SHARED Enemie(0) AS Enemies
  233.  
  234. DIM SHARED Jet1_Sheet%
  235. DIM SHARED Jet2_Sheet%
  236. DIM SHARED Jet3_Sheet%
  237. DIM SHARED Bird_Sheet%
  238. DIM SHARED Crow_Sheet%
  239. DIM SHARED eagle_Sheet%
  240. DIM SHARED blood_Sheet%
  241. DIM SHARED explosion_Sheet%
  242. DIM SHARED spark_Sheet%
  243. DIM SHARED lifeBars(99) AS LONG
  244.  
  245. FPSEvent = _FREETIMER 'Event for showing current FPS (Frame Per Second)
  246. FPSEvt = _FREETIMER 'Event for calculating current FPS (Frame Per Second)
  247. GlobalEvent = _FREETIMER 'Event for game main menu
  248. TimerEvent = _FREETIMER 'Event of timer which is displayed during gameplay
  249. GameRenderingEvent = _FREETIMER 'Event in which level objects are rendered.
  250. NEvent = _FREETIMER ' Global Event for notification
  251.  
  252. 'Splash Screen
  253.  
  254. Splash
  255.  
  256.  
  257. LoaderStart
  258.  
  259. loadComponents
  260. 'cursors
  261. Mouse.cursor = _LOADIMAGE("Images/cursor.png", 33)
  262. Mouse.cursor2 = _LOADIMAGE("Images/cursor2.png", 33)
  263.  
  264. 'fonts
  265. Fonts.biggest = _LOADFONT("Font/ARDESTINE.ttf", 68)
  266. Fonts.bigger = _LOADFONT("Font/ARDESTINE.ttf", 40)
  267. Fonts.smaller = _LOADFONT("Font/arial.ttf", 12, "dontblend")
  268. Fonts.normal = _LOADFONT("Font/ARDESTINE.ttf", 24)
  269.  
  270. 'scores image
  271.  
  272. scoresImage(0) = _LOADIMAGE("Images/10.png", 33)
  273. scoresImage(1) = _LOADIMAGE("Images/20.png", 33)
  274. scoresImage(2) = _LOADIMAGE("Images/35.png", 33)
  275. scoresImage(3) = _LOADIMAGE("Images/50.png", 33)
  276. scoresImage(4) = _LOADIMAGE("Images/75.png", 33)
  277. scoresImage(5) = _LOADIMAGE("Images/100.png", 33)
  278.  
  279. 'fogs
  280. Fogs.x = 0
  281. Fogs.move = 1
  282. Fogs.handle = _LOADIMAGE("Images/fogs_.png", 33)
  283.  
  284. 'rains
  285. Rainx8& = _LOADIMAGE("Images/rainx8.png", 33)
  286. Rainx16& = _LOADIMAGE("Images/rainx16.png", 33)
  287.  
  288.  
  289. 'storm
  290. StormImg& = _LOADIMAGE("Images\storm.png", 33) 'we're using hardware image
  291.  
  292. 'LifeBars
  293. FOR i = 0 TO 99
  294.     lifeBars(i) = _NEWIMAGE(100, 6, 32)
  295.     _DEST lifeBars(i)
  296.     r = p5map(i + 1, 1, 100, 255, 0)
  297.     g = p5map(i + 1, 1, 100, 0, 255)
  298.     LINE (0, 0)-(100, 6), _RGB(0, 0, 0), BF
  299.     LINE (0, 0)-(i + 1, 6), _RGB(r, g, 0), BF
  300.     LINE (0, 0)-(99, 5), _RGB(255, 255, 255), B
  301.     _DEST 0
  302.  
  303. DIM tmp&
  304. FOR i = 0 TO 99
  305.     tmp& = _COPYIMAGE(lifeBars(i))
  306.     _FREEIMAGE lifeBars(i)
  307.     lifeBars(i) = _COPYIMAGE(tmp&, 33)
  308.     _FREEIMAGE tmp&
  309.  
  310. Gun.damage = 3
  311. Gun.id = 1
  312. Gun.NAME = "Shot Gun"
  313.  
  314. Menubg& = _LOADIMAGE("Images\farm1.jpg")
  315. GunImg&(0) = _LOADIMAGE("Images\gun_shot.png")
  316. GunImg&(1) = _LOADIMAGE("Images\Gun_ak-47.png")
  317. ScoreBoard& = _LOADIMAGE("Images\score_board.png")
  318.  
  319. blood_Sheet% = SPRITESHEETLOAD("Images\blood.png", 64, 62, _RGB(0, 0, 0))
  320. Jet1_Sheet% = SPRITESHEETLOAD("Images\Jet.png", 120, 122, _RGB(0, 0, 0))
  321. Jet2_Sheet% = SPRITESHEETLOAD("Images\Jet_2.png", 120, 122, _RGB(0, 0, 0))
  322. Jet3_Sheet% = SPRITESHEETLOAD("Images\Jet_3.png", 150, 122, _RGB(0, 0, 0))
  323. eagle_Sheet% = SPRITESHEETLOAD("Images\eagle.png", 40, 40, _RGB(0, 0, 0))
  324. Crow_Sheet% = SPRITESHEETLOAD("Images\crow.png", 97, 120, _RGB(0, 0, 0))
  325. Bird_Sheet% = SPRITESHEETLOAD("Images\bird.png", 180, 170, _RGB(0, 0, 0))
  326.  
  327. explosion_Sheet% = SPRITESHEETLOAD("Images\explosion.png", 100, 100, _RGB(0, 0, 0))
  328.  
  329. FOR i = 0 TO 1
  330.     ExplosionsZ(i).img = SPRITENEW(explosion_Sheet%, 1, SAVE)
  331.     SPRITEANIMATESET ExplosionsZ(i).img, 1, 81
  332.     ExplosionsZ(i).y = 300
  333.  
  334. ExplosionsZ(0).x = 100: ExplosionsZ(1).x = 700
  335.  
  336. FOR i = 0 TO 20
  337.     Bloods(i).img = SPRITENEW(blood_Sheet%, 1, SAVE)
  338.     SPRITEANIMATESET Bloods(i).img, 1, 6
  339.     explosions(i).img = SPRITENEW(explosion_Sheet%, 1, SAVE)
  340.     SPRITEANIMATESET explosions(i).img, 1, 81
  341.     Bloods(i).totalFrames = 6
  342.     Bloods(i).n = 5
  343.     explosions(i).totalFrames = 81
  344.     explosions(i).n = 4
  345. MenuBlood% = SPRITENEW(blood_Sheet%, 1, SAVE)
  346. SPRITEANIMATESET MenuBlood%, 1, 6
  347.  
  348.  
  349.  
  350. 'Setup Notificaton stuff
  351. ON TIMER(NEvent, .013) Notify
  352. TIMER(NEvent) ON
  353.  
  354. _FONT Fonts.bigger
  355.  
  356. tmp& = _NEWIMAGE(400, 60, 32)
  357. _DEST tmp&
  358. _FONT Fonts.bigger
  359. COLOR , _RGBA(0, 0, 0, 0)
  360. _PRINTSTRING (CenterPrintX("Play"), 0), "Play"
  361. GameMenus(0).img = _COPYIMAGE(tmp&, 33)
  362. GameMenus(0).img2 = _COPYIMAGE(tmp&, 32)
  363. GameMenus(0).y = 150
  364.  
  365. tmp& = _NEWIMAGE(400, 60, 32)
  366. _DEST tmp&
  367. _FONT Fonts.bigger
  368. COLOR , _RGBA(0, 0, 0, 0)
  369. _PRINTSTRING (CenterPrintX("Options"), 0), "Options"
  370. GameMenus(1).img = _COPYIMAGE(tmp&, 33)
  371. GameMenus(1).img2 = _COPYIMAGE(tmp&, 32)
  372. GameMenus(1).y = GameMenus(0).y + 60
  373.  
  374. tmp& = _NEWIMAGE(400, 60, 32)
  375. _DEST tmp&
  376. _FONT Fonts.bigger
  377. COLOR , _RGBA(0, 0, 0, 0)
  378. _PRINTSTRING (CenterPrintX("Help"), 0), "Help"
  379. GameMenus(2).img = _COPYIMAGE(tmp&, 33)
  380. GameMenus(2).img2 = _COPYIMAGE(tmp&, 32)
  381. GameMenus(2).y = GameMenus(1).y + 60
  382.  
  383. tmp& = _NEWIMAGE(400, 60, 32)
  384. _DEST tmp&
  385. _FONT Fonts.bigger
  386. COLOR , _RGBA(0, 0, 0, 0)
  387. _PRINTSTRING (CenterPrintX("Credits"), 0), "Credits"
  388. GameMenus(3).img = _COPYIMAGE(tmp&, 33)
  389. GameMenus(3).img2 = _COPYIMAGE(tmp&, 32)
  390. GameMenus(3).y = GameMenus(2).y + 60
  391.  
  392. tmp& = _NEWIMAGE(400, 60, 32)
  393. _DEST tmp&
  394. _FONT Fonts.bigger
  395. COLOR , _RGBA(0, 0, 0, 0)
  396. _PRINTSTRING (CenterPrintX("Exit"), 0), "Exit"
  397. GameMenus(4).img = _COPYIMAGE(tmp&, 33)
  398. GameMenus(4).img2 = _COPYIMAGE(tmp&, 32)
  399. GameMenus(4).y = GameMenus(3).y + 60
  400.  
  401.  
  402. tmp& = _NEWIMAGE(400, 30, 32)
  403. _DEST tmp&
  404. COLOR , _RGBA(0, 0, 0, 0)
  405. _FONT Fonts.normal
  406. _PRINTSTRING (20, 0), "Fullscreen"
  407. GameMenus(5).img = _COPYIMAGE(tmp&, 33)
  408. GameMenus(5).img2 = _COPYIMAGE(tmp&, 32)
  409. GameMenus(5).y = 113
  410.  
  411. tmp& = _NEWIMAGE(400, 30, 32)
  412. _DEST tmp&
  413. COLOR , _RGBA(0, 0, 0, 0)
  414. _FONT Fonts.normal
  415. _PRINTSTRING (20, 0), "Fullscreen Method "
  416. GameMenus(6).img = _COPYIMAGE(tmp&, 33)
  417. GameMenus(6).img2 = _COPYIMAGE(tmp&, 32)
  418. GameMenus(6).y = GameMenus(5).y + 34
  419.  
  420. tmp& = _NEWIMAGE(400, 30, 32)
  421. _DEST tmp&
  422. COLOR , _RGBA(0, 0, 0, 0)
  423. _FONT Fonts.normal
  424. _PRINTSTRING (20, 0), "Music "
  425. GameMenus(7).img = _COPYIMAGE(tmp&, 33)
  426. GameMenus(7).img2 = _COPYIMAGE(tmp&, 32)
  427. GameMenus(7).y = GameMenus(6).y + 34
  428.  
  429. tmp& = _NEWIMAGE(400, 30, 32)
  430. _DEST tmp&
  431. COLOR , _RGBA(0, 0, 0, 0)
  432. _FONT Fonts.normal
  433. _PRINTSTRING (20, 0), "SFX "
  434. GameMenus(8).img = _COPYIMAGE(tmp&, 33)
  435. GameMenus(8).img2 = _COPYIMAGE(tmp&, 32)
  436. GameMenus(8).y = GameMenus(7).y + 34
  437.  
  438. tmp& = _NEWIMAGE(400, 30, 32)
  439. _DEST tmp&
  440. COLOR , _RGBA(0, 0, 0, 0)
  441. _FONT Fonts.normal
  442. _PRINTSTRING (20, 0), "Music Volume "
  443. GameMenus(9).img = _COPYIMAGE(tmp&, 33)
  444. GameMenus(9).img2 = _COPYIMAGE(tmp&, 32)
  445. GameMenus(9).y = GameMenus(8).y + 34
  446.  
  447. tmp& = _NEWIMAGE(400, 30, 32)
  448. _DEST tmp&
  449. COLOR , _RGBA(0, 0, 0, 0)
  450. _FONT Fonts.normal
  451. _PRINTSTRING (20, 0), "SFX Volume"
  452. GameMenus(10).img = _COPYIMAGE(tmp&, 33)
  453. GameMenus(10).img2 = _COPYIMAGE(tmp&, 32)
  454. GameMenus(10).y = GameMenus(9).y + 34
  455.  
  456. tmp& = _NEWIMAGE(400, 30, 32)
  457. _DEST tmp&
  458. COLOR , _RGBA(0, 0, 0, 0)
  459. _FONT Fonts.normal
  460. _PRINTSTRING (20, 0), "3D Sound Effect"
  461. GameMenus(11).img = _COPYIMAGE(tmp&, 33)
  462. GameMenus(11).img2 = _COPYIMAGE(tmp&, 32)
  463. GameMenus(11).y = GameMenus(10).y + 34
  464.  
  465. tmp& = _NEWIMAGE(400, 30, 32)
  466. _DEST tmp&
  467. COLOR , _RGBA(0, 0, 0, 0)
  468. _FONT Fonts.normal
  469. _PRINTSTRING (20, 0), "Frame Rate "
  470. GameMenus(12).img = _COPYIMAGE(tmp&, 33)
  471. GameMenus(12).img2 = _COPYIMAGE(tmp&, 32)
  472. GameMenus(12).y = GameMenus(11).y + 34
  473.  
  474. tmp& = _NEWIMAGE(500, 30, 32)
  475. _DEST tmp&
  476. COLOR , _RGBA(0, 0, 0, 0)
  477. _FONT Fonts.normal
  478. _PRINTSTRING (CenterPrintX("Default Settings"), 0), "Default Settings"
  479. GameMenus(13).img = _COPYIMAGE(tmp&, 33)
  480. GameMenus(13).img2 = _COPYIMAGE(tmp&, 32)
  481. GameMenus(13).y = GameMenus(12).y + 34
  482.  
  483. tmp& = _NEWIMAGE(500, 200, 32)
  484. _DEST tmp&
  485. COLOR , _RGBA(0, 0, 0, 0)
  486. _FONT Fonts.normal
  487. _PRINTSTRING (CenterPrintX("Apply Settings"), 0), "Apply Settings"
  488. GameMenus(14).img = _COPYIMAGE(tmp&, 33)
  489. GameMenus(14).img2 = _COPYIMAGE(tmp&, 32)
  490. GameMenus(14).y = GameMenus(13).y + 34
  491.  
  492. tmp& = _NEWIMAGE(500, 200, 32)
  493. _DEST tmp&
  494. COLOR , _RGBA(0, 0, 0, 0)
  495. _FONT Fonts.normal
  496. _PRINTSTRING (CenterPrintX("Go Back To Main Menu"), 0), "Go Back To Main Menu"
  497. GameMenus(15).img = _COPYIMAGE(tmp&, 33)
  498. GameMenus(15).img2 = _COPYIMAGE(tmp&, 32)
  499. GameMenus(15).y = GameMenus(14).y + 34
  500.  
  501. tmp& = _NEWIMAGE(500, 200, 32)
  502. _DEST tmp&
  503. COLOR , _RGBA(0, 0, 0, 0)
  504. _FONT Fonts.normal
  505. _PRINTSTRING (20, 0), "Fullscreen"
  506. GameMenus(16).img = _COPYIMAGE(tmp&, 33)
  507. GameMenus(16).img2 = _COPYIMAGE(tmp&, 32)
  508. GameMenus(16).y = 232
  509.  
  510. tmp& = _NEWIMAGE(500, 200, 32)
  511. _DEST tmp&
  512. COLOR , _RGBA(0, 0, 0, 0)
  513. _FONT Fonts.normal
  514. _PRINTSTRING (20, 0), "Music Volume"
  515. GameMenus(17).img = _COPYIMAGE(tmp&, 33)
  516. GameMenus(17).img2 = _COPYIMAGE(tmp&, 32)
  517. GameMenus(17).y = GameMenus(16).y + 34
  518.  
  519. tmp& = _NEWIMAGE(500, 200, 32)
  520. _DEST tmp&
  521. COLOR , _RGBA(0, 0, 0, 0)
  522. _FONT Fonts.normal
  523. _PRINTSTRING (20, 0), "SFX Volume"
  524. GameMenus(18).img = _COPYIMAGE(tmp&, 33)
  525. GameMenus(18).img2 = _COPYIMAGE(tmp&, 32)
  526. GameMenus(18).y = GameMenus(17).y + 34
  527.  
  528. tmp& = _NEWIMAGE(500, 200, 32)
  529. _DEST tmp&
  530. COLOR , _RGBA(0, 0, 0, 0)
  531. _FONT Fonts.normal
  532. _PRINTSTRING (CenterPrintX("Exit to Main Menu"), 0), "Exit to Main Menu"
  533. GameMenus(19).img = _COPYIMAGE(tmp&, 33)
  534. GameMenus(19).img2 = _COPYIMAGE(tmp&, 32)
  535. GameMenus(19).y = GameMenus(18).y + 34
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542. LoaderEnd
  543.  
  544. start:
  545.  
  546. COLOR _RGB(255, 255, 255), _RGBA(0, 0, 0, 0)
  547.  
  548. ' echo COMMAND$(1)
  549. ' echo COMMAND$(2)
  550. ' IF COMMAND$(1) = "-loadlevel" AND VAL(COMMAND$(2)) > 0 THEN
  551. ' LevelStage% = VAL(COMMAND$(2))
  552. ' LevelStage2% = LevelStage%
  553. ' GOTO newgame
  554. ' END IF
  555.  
  556. GameMenu
  557.  
  558.  
  559.  
  560.  
  561. IF MenuChoice = 1 THEN MenuChoice = 0: GOTO newgame
  562. IF MenuChoice = 2 THEN
  563.     MenuChoice = 0
  564.  
  565.     'save current settings in dummy variable :P
  566.     DIM preConfig AS Settings
  567.     preConfig = W ' W is a global variable which stored all game settings
  568.  
  569.     DIM on_switch&, off_switch&, bd&, cj&, gfx&, ac& 'images surface
  570.     on_switch& = _LOADIMAGE("Images/on.png", 33)
  571.     off_switch& = _LOADIMAGE("Images/off.png", 33)
  572.     FOR i = 0 TO 4
  573.         _PUTIMAGE (200, GameMenus(i).y), GameMenus(i).img2
  574.     NEXT
  575.  
  576.     bd& = _COPYIMAGE(0)
  577.     cj& = _COPYIMAGE(bd&)
  578.  
  579.     BLURIMAGE cj&, 5
  580.     gfx& = _NEWIMAGE(500, 340, 32)
  581.     _DEST gfx&
  582.     CLS , 0 'make it transparent
  583.     LINE (0, 0)-STEP(_WIDTH, _HEIGHT), _RGBA(0, 0, 0, 150), BF
  584.     FOR i = 5 TO 14
  585.         _PUTIMAGE (0, GameMenus(i).y - 103), GameMenus(i).img2
  586.     NEXT
  587.  
  588.     _DEST 0
  589.  
  590.     FOR i = 0 TO 255 STEP 10
  591.         _SETALPHA i, , cj&
  592.         _PUTIMAGE , bd&
  593.         _PUTIMAGE , cj&
  594.         LINE (0, 0)-(_WIDTH, _HEIGHT), _RGBA(0, 0, 0, i / 3), BF
  595.         _PUTIMAGE (150, 103), gfx&, 0, (0, 0)-(500, p5map(i, 0, 255, 0, 340))
  596.         _DISPLAY
  597.     NEXT
  598.     ac& = _COPYIMAGE(cj&)
  599.     _DEST ac&
  600.     LINE (0, 0)-(_WIDTH, _HEIGHT), _RGBA(0, 0, 0, 85), BF
  601.     _DEST 0
  602.     DO
  603.         WHILE _MOUSEINPUT: WEND
  604.         Mouse.x = _MOUSEX: Mouse.y = _MOUSEY
  605.         Mouse.lclick = 0
  606.         Mouse.rclick = 0
  607.         IF _MOUSEBUTTON(1) THEN
  608.             WHILE _MOUSEBUTTON(1): WHILE _MOUSEINPUT: WEND: WEND
  609.             Mouse.lclick = -1
  610.         END IF
  611.         IF _MOUSEBUTTON(2) THEN
  612.             WHILE _MOUSEBUTTON(2): WHILE _MOUSEINPUT: WEND: WEND
  613.             Mouse.rclick = -1
  614.         END IF
  615.         _PUTIMAGE , ac&
  616.         LINE (150, 103)-STEP(500, 374), _RGBA(0, 0, 0, 150), BF
  617.         FOR i = 5 TO 15
  618.             IF Mouse.x > 150 AND Mouse.x < 650 AND Mouse.y > GameMenus(i).y - 10 AND Mouse.y < GameMenus(i).y + 24 THEN
  619.                 LINE (150, GameMenus(i).y - 10)-(650, GameMenus(i).y + 24), _RGBA(255, 100, 0, 100), BF
  620.                 IF Mouse.lclick THEN
  621.                     SELECT CASE i
  622.                         CASE 5
  623.                             IF W.fullscreen > 0 THEN W.fullscreen = 0 ELSE W.fullscreen = 1
  624.                         CASE 6
  625.                             W.fullscreen = W.fullscreen + 1
  626.                             IF W.fullscreen > 2 THEN W.fullscreen = 1
  627.                         CASE 7
  628.                             IF W.music THEN W.music = 0 ELSE W.music = -1
  629.                         CASE 8
  630.                             IF W.sfx THEN W.sfx = 0 ELSE W.sfx = -1
  631.                         CASE 9
  632.                             W.musicV = W.musicV + .1
  633.                             IF W.musicV > 1.0 THEN W.musicV = .1
  634.                         CASE 10
  635.                             W.sfxV = W.sfxV + .1
  636.                             IF W.sfxV > 1 THEN W.sfxV = 0.1
  637.                         CASE 11
  638.                             IF W.SE THEN W.SE = 0 ELSE W.SE = -1
  639.                         CASE 12
  640.                             W.fps = W.fps + 30
  641.                             IF W.fps > 240 THEN W.fps = 30
  642.                         CASE 13
  643.                             W.fullscreen = 0
  644.                             W.music = -1
  645.                             W.sfx = -1
  646.                             W.musicV = 1
  647.                             W.sfxV = 1
  648.                             W.SE = -1
  649.                             W.fps = 30
  650.                         CASE 14
  651.                             writeConfig
  652.                             loadComponents
  653.                             showNotification "Settings have been applied."
  654.                         CASE 15
  655.                             EXIT DO
  656.                     END SELECT
  657.                 END IF
  658.             END IF
  659.             _PUTIMAGE (150, GameMenus(i).y), GameMenus(i).img
  660.             SELECT CASE i
  661.                 CASE 5
  662.                     IF W.fullscreen > 0 THEN _PUTIMAGE (580, GameMenus(i).y - 3), on_switch& ELSE _PUTIMAGE (580, GameMenus(i).y - 3), off_switch&
  663.                 CASE 6
  664.                     _FONT Fonts.normal
  665.                     SELECT CASE W.fullscreen
  666.                         CASE 1
  667.                             _PRINTSTRING (630 - txtWidth("Stretch"), GameMenus(i).y), "Stretch"
  668.                         CASE 2
  669.                             _PRINTSTRING (630 - txtWidth("Square Pixels"), GameMenus(i).y), "Square Pixels"
  670.                         CASE ELSE
  671.                             _PRINTSTRING (630 - txtWidth("Disable"), GameMenus(i).y), "Disable"
  672.                     END SELECT
  673.                 CASE 7
  674.                     IF W.music THEN _PUTIMAGE (580, GameMenus(i).y - 3), on_switch& ELSE _PUTIMAGE (580, GameMenus(i).y - 3), off_switch&
  675.                 CASE 8
  676.                     IF W.sfx THEN _PUTIMAGE (580, GameMenus(i).y - 3), on_switch& ELSE _PUTIMAGE (580, GameMenus(i).y - 3), off_switch&
  677.                 CASE 9
  678.                     _FONT Fonts.normal
  679.                     IF W.musicV > .9 THEN
  680.                         _PRINTSTRING (630 - txtWidth(" 10"), GameMenus(i).y), " 10 "
  681.                     ELSE
  682.                         _PRINTSTRING (630 - txtWidth(STR$(INT(W.musicV * 10))), GameMenus(i).y), STR$(INT(W.musicV * 10))
  683.                     END IF
  684.                 CASE 10
  685.                     _FONT Fonts.normal
  686.                     IF W.sfxV > .9 THEN
  687.                         _PRINTSTRING (630 - txtWidth(" 10"), GameMenus(i).y), " 10 "
  688.                     ELSE
  689.                         _PRINTSTRING (630 - txtWidth(STR$(INT(W.sfxV * 10))), GameMenus(i).y), STR$(INT(W.sfxV * 10))
  690.                     END IF
  691.                 CASE 11
  692.                     IF W.SE THEN _PUTIMAGE (580, GameMenus(i).y - 3), on_switch& ELSE _PUTIMAGE (580, GameMenus(i).y - 3), off_switch&
  693.                 CASE 12
  694.                     _FONT Fonts.normal
  695.                     _PRINTSTRING (630 - txtWidth(STR$(W.fps)), GameMenus(i).y), STR$(W.fps)
  696.             END SELECT
  697.         NEXT
  698.         _LIMIT W.fps
  699.         IF Mouse.hovering THEN
  700.             _PUTIMAGE (Mouse.x - 16, Mouse.y - 16), Mouse.cursor2
  701.             _DISPLAY
  702.         ELSE
  703.             _PUTIMAGE (Mouse.x - 16, Mouse.y - 16), Mouse.cursor
  704.             _DISPLAY
  705.         END IF
  706.  
  707.     LOOP
  708.     FOR i = 255 TO 0 STEP -10
  709.         _SETALPHA i, , cj&
  710.         _PUTIMAGE , bd&
  711.         _PUTIMAGE , cj&
  712.         LINE (0, 0)-(_WIDTH, _HEIGHT), _RGBA(0, 0, 0, i / 3), BF
  713.         _PUTIMAGE (150, 103), gfx&, 0, (0, 0)-(500, p5map(i, 0, 255, 0, 340))
  714.         _DISPLAY
  715.     NEXT
  716.     _FREEIMAGE bd&
  717.     _FREEIMAGE cj&
  718.     _FREEIMAGE ac&
  719.     _FREEIMAGE gfx&
  720.     _FREEIMAGE on_switch&
  721.     _FREEIMAGE off_switch&
  722.     GOTO start
  723. IF MenuChoice = 3 THEN
  724.     MenuChoice = 0
  725.     FOR i = 0 TO 4
  726.         _PUTIMAGE (200, GameMenus(i).y), GameMenus(i).img2
  727.     NEXT
  728.     bd& = _COPYIMAGE(0)
  729.     cj& = _COPYIMAGE(bd&)
  730.  
  731.     BLURIMAGE cj&, 5
  732.     DIM k&
  733.     k& = _LOADIMAGE("Images\help.png")
  734.  
  735.     FOR i = 0 TO 255 STEP 10
  736.         _SETALPHA i, , cj&
  737.         _PUTIMAGE , bd&
  738.         _PUTIMAGE , cj&
  739.         _SETALPHA i / 1.25, , k&
  740.         LINE (0, 0)-(_WIDTH, _HEIGHT), _RGBA(0, 0, 0, i / 5), BF
  741.         centerImage k&
  742.         _DISPLAY
  743.     NEXT
  744.  
  745.     DO
  746.         'mouse input
  747.         WHILE _MOUSEINPUT: WEND
  748.         Mouse.x = _MOUSEX: Mouse.y = _MOUSEY
  749.  
  750.         IF _MOUSEBUTTON(1) THEN
  751.             WHILE _MOUSEBUTTON(1): WHILE _MOUSEINPUT: WEND: WEND
  752.             Mouse.lclick = -1
  753.         ELSE
  754.             Mouse.lclick = 0
  755.         END IF
  756.  
  757.         IF _MOUSEBUTTON(2) THEN
  758.             WHILE _MOUSEBUTTON(2): WHILE _MOUSEINPUT: WEND: WEND
  759.             Mouse.rclick = -1
  760.         ELSE
  761.             Mouse.rclick = 0
  762.         END IF
  763.  
  764.         _LIMIT W.fps
  765.  
  766.         _DISPLAY
  767.  
  768.         IF Mouse.lclick OR Mouse.rclick OR _KEYHIT = 27 THEN EXIT DO
  769.     LOOP
  770.  
  771.     FOR i = 255 TO 0 STEP -10
  772.         _SETALPHA i, , cj&
  773.         _PUTIMAGE , bd&
  774.         _PUTIMAGE , cj&
  775.         _SETALPHA i / 1.25, , k&
  776.         LINE (0, 0)-(_WIDTH, _HEIGHT), _RGBA(0, 0, 0, i / 5), BF
  777.         centerImage k&
  778.         _DISPLAY
  779.     NEXT
  780.  
  781.     _PUTIMAGE , bd&
  782.     _FREEIMAGE bd&
  783.     _FREEIMAGE cj&
  784.     _FREEIMAGE k&
  785.     GOTO start
  786.  
  787.  
  788. IF MenuChoice = 4 THEN
  789.     FOR i = 0 TO 4
  790.         _PUTIMAGE (200, GameMenus(i).y), GameMenus(i).img2
  791.     NEXT
  792.  
  793.     bd& = _COPYIMAGE(0)
  794.  
  795.     FOR i = 0 TO 255 STEP 5
  796.         _PUTIMAGE , bd&
  797.         LINE (0, 0)-(_WIDTH, _HEIGHT), _RGBA(0, 0, 0, i), BF
  798.         _DISPLAY
  799.     NEXT
  800.  
  801.     showCredits
  802.  
  803.     FOR i = 255 TO 0 STEP -5
  804.         _PUTIMAGE , bd&
  805.         LINE (0, 0)-(_WIDTH, _HEIGHT), _RGBA(0, 0, 0, i), BF
  806.         _DISPLAY
  807.     NEXT
  808.  
  809.     _FREEIMAGE bd&
  810.     MenuChoice = 0
  811.     GOTO start
  812.  
  813.  
  814. IF MenuChoice = 5 THEN SYSTEM 1
  815. MenuChoice = 0
  816. newgame:
  817.  
  818.  
  819.  
  820. LoaderStart
  821. SetupRain
  822. IF COMMAND$(1) = "-loadlevel" THEN
  823.     LoadLevel
  824.     IF getCurrentLevel > MAX_LEVEL THEN randomLevels = -1 ELSE randomLevels = 0: LoadLevel
  825.  
  826.  
  827. _FONT Fonts.bigger
  828.  
  829. '################### Random Levels ################################
  830. IF randomLevels THEN
  831.     Level.completed = 0
  832.     Level.over = 0
  833.     LevelStage% = p5random(1, MAX_LEVEL)
  834.     F = FREEFILE
  835.     'LevelStage% = VAL(COMMAND$(2))
  836.     OPEN "stages/stage" + RTRIM$(LTRIM$(STR$(LevelStage%))) + ".dat" FOR INPUT AS #F
  837.     INPUT #F, Level.enemies
  838.     INPUT #F, Level.scenes
  839.     INPUT #F, Seconds%
  840.     INPUT #F, Level.mode
  841.     INPUT #F, Level.background
  842.     CLOSE #F
  843.     Level.bg = _LOADIMAGE("Images\" + RTRIM$(Level.background))
  844.     OldSeconds% = Seconds%
  845.  
  846. IF randomLevels THEN _PRINTSTRING (CenterPrintX("Random Levels"), 300), "Random Levels" ELSE _PRINTSTRING (CenterPrintX("Stage " + LTRIM$(RTRIM$(STR$(LevelStage%)))), 300), "Stage " + LTRIM$(RTRIM$(STR$(LevelStage%)))
  847.  
  848.  
  849. ' if randomLevels then LoaderEnd : goto game_rendering_begin
  850. ' _DELAY 0.5
  851.  
  852.  
  853. '############################# Custom Levels #############################
  854.  
  855. ERASE Enemie 'clear all previous enemie data
  856.  
  857. REDIM SHARED Enemie(Level.enemies) AS Enemies
  858.  
  859. 'Enemie Configuirations
  860.  
  861. Level.completed = 0
  862. Level.over = 0
  863. Level.cancel = 0
  864. CurrentScore% = 0
  865. Level.u = 0
  866. Level.currentScene = 1
  867.  
  868. OPEN "Stages\Stage" + LTRIM$(RTRIM$(STR$(LevelStage%))) + ".lvl" FOR INPUT AS #F
  869.  
  870. FOR i = 1 TO Level.enemies
  871.     INPUT #F, Enemie(i).typ
  872.  
  873.     SELECT CASE RTRIM$(Enemie(i).typ)
  874.  
  875.         CASE "bird"
  876.             Enemie(i).img = SPRITENEW(Bird_Sheet%, 1, SAVE)
  877.             SPRITEANIMATESET Enemie(i).img, 1, 14
  878.             SPRITEZOOM Enemie(i).img, 50
  879.             Enemie(i).n = 6
  880.             Enemie(i).points = 10
  881.             Enemie(i).life = 4
  882.             Enemie(i).life2 = Enemie(i).life
  883.             Enemie(i).snd = _SNDCOPY(Bird&)
  884.         CASE "crow"
  885.             Enemie(i).img = SPRITENEW(Crow_Sheet%, 1, SAVE)
  886.             SPRITEANIMATESET Enemie(i).img, 1, 4
  887.             SPRITEZOOM Enemie(i).img, 70
  888.             Enemie(i).n = 12
  889.             Enemie(i).points = 20
  890.             Enemie(i).life = 7
  891.             Enemie(i).life2 = Enemie(i).life
  892.             Enemie(i).snd = _SNDCOPY(Crow&)
  893.         CASE "eagle"
  894.             Enemie(i).img = SPRITENEW(eagle_Sheet%, 7, SAVE)
  895.             SPRITEANIMATESET Enemie(i).img, 7, 9
  896.             Enemie(i).n = 12
  897.             Enemie(i).points = 35
  898.             Enemie(i).life = 14
  899.             Enemie(i).life2 = Enemie(i).life
  900.             Enemie(i).snd = _SNDCOPY(Eagle&)
  901.         CASE "jet1"
  902.             Enemie(i).img = SPRITENEW(Jet1_Sheet%, 1, SAVE)
  903.             SPRITEANIMATESET Enemie(i).img, 1, 3
  904.             SPRITEZOOM Enemie(i).img, 70
  905.             Enemie(i).n = 10
  906.             Enemie(i).points = 50
  907.             Enemie(i).life = 30
  908.             Enemie(i).life2 = Enemie(i).life
  909.             Enemie(i).snd = _SNDCOPY(Jet&)
  910.         CASE "jet2"
  911.             Enemie(i).img = SPRITENEW(Jet2_Sheet%, 1, SAVE)
  912.             SPRITEANIMATESET Enemie(i).img, 1, 3
  913.             SPRITEZOOM Enemie(i).img, 70
  914.             Enemie(i).n = 10
  915.             Enemie(i).points = 75
  916.             Enemie(i).life = 45
  917.             Enemie(i).life2 = Enemie(i).life
  918.             Enemie(i).snd = _SNDCOPY(Jet&)
  919.         CASE "jet3"
  920.             Enemie(i).img = SPRITENEW(Jet3_Sheet%, 1, SAVE)
  921.             SPRITEANIMATESET Enemie(i).img, 1, 3
  922.             SPRITEZOOM Enemie(i).img, 70
  923.             Enemie(i).n = 10
  924.             Enemie(i).points = 100
  925.             Enemie(i).life = 70
  926.             Enemie(i).life2 = Enemie(i).life
  927.             Enemie(i).snd = _SNDCOPY(Jet&)
  928.     END SELECT
  929.     INPUT #F, Enemie(i).u
  930.     INPUT #F, Enemie(i).y
  931.     INPUT #F, Enemie(i).m
  932.     IF Enemie(i).m < 0 THEN Enemie(i).x = _WIDTH: SPRITEFLIP Enemie(i).img, HORIZONTAL ELSE Enemie(i).x = 0
  933.  
  934.     INPUT #F, Enemie(i).scene
  935.  
  936.  
  937. LoaderEnd
  938.  
  939. game_rendering_begin:::
  940.  
  941. _PUTIMAGE (0, 0)-(_WIDTH, _HEIGHT), Level.bg
  942. _PUTIMAGE (0, 520), ScoreBoard&
  943. _PUTIMAGE (50, 550)-(170, 590), GunImg&(Gun.id - 1)
  944. _FONT Fonts.smaller
  945. _PRINTSTRING (40, 580), RTRIM$(Gun.NAME)
  946. _FONT Fonts.normal
  947.  
  948. IF randomLevels THEN _PRINTSTRING (CenterPrintX("Random Levels"), 560), "Random Levels" ELSE _PRINTSTRING (CenterPrintX("Stage " + STR$(LevelStage%)), 560), "Stage " + STR$(LevelStage%)
  949. _FONT Fonts.smaller
  950.  
  951. Minutes% = (Seconds% - (Seconds% MOD 60)) / 60
  952. t = Seconds% MOD 60
  953.  
  954. _PRINTSTRING (600, 560), "Score - " + STR$(CurrentScore%)
  955. _PRINTSTRING (600, 580), "Time Left -" + STR$(Minutes%) + ":" + STR$(t)
  956. StartLevel
  957.  
  958. FOR i = 1 TO Level.enemies 'free all the sound buffer stream (sound stream will reload again when next gameplay starts.
  959.     _SNDCLOSE Enemie(i).snd
  960.  
  961. COLOR _RGB(255, 255, 255), _RGBA(0, 0, 0, 0)
  962. 'checking if the level has benn canceled by the user.
  963. IF Level.cancel THEN
  964.     'free the level background image
  965.     _FREEIMAGE Level.bg
  966.     Level.cancel = 0
  967.     GOTO start
  968.  
  969. 'checking if game is completed
  970.  
  971. IF Level.completed THEN
  972.     ' IF COMMAND$(1) = "-loadlevel" THEN
  973.     ' echo "Level : " + STR$(LevelStage%)
  974.     ' echo "Time taken to complete : " + STR$(Level.time - Seconds%)
  975.     ' END IF
  976.  
  977.     _PUTIMAGE (0, 0)-(_WIDTH, _HEIGHT), Level.bg
  978.  
  979.     'crosfading start here -
  980.     DIM blured&
  981.  
  982.     blured& = _COPYIMAGE(Level.bg)
  983.     BLURIMAGE blured&, 5
  984.     FOR i = 1 TO 255 STEP 20
  985.         _SETALPHA i, , blured&
  986.         _PUTIMAGE , Level.bg
  987.         _PUTIMAGE , blured&
  988.         _DISPLAY
  989.     NEXT
  990.  
  991.     _FREEIMAGE blured&
  992.  
  993.     LINE (200, 200)-(_WIDTH - 200, _HEIGHT - 200), _RGBA(0, 0, 0, 180), BF
  994.     _FONT Fonts.normal
  995.     _PRINTSTRING (CenterPrintX("Stage " + STR$(LevelStage%) + "Completed!"), 210), "Stage " + STR$(LevelStage%) + " Completed"
  996.     _FONT Fonts.smaller
  997.     DIM a$
  998.     a$ = "Congratulations!! You created new high score!"
  999.  
  1000.     IF CurrentScore% > HighScore% THEN _PRINTSTRING (CenterPrintX(a$), 250), a$
  1001.  
  1002.     _PRINTSTRING (CenterPrintX("Score - " + STR$(CurrentScore%)), 300), "Score - " + STR$(CurrentScore%)
  1003.     _PRINTSTRING (CenterPrintX("Bonus Score - " + STR$(Seconds% * 2)), 320), "Bonus Score - " + STR$(Seconds% * 2)
  1004.     _PRINTSTRING (CenterPrintX("Total Score - " + STR$(Seconds% * 2 + CurrentScore%)), 340), "Total Score - " + STR$(Seconds% * 2 + CurrentScore%)
  1005.  
  1006.     IF LevelStage% = MAX_LEVEL THEN a$ = "Game Completed" ELSE a$ = "Be ready for next stage. Wait a moment..."
  1007.     _PRINTSTRING (CenterPrintX(a$), 380), a$
  1008.  
  1009.     DO
  1010.         IF F = 1 THEN SPRITESHOW ExplosionsZ(0).img: SPRITESHOW ExplosionsZ(1).img
  1011.         FOR i = 0 TO 1
  1012.             SPRITENEXT ExplosionsZ(i).img
  1013.             SPRITEPUT ExplosionsZ(i).x, ExplosionsZ(i).y, ExplosionsZ(i).img
  1014.         NEXT
  1015.         _LIMIT W.fps
  1016.         _DISPLAY
  1017.         F = F + 1
  1018.     LOOP UNTIL F > 180
  1019.     SPRITEHIDE ExplosionsZ(0).img
  1020.     SPRITEHIDE ExplosionsZ(1).img
  1021.    
  1022.     F = 0
  1023.     IF COMMAND$(1) = "-loadlevel" THEN SYSTEM
  1024.     SaveGame
  1025.  
  1026.     IF LevelStage% > MAX_LEVEL THEN
  1027.         bd& = _COPYIMAGE(0)
  1028.         FOR i = 0 TO 255 STEP 5
  1029.             _PUTIMAGE , bd&
  1030.             LINE (0, 0)-(_WIDTH, _HEIGHT), _RGBA(0, 0, 0, i), BF
  1031.             _DISPLAY
  1032.         NEXT
  1033.         showCredits
  1034.  
  1035.         GOTO start
  1036.     END IF
  1037.     'free the level background image
  1038.     _FREEIMAGE Level.bg
  1039.  
  1040.     GOTO newgame
  1041. IF Level.over THEN
  1042.     COLOR _RGB(255, 0, 0)
  1043.     ' IF COMMAND$(1) = "-loadlevel" THEN
  1044.     ' echo "Level failed to compete"
  1045.     ' END IF
  1046.  
  1047.     _PUTIMAGE (0, 0)-(_WIDTH, _HEIGHT), Level.bg
  1048.     'crosfading start here -
  1049.     blured& = _COPYIMAGE(Level.bg)
  1050.     BLURIMAGE blured&, 5
  1051.     FOR i = 1 TO 255 STEP 20
  1052.         _SETALPHA i, , blured&
  1053.         _PUTIMAGE , Level.bg
  1054.         _PUTIMAGE , blured&
  1055.         _DISPLAY
  1056.     NEXT
  1057.  
  1058.     _FREEIMAGE blured&
  1059.     LINE (200, 250)-(_WIDTH - 200, _HEIGHT - 250), _RGBA(0, 0, 0, 180), BF
  1060.     _FONT Fonts.bigger
  1061.     _PRINTSTRING (CenterPrintX("Game Over"), 260), "Game Over"
  1062.     _FONT Fonts.smaller
  1063.     _PRINTSTRING (CenterPrintX("Click To Continue..."), _HEIGHT - 280), "Click to Continue..."
  1064.     _DISPLAY
  1065.  
  1066.     DO
  1067.         WHILE _MOUSEINPUT: WEND
  1068.         IF _MOUSEBUTTON(1) THEN
  1069.             WHILE _MOUSEBUTTON(1): WHILE _MOUSEINPUT: WEND: WEND
  1070.             EXIT DO
  1071.         END IF
  1072.         _LIMIT 30
  1073.     LOOP
  1074.     GOTO start
  1075.     'free the level background image
  1076.     _FREEIMAGE Level.bg
  1077.  
  1078.  
  1079. 404
  1080. COLOR _RGB(255, 255, 255)
  1081. CIRCLE (_WIDTH / 2, 200), 100
  1082. CIRCLE (_WIDTH / 2 - 50, 150), 5
  1083. CIRCLE (_WIDTH / 2 + 50, 150), 5
  1084. CIRCLE (_WIDTH / 2, 250), 50, , 0, _PI
  1085.  
  1086. centerPrint "An Error has ocurred!", 350
  1087. centerPrint "Error Code - " + STR$(ERR), 366
  1088.     centerPrint "Error File - " + _INCLERRORFILE$, 382
  1089.     centerPrint "Error Line - " + STR$(_INCLERRORLINE), 398
  1090.     centerPrint "Error File - Main_File", 382
  1091.     centerPrint "Error Line - " + STR$(_ERRORLINE), 398
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099. SUB echo (m$) 'always write to console
  1100.     DIM preDest AS LONG
  1101.     preDest = _DEST
  1102.     PRINT m$
  1103.     _DEST preDest
  1104.  
  1105. SUB showNotification (message$)
  1106.     NText$ = message$
  1107.     NShow = -1
  1108.  
  1109. SUB Notify ()
  1110.     STATIC imgy
  1111.     IF NShow = -1 THEN
  1112.         IF NFPSCount% = 0 THEN
  1113.             _FONT 16
  1114.             DIM __w AS INTEGER, h AS INTEGER, tmp&, preDest AS LONG
  1115.             __w = LEN(NText$) * 8 + 40
  1116.             h = 36
  1117.  
  1118.             tmp& = _NEWIMAGE(__w, h, 32)
  1119.  
  1120.             preDest = _DEST
  1121.             _DEST tmp&
  1122.  
  1123.             COLOR _RGB(10, 10, 10), _RGB(355, 245, 245)
  1124.             CLS , _RGB(255, 245, 245)
  1125.             _PRINTSTRING (20, 10), NText$
  1126.  
  1127.             _DEST preDest
  1128.             NImage& = _COPYIMAGE(tmp&, 33)
  1129.             _FREEIMAGE tmp&
  1130.  
  1131.             imgy = -40
  1132.         END IF
  1133.         IF NFPSCount% > 0 AND NFPSCount% < 40 THEN
  1134.             imgy = imgy + 1
  1135.             _PUTIMAGE (_WIDTH / 2 - _WIDTH(NImage&) / 2, imgy), NImage&
  1136.         END IF
  1137.         IF NFPSCount% > 40 AND NFPSCount% < 160 THEN
  1138.             _PUTIMAGE (_WIDTH / 2 - _WIDTH(NImage&) / 2, imgy), NImage&
  1139.         END IF
  1140.         IF NFPSCount% > 160 AND NFPSCount% < 200 THEN
  1141.             _PUTIMAGE (_WIDTH / 2 - _WIDTH(NImage&) / 2, imgy), NImage&
  1142.             imgy = imgy - 1
  1143.         END IF
  1144.         NFPSCount% = NFPSCount% + 1
  1145.         IF NFPSCount% > 200 THEN
  1146.             _FREEIMAGE NImage&
  1147.             NFPSCount% = 0
  1148.             NShow = 0
  1149.         END IF
  1150.     END IF
  1151.  
  1152.  
  1153. SUB readConfig ()
  1154.     DIM F AS INTEGER
  1155.  
  1156.     IF NOT _FILEEXISTS("Settings/settings.dat") THEN writeConfig
  1157.     F = FREEFILE
  1158.     OPEN "Settings/settings.dat" FOR INPUT AS #F
  1159.     INPUT #F, W.fullscreen
  1160.     INPUT #F, W.music
  1161.     INPUT #F, W.sfx
  1162.     INPUT #F, W.musicV
  1163.     INPUT #F, W.sfxV
  1164.     INPUT #F, W.SE
  1165.     INPUT #F, W.fps
  1166.     CLOSE #F
  1167.  
  1168. SUB writeConfig ()
  1169.     DIM f AS INTEGER
  1170.  
  1171.     f = FREEFILE
  1172.     OPEN "Settings/settings.dat" FOR OUTPUT AS #f
  1173.     PRINT #f, W.fullscreen
  1174.     PRINT #f, W.music
  1175.     PRINT #f, W.sfx
  1176.     PRINT #f, W.musicV
  1177.     PRINT #f, W.sfxV
  1178.     PRINT #f, W.SE
  1179.     PRINT #f, W.fps
  1180.     CLOSE #f
  1181.  
  1182. SUB createConfig ()
  1183.     W.fullscreen = 0
  1184.     W.music = -1
  1185.     W.sfx = -1
  1186.     W.musicV = 1
  1187.     W.sfxV = 1
  1188.     W.SE = -1
  1189.     W.fps = 90
  1190.     writeConfig
  1191.  
  1192. SUB loadComponents ()
  1193.     IF W.fullscreen = 0 THEN
  1194.     ELSEIF W.fullscreen = 1 THEN
  1195.     ELSEIF W.fullscreen = 2 THEN
  1196.     END IF
  1197.  
  1198.     'SFXs
  1199.     ' screen_conf:
  1200.     IF Gun1& = 0 THEN Gun1& = _SNDOPEN("SFX/Gun1.ogg", "sync,vol,pause")
  1201.     IF Gun2& = 0 THEN Gun2& = _SNDOPEN("SFX/Gun2.ogg", "sync,vol,pause")
  1202.     IF Bird& = 0 THEN Bird& = _SNDOPEN("SFX/bird.ogg", "sync,vol,pause")
  1203.     IF Crow& = 0 THEN Crow& = _SNDOPEN("SFX/Crow.ogg", "sync,vol,pause")
  1204.     IF Eagle& = 0 THEN Eagle& = _SNDOPEN("SFX/Eagle.ogg", "sync,vol,pause")
  1205.     IF Expos& = 0 THEN Expos& = _SNDOPEN("SFX/Explosion.mp3", "sync,vol,pause")
  1206.     IF Jet& = 0 THEN Jet& = _SNDOPEN("SFX/Jet.ogg", "sync,vol,pause")
  1207.     IF RainSound& = 0 THEN RainSound& = _SNDOPEN("SFX/Rain.mp3", "vol,sync,pause")
  1208.  
  1209.     IF Musics&(0) = 0 THEN Musics&(0) = _SNDOPEN("Musics/Hunter's_Revenge-Against_Evil.mp3", "sync,vol,pause")
  1210.     IF Musics&(1) = 0 THEN Musics&(1) = _SNDOPEN("Musics/Hunter's_Revenge-End_Of_Game.mp3", "sync,vol,pause")
  1211.     IF Musics&(2) = 0 THEN Musics&(2) = _SNDOPEN("Musics/Hunter's_Revenge-Who's_Next.mp3", "sync,vol,pause")
  1212.  
  1213.     setMusicVol W.musicV
  1214.     IF NOT W.music THEN 'if menu background music disable, then stop the musics, regardless of whether the are being played or not.
  1215.         _SNDSTOP Musics&(0)
  1216.         _SNDSTOP Musics&(1)
  1217.         _SNDSTOP Musics&(2)
  1218.     END IF
  1219.  
  1220.     W.done = -1
  1221.  
  1222. SUB Splash ()
  1223.  
  1224.     CLS
  1225.  
  1226.     DIM stars&, x AS INTEGER, y AS INTEGER, F AS INTEGER
  1227.  
  1228.     stars& = _NEWIMAGE(_WIDTH * 2, _HEIGHT, 32)
  1229.     _DEST stars&
  1230.     DO
  1231.         x = INT(RND * _WIDTH(stars&))
  1232.         y = INT(RND * _HEIGHT)
  1233.         PSET (x, y), _RGB(255, 255, 255)
  1234.         F = F + 1
  1235.     LOOP UNTIL F > 700
  1236.  
  1237.     DIM spT&, sp&, eft1&, p AS INTEGER, a AS INTEGER, xx AS INTEGER
  1238.  
  1239.     _DEST 0
  1240.     spT& = _LOADIMAGE("Images\splash.png")
  1241.     _CLEARCOLOR _RGB(0, 0, 0), spT&
  1242.     sp& = _COPYIMAGE(spT&, 33)
  1243.     F = 0
  1244.     eft1& = _NEWIMAGE(_WIDTH, _HEIGHT, 32)
  1245.     _DEST eft1&
  1246.     LINE (0, 0)-(_WIDTH, _HEIGHT), _RGB(0, 0, 50), BF
  1247.     _DEST 0
  1248.  
  1249.     p = 6
  1250.     FPSStart
  1251.     DO
  1252.         _SETALPHA a, , eft1&: _PUTIMAGE , eft1&
  1253.         _PUTIMAGE (xx, 0), stars&
  1254.         _PUTIMAGE , sp&
  1255.         xx = xx - 1
  1256.         IF xx < -_WIDTH - 2 THEN xx = 0
  1257.         _LIMIT 60
  1258.         a = a + p
  1259.         IF a > 250 THEN p = -p
  1260.         IF a < 6 THEN p = 6
  1261.         _DISPLAY
  1262.         F% = F% + 1
  1263.         FPSCurrent% = FPSCurrent% + 1
  1264.     LOOP UNTIL F% > 360
  1265.  
  1266.     FPSEnd
  1267.     CLS
  1268.  
  1269.     _FREEIMAGE sp&
  1270.     _FREEIMAGE spT&
  1271.     _FREEIMAGE eft1&
  1272.     _FREEIMAGE stars&
  1273.  
  1274. SUB FPSStart ()
  1275.     ON TIMER(FPSEvent, 1) FPS
  1276.     ON TIMER(FPSEvt, 0.01) FPSShow
  1277.     TIMER(FPSEvent) ON
  1278.     TIMER(FPSEvt) ON
  1279.  
  1280. SUB FPS ()
  1281.     FPSRate% = FPSCurrent%
  1282.     FPSCurrent% = 0
  1283.  
  1284. SUB FPSShow ()
  1285.     COLOR _RGB(255, 255, 255)
  1286.     _PRINTSTRING (720, 0), STR$(FPSRate%) + " FPS"
  1287.  
  1288. SUB FPSEnd ()
  1289.     TIMER(FPSEvent) OFF
  1290.     TIMER(FPSEvt) OFF
  1291.  
  1292. SUB LoaderStart ()
  1293.     Loader& = _LOADIMAGE("Images\loader.gif", 33)
  1294.     LoaderEvt! = _FREETIMER
  1295.     ON TIMER(LoaderEvt!, 0.1) ShowLoader
  1296.     TIMER(LoaderEvt!) ON
  1297.  
  1298. SUB LoaderEnd ()
  1299.     TIMER(LoaderEvt!) OFF
  1300.     _FREEIMAGE Loader&
  1301.  
  1302. SUB ShowLoader ()
  1303.     IF LoaderCF% = 0 THEN LoaderCF% = 1
  1304.     _PUTIMAGE (LoaderX%, LoaderY%), Loader&, 0, (LoaderCF% * 48 - 48, 0)-(LoaderCF% * 48 - 1, 48)
  1305.     LoaderCF% = LoaderCF% + 1
  1306.     IF LoaderCF% > 8 THEN LoaderCF% = 1
  1307.     _DISPLAY
  1308.  
  1309. ' SUB PlayMovie (m$)
  1310. ' LoaderStart
  1311.  
  1312. ' DIM f AS INTEGER, n AS LONG, i AS LONG, k AS INTEGER
  1313.  
  1314. ' f = FREEFILE
  1315. ' OPEN "Movies\" + m$ + "\" + m$ + ".txt" FOR INPUT AS #f
  1316. ' INPUT #f, n
  1317. ' CLOSE #f
  1318. ' DIM Temps_Buffers&(n)
  1319. ' FOR i = 1 TO n
  1320. ' Temps_Buffers&(i) = _LOADIMAGE("Movies\" + m$ + "\produce" + LTRIM$(RTRIM$(STR$(i))) + ".jpg", 33)
  1321. ' NEXT
  1322. ' LoaderEnd
  1323. ' FOR i = 1 TO n
  1324. ' FOR k = 1 TO 3
  1325. ' _PUTIMAGE , Temps_Buffers&(i)
  1326. ' _DISPLAY
  1327. ' NEXT
  1328. ' _DELAY .05
  1329. ' _FREEIMAGE Temps_Buffers&(i)
  1330. ' NEXT
  1331. ' ERASE Temps_Buffers&
  1332. ' END SUB
  1333.  
  1334. SUB GameMenu ()
  1335.     _PUTIMAGE , Menubg&
  1336.     DIM n%
  1337.     'Menu background music
  1338.     IF W.music THEN
  1339.         n% = p5random(0, 2)
  1340.         IF NOT (_SNDPLAYING(Musics&(0)) OR _SNDPLAYING(Musics&(1)) OR _SNDPLAYING(Musics&(2))) THEN _SNDPLAY Musics&(n%)
  1341.     END IF
  1342.  
  1343.     ON TIMER(GlobalEvent, 0.01) GameMenu2
  1344.     TIMER(GlobalEvent) ON
  1345.     DO
  1346.         WHILE _MOUSEINPUT: WEND
  1347.         Mouse.x = _MOUSEX: Mouse.y = _MOUSEY
  1348.         Mouse.lclick = _MOUSEBUTTON(1)
  1349.         _LIMIT W.fps
  1350.         IF MenuChoice > 0 THEN EXIT DO
  1351.     LOOP
  1352.     TIMER(GlobalEvent) OFF
  1353.  
  1354. SUB GameMenu2 ()
  1355.  
  1356.     _PUTIMAGE , Menubg&
  1357.     LINE (200, 130)-(_WIDTH - 200, 450), _RGBA(0, 0, 0, 150), BF
  1358.  
  1359.     DIM i AS INTEGER
  1360.  
  1361.     FOR i = 0 TO 4
  1362.         COLOR _RGB(255, 255, 255), _RGBA(0, 0, 0, 0)
  1363.         IF Mouse.x > 200 AND Mouse.x < 600 AND Mouse.y > GameMenus(i).y - 20 AND Mouse.y < GameMenus(i).y + _FONTHEIGHT(Fonts.bigger) THEN
  1364.             LINE (200, GameMenus(i).y - 20)-(600, GameMenus(i).y + _FONTHEIGHT(Fonts.bigger)), _RGBA(255, 100, 0, 100), BF
  1365.             SPRITEPUT 150, GameMenus(i).y + 20, MenuBlood%
  1366.             SPRITENEXT MenuBlood%
  1367.             '       _PRINTSTRING (GameMenus(i).x, GameMenus(i).y), RTRIM$(GameMenus(i).text)
  1368.             _PUTIMAGE (200, GameMenus(i).y), GameMenus(i).img
  1369.             IF Mouse.lclick THEN
  1370.                 TIMER(GlobalEvent!) OFF
  1371.                 SELECT CASE i
  1372.                     CASE 0
  1373.                         MenuChoice = 1
  1374.                     CASE 1
  1375.                         MenuChoice = 2
  1376.                     CASE 2
  1377.                         MenuChoice = 3
  1378.                     CASE 3
  1379.                         MenuChoice = 4
  1380.                     CASE 4
  1381.                         MenuChoice = 5
  1382.  
  1383.                 END SELECT
  1384.             END IF
  1385.         ELSE
  1386.             '      _PRINTSTRING (GameMenus(i).x, GameMenus(i).y), RTRIM$(GameMenus(i).text)
  1387.             _PUTIMAGE (200, GameMenus(i).y), GameMenus(i).img
  1388.         END IF
  1389.     NEXT
  1390.     IF Mouse.hovering THEN
  1391.         _PUTIMAGE (Mouse.x - 16, Mouse.y - 16), Mouse.cursor2
  1392.         _DISPLAY
  1393.     ELSE
  1394.         _PUTIMAGE (Mouse.x - 16, Mouse.y - 16), Mouse.cursor
  1395.         _DISPLAY
  1396.     END IF
  1397.  
  1398.  
  1399.  
  1400. FUNCTION CenterPrintX (m$)
  1401.     DIM i AS INTEGER, a AS INTEGER
  1402.     FOR i = 1 TO LEN(m$)
  1403.         a = a + _PRINTWIDTH(MID$(m$, i, 1))
  1404.     NEXT
  1405.     CenterPrintX = (_WIDTH / 2) - (a / 2)
  1406.  
  1407. FUNCTION getCurrentLevel% ()
  1408.     IF NOT _FILEEXISTS("Save_Game/save.dat") THEN getCurrentLevel% = 1: EXIT FUNCTION
  1409.     DIM F AS INTEGER
  1410.     F = FREEFILE
  1411.     OPEN "Save_Game\save.dat" FOR BINARY AS #F
  1412.     SEEK F, 3
  1413.     GET #F, , getCurrentLevel%
  1414.     CLOSE #F
  1415.  
  1416. SUB LoadLevel ()
  1417.     Level.completed = 0
  1418.     Level.over = 0
  1419.     DIM F AS INTEGER
  1420.     F = FREEFILE
  1421.     ' IF COMMAND$(1) = "-loadlevel" THEN
  1422.     ' GOTO skip_game_save_info
  1423.     ' END IF
  1424.     IF NOT _FILEEXISTS("Save_Game\save.dat") THEN
  1425.         OPEN "Save_Game\save.dat" FOR BINARY AS #F
  1426.         LevelStage% = 1
  1427.         HighScore% = 0
  1428.         PUT #F, , HighScore%
  1429.         PUT #F, , LevelStage%
  1430.         CLOSE #F
  1431.     ELSE
  1432.         OPEN "Save_Game\save.dat" FOR BINARY AS #F
  1433.         GET #F, , HighScore%
  1434.         GET #F, , LevelStage%
  1435.         CLOSE #F
  1436.     END IF
  1437.     skip_game_save_info:::
  1438.     ' echo "loading level/stage : " + STR$(LevelStage%)
  1439.     OPEN "Stages\Stage" + RTRIM$(LTRIM$(STR$(LevelStage%))) + ".dat" FOR INPUT AS #F
  1440.     INPUT #F, Level.enemies
  1441.     INPUT #F, Level.scenes
  1442.     INPUT #F, Level.time
  1443.     INPUT #F, Level.mode
  1444.     INPUT #F, Level.background
  1445.     CLOSE #F
  1446.     LevelStage2% = LevelStage%
  1447.     Level.bg = _LOADIMAGE("Images\" + RTRIM$(Level.background))
  1448.     Seconds% = Level.time
  1449.     OldSeconds% = Seconds%
  1450.     'LevelStage% = clevel%
  1451.  
  1452. SUB StartLevel ()
  1453.  
  1454.     'Stop music during gameplay
  1455.     DIM i AS INTEGER, k&, onn&, offf&, bd&, bd2&, ac&, gfx&
  1456.     IF W.music THEN
  1457.         FOR i = 0 TO 2
  1458.             _SNDSTOP Musics&(i)
  1459.         NEXT 'stops all musics
  1460.     END IF
  1461.     IF W.sfx THEN updateSfxVolume
  1462.  
  1463.     ON TIMER(GameRenderingEvent, 1 / W.fps) UpdateStatus
  1464.     ON TIMER(TimerEvent, 1) UpdateTime
  1465.     TIMER(GameRenderingEvent) ON
  1466.     TIMER(TimerEvent) ON
  1467.     Mouse.lclick = 0
  1468.     Mouse.rclick = 0
  1469.     Mouse.mclick = 0
  1470.     DO
  1471.         WHILE _MOUSEINPUT: WEND
  1472.  
  1473.         Mouse.x = _MOUSEX: Mouse.y = _MOUSEY
  1474.         IF _MOUSEBUTTON(1) THEN
  1475.             WHILE _MOUSEBUTTON(1): WHILE _MOUSEINPUT: WEND: WEND
  1476.             Mouse.lclick = -1
  1477.         END IF
  1478.         IF _MOUSEBUTTON(2) THEN
  1479.             WHILE _MOUSEBUTTON(2): WHILE _MOUSEINPUT: WEND: WEND
  1480.             Mouse.rclick = -1
  1481.         END IF
  1482.         IF _MOUSEBUTTON(3) THEN
  1483.             WHILE _MOUSEBUTTON(3): WHILE _MOUSEINPUT: WEND: WEND
  1484.             Mouse.mclick = -1
  1485.         ELSE Mouse.mclick = 0
  1486.         END IF
  1487.  
  1488.         k& = _KEYHIT
  1489.         IF k& = 27 OR Mouse.mclick THEN
  1490.             TIMER(GameRenderingEvent) OFF
  1491.             TIMER(TimerEvent) OFF
  1492.             IF W.sfx THEN PauseSound 'Pause the sounds
  1493.  
  1494.             onn& = _LOADIMAGE("Images/on.png", 33)
  1495.             offf& = _LOADIMAGE("Images/off.png", 33)
  1496.  
  1497.             bd& = _COPYIMAGE(0)
  1498.             bd2& = _COPYIMAGE(0)
  1499.  
  1500.             BLURIMAGE bd2&, 5
  1501.             gfx& = _NEWIMAGE(500, 156, 32)
  1502.             _DEST gfx&
  1503.             CLS , 0 'make it transparent
  1504.             LINE (0, 0)-STEP(_WIDTH, _HEIGHT), _RGBA(0, 0, 0, 150), BF
  1505.             FOR i = 16 TO 19
  1506.                 _PUTIMAGE (0, GameMenus(i).y - 222), GameMenus(i).img2
  1507.             NEXT
  1508.             _DEST 0
  1509.  
  1510.             FOR i = 0 TO 255 STEP 10
  1511.                 _SETALPHA i, , bd2&
  1512.                 _PUTIMAGE , bd&
  1513.                 _PUTIMAGE , bd2&
  1514.                 LINE (0, 0)-(_WIDTH, _HEIGHT), _RGBA(0, 0, 0, i / 3), BF
  1515.                 _PUTIMAGE (150, 222), gfx&, 0, (0, 0)-(500, p5map(i, 0, 255, 0, 136))
  1516.                 _DISPLAY
  1517.             NEXT
  1518.             ac& = _COPYIMAGE(0)
  1519.             DO
  1520.                 WHILE _MOUSEINPUT: WEND
  1521.                 Mouse.x = _MOUSEX: Mouse.y = _MOUSEY
  1522.                 Mouse.lclick = 0
  1523.                 Mouse.rclick = 0
  1524.                 IF _MOUSEBUTTON(1) THEN
  1525.                     WHILE _MOUSEBUTTON(1): WHILE _MOUSEINPUT: WEND: WEND
  1526.                     Mouse.lclick = -1
  1527.                 END IF
  1528.                 IF _MOUSEBUTTON(2) THEN
  1529.                     WHILE _MOUSEBUTTON(2): WHILE _MOUSEINPUT: WEND: WEND
  1530.                     Mouse.rclick = -1
  1531.                 END IF
  1532.  
  1533.                 _PUTIMAGE , ac&
  1534.                 LINE (150, 222)-STEP(500, 136), _RGBA(0, 0, 0, 50), BF
  1535.                 FOR i = 16 TO 19
  1536.                     IF Mouse.x > 150 AND Mouse.x < 650 AND Mouse.y > GameMenus(i).y - 10 AND Mouse.y < GameMenus(i).y + 24 THEN
  1537.                         IF Mouse.lclick THEN
  1538.                             SELECT CASE i
  1539.                                 CASE 16
  1540.                                     IF W.fullscreen > 0 THEN W.fullscreen = 0 ELSE W.fullscreen = 1
  1541.                                 CASE 17
  1542.                                     W.musicV = W.musicV + .1
  1543.                                     IF W.musicV > 1 THEN W.musicV = .1
  1544.                                 CASE 18
  1545.                                     W.sfxV = W.sfxV + .1
  1546.                                     IF W.sfxV > 1 THEN W.sfxV = .1
  1547.                                 CASE 19
  1548.                                     Level.cancel = -1
  1549.                                     EXIT DO
  1550.                             END SELECT
  1551.                         END IF
  1552.                         LINE (150, GameMenus(i).y - 10)-(650, GameMenus(i).y + 24), _RGBA(255, 100, 0, 100), BF
  1553.                     END IF
  1554.                     _PUTIMAGE (150, GameMenus(i).y), GameMenus(i).img
  1555.                     SELECT CASE i
  1556.                         CASE 16
  1557.                             IF W.fullscreen > 0 THEN _PUTIMAGE (580, GameMenus(i).y - 3), onn& ELSE _PUTIMAGE (580, GameMenus(i).y - 3), offf&
  1558.                         CASE 17
  1559.                             _FONT Fonts.normal
  1560.                             IF W.musicV > .9 THEN
  1561.                                 _PRINTSTRING (630 - txtWidth(" 10"), GameMenus(i).y), " 10 "
  1562.                             ELSE
  1563.                                 _PRINTSTRING (630 - txtWidth(STR$(INT(W.musicV * 10))), GameMenus(i).y), STR$(INT(W.musicV * 10))
  1564.                             END IF
  1565.                         CASE 18
  1566.                             _FONT Fonts.normal
  1567.                             IF W.sfxV > .9 THEN
  1568.                                 _PRINTSTRING (630 - txtWidth(" 10"), GameMenus(i).y), " 10 "
  1569.                             ELSE
  1570.                                 _PRINTSTRING (630 - txtWidth(STR$(INT(W.sfxV * 10))), GameMenus(i).y), STR$(INT(W.sfxV * 10))
  1571.                             END IF
  1572.                     END SELECT
  1573.                 NEXT
  1574.                 IF _KEYHIT = 27 OR _MOUSEBUTTON(3) THEN EXIT DO
  1575.                 _LIMIT W.fps
  1576.                 _PUTIMAGE (Mouse.x - 8, Mouse.y - 8), Mouse.cursor
  1577.                 _DISPLAY
  1578.             LOOP
  1579.             FOR i = 255 TO 0 STEP -10
  1580.                 _SETALPHA i, , bd2&
  1581.                 _PUTIMAGE , bd&
  1582.                 _PUTIMAGE , bd2&
  1583.                 LINE (0, 0)-(_WIDTH, _HEIGHT), _RGBA(0, 0, 0, i / 3), BF
  1584.                 _PUTIMAGE (150, 222), gfx&, 0, (0, 0)-(500, p5map(i, 0, 255, 0, 222))
  1585.                 _DISPLAY
  1586.             NEXT
  1587.  
  1588.             _PUTIMAGE , bd& 'Erase that menu line
  1589.             _FREEIMAGE bd&
  1590.             _FREEIMAGE bd2&
  1591.             _FREEIMAGE ac&
  1592.             _FREEIMAGE gfx&
  1593.             _FREEIMAGE onn&
  1594.             _FREEIMAGE offf&
  1595.             loadComponents
  1596.  
  1597.             IF W.sfx THEN 'update the sfx volume and play the paused sound.
  1598.                 updateSfxVolume
  1599.                 IF NOT Level.cancel THEN PlayPausedSound
  1600.             END IF
  1601.  
  1602.             TIMER(GameRenderingEvent) ON
  1603.             TIMER(TimerEvent) ON
  1604.  
  1605.             IF Level.cancel THEN EXIT DO
  1606.         END IF
  1607.         _LIMIT W.fps
  1608.     LOOP UNTIL Level.completed OR Level.over
  1609.     TIMER(GameRenderingEvent) OFF
  1610.     CloseTime
  1611.     FOR i = 0 TO 20
  1612.         IF Bloods(i).active THEN
  1613.             Bloods(i).active = 0
  1614.             SPRITEHIDE Bloods(i).img
  1615.         END IF
  1616.         IF explosions(i).active THEN
  1617.             explosions(i).active = 0
  1618.             SPRITEHIDE explosions(i).img
  1619.         END IF
  1620.     NEXT
  1621.     FOR i = 0 TO UBOUND(ShotScore)
  1622.         ShotScore(i).active = 0
  1623.     NEXT
  1624.  
  1625. SUB UpdateStatus ()
  1626.     ' $checking:off
  1627.     STATIC thunder_f_count, thunder_ha_count, thunder_ha_count_limit
  1628.     DIM i AS INTEGER, t AS INTEGER, tmp&, tmp2&
  1629.  
  1630.     IF Seconds% < OldSeconds% OR OldScore% < CurrentScore% THEN _PUTIMAGE (0, 0)-(_WIDTH, _HEIGHT), Level.bg
  1631.  
  1632.     FOR i = 1 TO Level.enemies
  1633.         IF Enemie(i).u = Level.u AND Enemie(i).active = 0 AND Enemie(i).scene = Level.currentScene THEN
  1634.             Enemie(i).active = -1
  1635.             PlayEnemieMusic i
  1636.             'echo "[New Enemie] (Scene " + STR$(Level.currentScene) + ")"
  1637.             'echo "Type : " + Enemie(i).typ
  1638.             'echo "u : " + STR$(Enemie(i).u)
  1639.             'echo "Current u : " + STR$(Enemie(i).u)
  1640.             'echo " Enemie Scene : " + STR$(Enemie(i).scene)
  1641.             'echo "Enemie Movement : " + STR$(Enemie(i).m)
  1642.         END IF
  1643.     NEXT
  1644.     FOR i = 1 TO Level.enemies
  1645.         IF Enemie(i).active AND Enemie(i).scene = Level.currentScene THEN
  1646.             'IF Enemie(i).u = Level.u THEN
  1647.             '    echo "Rendered"
  1648.             '    echo "********************************************************************************"
  1649.             'END IF
  1650.             IF Enemie(i).f > Enemie(i).n THEN SPRITENEXT Enemie(i).img: Enemie(i).f = 0
  1651.  
  1652.             SPRITEPUT Enemie(i).x, Enemie(i).y, Enemie(i).img
  1653.  
  1654.             Enemie(i).x = Enemie(i).x + Enemie(i).m
  1655.             Enemie(i).f = Enemie(i).f + 1
  1656.  
  1657.             IF W.SE THEN _SNDBAL Enemie(i).snd, p5map(Enemie(i).x, 0, _WIDTH, -1, 1), p5map(Enemie(i).y, 0, _HEIGHT, 1, -1), , 2
  1658.  
  1659.             IF Enemie(i).x > _WIDTH + SPRITECURRENTWIDTH(Enemie(i).img) THEN Enemie(i).m = -Enemie(i).m: SPRITEFLIP Enemie(i).img, HORIZONTAL: PlayEnemieMusic i
  1660.             IF Enemie(i).x < -SPRITECURRENTWIDTH(Enemie(i).img) THEN Enemie(i).m = -Enemie(i).m: SPRITEFLIP Enemie(i).img, NONE: PlayEnemieMusic i
  1661.  
  1662.             IF Mouse.x > SPRITEX1(Enemie(i).img) AND Mouse.x < SPRITEX2(Enemie(i).img) AND Mouse.y > SPRITEY1(Enemie(i).img) AND Mouse.y < SPRITEY2(Enemie(i).img) THEN
  1663.                 Mouse.hovering = -1
  1664.  
  1665.                 IF Mouse.lclick THEN Enemie(i).life = Enemie(i).life - Gun.damage
  1666.                 IF Enemie(i).life < 0 THEN Enemie(i).life = 0
  1667.  
  1668.                 'Showing Enemie current life with life bar
  1669.                 IF Enemie(i).life = 0 THEN
  1670.                     _PUTIMAGE (Enemie(i).x - SPRITECURRENTWIDTH(Enemie(i).img) / 2, Enemie(i).y - 30), lifeBars(0)
  1671.                 ELSE
  1672.                     _PUTIMAGE (Enemie(i).x - SPRITECURRENTWIDTH(Enemie(i).img) / 2, Enemie(i).y - 30), lifeBars(INT(Enemie(i).life / Enemie(i).life2 * 100) - 1) 'shows life bar :)
  1673.                 END IF
  1674.             END IF
  1675.             'checking if any enemie is dead :D
  1676.             IF Enemie(i).life = 0 THEN
  1677.                 SPRITEHIDE Enemie(i).img
  1678.                 Enemie(i).ending = -1
  1679.                 Enemie(i).active = 0
  1680.                 StopEnemieMusic i
  1681.                 'echo "[Enemie Dead]"
  1682.                 'echo "Type : " + Enemie(i).typ
  1683.                 'echo "Enemie Scene" + STR$(Enemie(i).scene)
  1684.                 'echo "--------------------------------------------------------------------------------------"
  1685.                 'You will get more score with ShotGun :P
  1686.  
  1687.                 IF Gun.id = 1 THEN CurrentScore% = CurrentScore% + INT(Enemie(i).points * 1.4)
  1688.  
  1689.                 MakeScoreFlash Enemie(i).x, Enemie(i).y, Enemie(i).points
  1690.                 CurrentScore% = CurrentScore% + Enemie(i).points
  1691.                 MakeBloods Enemie(i).x, Enemie(i).y, Enemie(i).typ
  1692.             END IF
  1693.         END IF
  1694.     NEXT
  1695.  
  1696.     IF Mouse.rclick THEN
  1697.         IF Gun.id = 1 THEN Gun.id = 2: Gun.NAME = "Ak-47": Gun.damage = 6 ELSE Gun.id = 1: Gun.NAME = "Shot Gun": Gun.damage = 3
  1698.         Mouse.rclick = 0
  1699.     END IF
  1700.     FOR i = 0 TO 20
  1701.         IF Bloods(i).active THEN
  1702.             IF Bloods(i).f > Bloods(i).n THEN SPRITENEXT Bloods(i).img: Bloods(i).f = 0: Bloods(i).currentFrame = Bloods(i).currentFrame + 1
  1703.             Bloods(i).f = Bloods(i).f + 1
  1704.             SPRITEPUT Bloods(i).x, Bloods(i).y, Bloods(i).img
  1705.             IF Bloods(i).currentFrame > Bloods(i).totalFrames * 2 THEN Bloods(i).active = 0: SPRITEHIDE Bloods(i).img
  1706.         END IF
  1707.     NEXT
  1708.     FOR i = 0 TO 20
  1709.         IF explosions(i).active THEN
  1710.             IF explosions(i).f > explosions(i).n THEN SPRITENEXT explosions(i).img: explosions(i).f = 0: explosions(i).currentFrame = explosions(i).currentFrame + 1
  1711.             explosions(i).f = explosions(i).f + 1
  1712.             SPRITEPUT explosions(i).x, explosions(i).y, explosions(i).img
  1713.             IF explosions(i).currentFrame > explosions(i).totalFrames THEN explosions(i).active = 0: SPRITEHIDE explosions(i).img
  1714.         END IF
  1715.     NEXT
  1716.  
  1717.     IF Seconds% < OldSeconds% OR OldScore% < CurrentScore% THEN
  1718.         IF Seconds% < 1 THEN Level.over = -1
  1719.         OldSeconds% = Seconds%
  1720.         OldScore% = CurrentScore%
  1721.         IF Seconds% < 11 THEN COLOR _RGB(255, 0, 0) ELSE COLOR _RGB(255, 255, 255)
  1722.         'redraw scoreboard
  1723.         _PUTIMAGE (0, 520), ScoreBoard&
  1724.         _PUTIMAGE (50, 550)-(170, 590), GunImg&(Gun.id - 1)
  1725.         _FONT Fonts.smaller
  1726.         _PRINTSTRING (40, 580), RTRIM$(Gun.NAME)
  1727.         _PRINTSTRING (600, 560), "Score - " + STR$(CurrentScore%)
  1728.         IF Seconds% >= 60 THEN t = Seconds% MOD 60 ELSE t = Seconds%
  1729.         _PRINTSTRING (600, 580), "Time left - " + STR$(Minutes%) + ":" + STR$(t)
  1730.         _FONT Fonts.normal
  1731.         IF randomLevels THEN _PRINTSTRING (CenterPrintX("Random Levels"), 560), "Random Levels" ELSE _PRINTSTRING (CenterPrintX("Stage " + STR$(LevelStage%)), 560), "Stage " + STR$(LevelStage%)
  1732.  
  1733.     END IF
  1734.  
  1735.     Level.u = Level.u + 1
  1736.     'creating new game scene
  1737.     IF SceneEnd(Level.currentScene) THEN
  1738.         Level.currentScene = Level.currentScene + 1
  1739.         Level.u = 0
  1740.         'echo "Current Scene : " + STR$(Level.currentScene)
  1741.         IF Level.currentScene > Level.scenes THEN Level.completed = -1
  1742.     END IF
  1743.  
  1744.     'game MODS
  1745.     SELECT CASE Level.mode
  1746.         CASE FOGMODE
  1747.             Fogs.x = Fogs.x - Fogs.move
  1748.             IF Fogs.x < -1600 OR Fogs.x > 0 THEN Fogs.move = -Fogs.move
  1749.             _PUTIMAGE (Fogs.x, 0), Fogs.handle
  1750.  
  1751.         CASE THUNDERMODE
  1752.             FallDrops
  1753.             DrawDrops
  1754.  
  1755.         CASE STORMMODE
  1756.             _PUTIMAGE (StormX%, 0), StormImg&
  1757.             StormX% = StormX% - 1
  1758.             IF StormX% < -2300 THEN StormX% = 0
  1759.  
  1760.         CASE FOGMODE + THUNDERMODE
  1761.             Fogs.x = Fogs.x - Fogs.move
  1762.             IF Fogs.x < -1600 OR Fogs.x > 0 THEN Fogs.move = -Fogs.move
  1763.             _PUTIMAGE (Fogs.x, 0), Fogs.handle
  1764.  
  1765.             FallDrops
  1766.             DrawDrops
  1767.  
  1768.         CASE FOGMODE + THUNDERMODE + 7
  1769.             Fogs.x = Fogs.x - Fogs.move
  1770.             IF Fogs.x < -1600 OR Fogs.x > 0 THEN Fogs.move = -Fogs.move
  1771.             _PUTIMAGE (Fogs.x, 0), Fogs.handle
  1772.  
  1773.             FallDrops
  1774.             DrawDrops
  1775.         CASE STORMMODE + THUNDERMODE
  1776.             _PUTIMAGE (StormX%, 0), StormImg&
  1777.             StormX% = StormX% - 1
  1778.             IF StormX% < -2300 THEN StormX% = 0
  1779.  
  1780.             FallDrops
  1781.             DrawDrops
  1782.  
  1783.         CASE STORMMODE + FOGMODE + THUNDERMODE
  1784.             Fogs.x = Fogs.x - Fogs.move
  1785.             IF Fogs.x < -1600 OR Fogs.x > 0 THEN Fogs.move = -Fogs.move
  1786.             _PUTIMAGE (Fogs.x, 0), Fogs.handle
  1787.  
  1788.             _PUTIMAGE (StormX%, 0), StormImg&
  1789.             StormX% = StormX% - 1
  1790.             IF StormX% < -2300 THEN StormX% =