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

0 Members and 1 Guest are viewing this topic.

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
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% = 0
  1791.  
  1792.             FallDrops
  1793.             DrawDrops
  1794.  
  1795.     END SELECT
  1796.  
  1797.     'scores effect
  1798.     FOR i = 0 TO UBOUND(ShotScore)
  1799.         IF ShotScore(i).active = -1 THEN
  1800.             ShotScore(i).sclX = SIN(ShotScore(i).__ops) * .5 + .5
  1801.             _PUTIMAGE (ShotScore(i).x - (ShotScore(i).sclX * _WIDTH(ShotScore(i).img) / 2), ShotScore(i).y - (ShotScore(i).sclX * _HEIGHT(ShotScore(i).img)) / 2)-(ShotScore(i).x + (ShotScore(i).sclX * _WIDTH(ShotScore(i).img)) / 2, ShotScore(i).y + (ShotScore(i).sclX * _HEIGHT(ShotScore(i).img)) / 2), ShotScore(i).img
  1802.             ShotScore(i).__ops = ShotScore(i).__ops + .1
  1803.             IF ShotScore(i).__ops > _PI(1.5) THEN
  1804.                 ShotScore(i).active = 0
  1805.             END IF
  1806.         END IF
  1807.     NEXT
  1808.  
  1809.     'countdown when game time is less or equal to 10s
  1810.     IF Seconds% < 11 THEN
  1811.         COLOR _RGB(255, 0, 0)
  1812.         _FONT Fonts.biggest
  1813.         _PRINTSTRING (CenterPrintX(RTRIM$(LTRIM$(STR$(Seconds%)))), _HEIGHT / 2 - _FONTHEIGHT / 2), RTRIM$(LTRIM$(STR$(Seconds%)))
  1814.     END IF
  1815.  
  1816.     'cursors
  1817.     IF Mouse.lclick THEN
  1818.         Mouse.lclick = 0
  1819.         IF W.sfx THEN
  1820.             IF Gun.id = 1 THEN _SNDPLAYCOPY Gun1& ELSE _SNDPLAYCOPY Gun2&
  1821.         END IF
  1822.     END IF
  1823.     IF Mouse.hovering THEN
  1824.         Mouse.hovering = 0
  1825.         _PUTIMAGE (Mouse.x - 16, Mouse.y - 16), Mouse.cursor2
  1826.     ELSE
  1827.         _PUTIMAGE (Mouse.x - 16, Mouse.y - 16), Mouse.cursor
  1828.     END IF
  1829.  
  1830.     IF Level.mode = THUNDERMODE OR Level.mode = THUNDERMODE + FOGMODE + 7 THEN
  1831.         IF thunder_ha_count_limit = 0 THEN thunder_ha_count_limit = p5random(1, 4)
  1832.         IF ThunderEvent = 0 THEN ThunderEvent = p5random(30, 340)
  1833.         ThunderCount = ThunderCount + 1
  1834.         IF ThunderCount > ThunderEvent THEN
  1835.             thunder_f_count = thunder_f_count + 1
  1836.             tmp& = _COPYIMAGE(0)
  1837.             tmp2& = _COPYIMAGE(0)
  1838.             MakeThunderImage tmp&
  1839.             _PUTIMAGE , tmp&
  1840.             _DISPLAY
  1841.             _PUTIMAGE , tmp2&
  1842.             _FREEIMAGE tmp&
  1843.             _FREEIMAGE tmp2&
  1844.             IF thunder_f_count > 3 THEN
  1845.                 IF thunder_ha_count < thunder_ha_count_limit THEN
  1846.                     ' ThunderCount = 0
  1847.                     thunder_f_count = 0
  1848.                     ThunderEvent = ThunderEvent + p5random(4, 25) + 3
  1849.                     thunder_ha_count = thunder_ha_count + 1
  1850.                 ELSE
  1851.                     thunder_ha_count = 0
  1852.                     thunder_f_count = 0
  1853.                     ThunderEvent = 0
  1854.                     ThunderCount = 0
  1855.                     thunder_ha_count_limit = p5random(1, 4)
  1856.                 END IF
  1857.             END IF
  1858.         ELSE
  1859.             _DISPLAY
  1860.         END IF
  1861.     ELSE
  1862.         _DISPLAY
  1863.     END IF
  1864.     ' $checking:on
  1865.  
  1866. SUB MakeBloods (x, y, typ AS STRING * 16)
  1867.     SELECT CASE RTRIM$(typ)
  1868.         CASE "jet1", "jet2", "jet3"
  1869.             MakeExplosions x, y
  1870.             EXIT SUB
  1871.     END SELECT
  1872.     DIM i AS INTEGER
  1873.     FOR i = 0 TO 20
  1874.         IF Bloods(i).active = 0 THEN
  1875.             Bloods(i).active = -1
  1876.             Bloods(i).x = x
  1877.             Bloods(i).y = y
  1878.             Bloods(i).currentFrame = 1
  1879.             SPRITESHOW Bloods(i).img
  1880.             EXIT SUB
  1881.         END IF
  1882.     NEXT
  1883.  
  1884. SUB MakeExplosions (x, y)
  1885.     DIM i AS INTEGER
  1886.     FOR i = 0 TO 20
  1887.         IF explosions(i).active = 0 THEN
  1888.             explosions(i).active = -1
  1889.             explosions(i).x = x
  1890.             explosions(i).y = y
  1891.             explosions(i).currentFrame = 1
  1892.             SPRITESHOW explosions(i).img
  1893.             IF W.sfx THEN _SNDPLAY Expos&
  1894.             EXIT SUB
  1895.         END IF
  1896.     NEXT
  1897.  
  1898. SUB MakeScoreFlash (x, y, s)
  1899.     DIM i AS INTEGER
  1900.     FOR i = 0 TO UBOUND(ShotScore)
  1901.         IF ShotScore(i).active = 0 THEN
  1902.             ShotScore(i).active = -1
  1903.             ShotScore(i).x = x
  1904.             ShotScore(i).y = y
  1905.             ShotScore(i).__ops = -_PI(.5)
  1906.             SELECT CASE s
  1907.                 CASE 10
  1908.                     ShotScore(i).img = scoresImage(0)
  1909.                 CASE 20
  1910.                     ShotScore(i).img = scoresImage(1)
  1911.                 CASE 35
  1912.                     ShotScore(i).img = scoresImage(2)
  1913.                 CASE 50
  1914.                     ShotScore(i).img = scoresImage(3)
  1915.                 CASE 75
  1916.                     ShotScore(i).img = scoresImage(4)
  1917.                 CASE 100
  1918.                     ShotScore(i).img = scoresImage(5)
  1919.             END SELECT
  1920.         END IF
  1921.     NEXT
  1922.  
  1923. SUB UpdateTime ()
  1924.     Seconds% = Seconds% - 1
  1925.     Minutes% = (Seconds% - (Seconds% MOD 60)) / 60
  1926.  
  1927. SUB CloseTime
  1928.     TIMER(TimerEvent) OFF
  1929.  
  1930. SUB PlayEnemieMusic (which&)
  1931.     IF W.sfx = 0 THEN EXIT SUB
  1932.  
  1933.     _SNDPLAY Enemie(which&).snd
  1934.  
  1935. SUB StopEnemieMusic (which&)
  1936.     _SNDSTOP Enemie(which&).snd
  1937.     Enemie(which&).sndPaused = 2 '2 for stop and 1 for paused
  1938.  
  1939. SUB updateSfxVolume ()
  1940.     IF NOT W.sfx THEN EXIT SUB
  1941.  
  1942.     DIM i AS INTEGER
  1943.     FOR i = 1 TO Level.enemies
  1944.         _SNDVOL Enemie(i).snd, W.sfxV
  1945.     NEXT
  1946.     _SNDVOL RainSound&, W.sfxV
  1947.  
  1948. SUB setMusicVol (v!)
  1949.     IF NOT W.music THEN EXIT SUB
  1950.     _SNDVOL Musics&(0), v!
  1951.     _SNDVOL Musics&(1), v!
  1952.     _SNDVOL Musics&(2), v!
  1953.  
  1954. SUB PlayPausedSound ()
  1955.     DIM i AS INTEGER
  1956.     FOR i = 1 TO Level.enemies
  1957.         IF Enemie(i).sndPaused = 1 THEN Enemie(i).sndPaused = 0: _SNDPLAY Enemie(i).snd
  1958.     NEXT
  1959.     IF Level.mode = THUNDERMODE OR Level.mode = FOGMODE + THUNDERMODE THEN
  1960.         IF NOT _SNDPLAYING(RainSound&) THEN _SNDPLAY RainSound&
  1961.     END IF
  1962.  
  1963. SUB PauseSound ()
  1964.  
  1965.     DIM i AS INTEGER
  1966.     FOR i = 1 TO Level.enemies
  1967.         IF Enemie(i).sndPaused = 0 THEN _SNDSTOP Enemie(i).snd: Enemie(i).sndPaused = 1
  1968.     NEXT
  1969.  
  1970.     IF _SNDPLAYING(RainSound&) THEN _SNDSTOP RainSound&
  1971.  
  1972.  
  1973. FUNCTION SceneEnd (which%)
  1974.     DIM i AS INTEGER, d AS _BYTE
  1975.  
  1976.     FOR i = 1 TO Level.enemies
  1977.         IF Enemie(i).ending = 0 AND Enemie(i).scene = which% THEN d = -1: EXIT FOR
  1978.     NEXT
  1979.     IF d = 0 THEN SceneEnd = -1 ELSE SceneEnd = 0
  1980.  
  1981. SUB SaveGame ()
  1982.     DIM a$, F AS INTEGER
  1983.     a$ = "Save_Game\save.dat"
  1984.     KILL a$
  1985.     F = FREEFILE
  1986.     LevelStage% = LevelStage% + 1
  1987.     OPEN a$ FOR BINARY AS #F
  1988.     IF HighScore% < CurrentScore% THEN PUT #F, , CurrentScore% ELSE PUT #F, , HighScore%
  1989.     PUT #F, , LevelStage%
  1990.     CLOSE #F
  1991.  
  1992. SUB SetupRain ()
  1993.     DIM i AS INTEGER
  1994.     FOR i = 0 TO UBOUND(Drop)
  1995.         Drop(i).x = RND * _WIDTH
  1996.         Drop(i).y = -(RND * (_HEIGHT * 3))
  1997.         Drop(i).z = INT(RND * 1)
  1998.         Drop(i).yspeed = Map(Drop(i).z, 0, 1, 1, 2)
  1999.         Drop(i).len = Map(Drop(i).z, 0, 1, 8, 16)
  2000.         Drop(i).gravity = Map(Drop(i).z, 0, 1, 0.1, 0.3)
  2001.     NEXT
  2002.     RainVol# = -1.0
  2003.  
  2004. SUB FallDrops ()
  2005.     DIM i AS INTEGER
  2006.     FOR i = 0 TO UBOUND(drop)
  2007.         Drop(i).y = Drop(i).y + Drop(i).yspeed
  2008.         Drop(i).yspeed = Drop(i).yspeed + Drop(i).gravity
  2009.         IF Drop(i).y > _HEIGHT THEN Drop(i).y = RND * -400: Drop(i).yspeed = Map(Drop(i).z, 0, 1, 1, 2)
  2010.     NEXT
  2011.  
  2012. SUB DrawDrops ()
  2013.     DIM i AS INTEGER
  2014.     IF W.sfx THEN
  2015.         ' IF RainVol# < .98 THEN RainVol# = RainVol# + 0.01: _SNDBAL RainSound&, 0, 0, RainVol#
  2016.         IF NOT _SNDPLAYING(RainSound&) THEN _SNDPLAY RainSound&
  2017.     END IF
  2018.     FOR i = 0 TO UBOUND(drop)
  2019.         IF Drop(i).z = 0 THEN _PUTIMAGE (Drop(i).x, Drop(i).y), Rainx8& ELSE _PUTIMAGE (Drop(i).x, Drop(i).y), Rainx16&
  2020.     NEXT
  2021.  
  2022.  
  2023.  
  2024. FUNCTION Map (value, r1, r2, e1, e2)
  2025.     IF value = r1 THEN Map = e1
  2026.     IF value = r2 THEN Map = e2
  2027.  
  2028. SUB MakeThunderImage (original_img&)
  2029.     IF original_img& = -1 THEN EXIT SUB
  2030.  
  2031.     DIM buffer AS _MEM, o AS _OFFSET, o2 AS _OFFSET
  2032.     n = p5random(30, 120)
  2033.  
  2034.     buffer = _MEMIMAGE(original_img&)
  2035.     o = buffer.OFFSET
  2036.     o2 = o + _WIDTH(original_img&) * _HEIGHT(original_img&) * 4
  2037.     DO
  2038.         ' echo str$(o)
  2039.         b = _MEMGET(buffer, o, _UNSIGNED _BYTE)
  2040.         IF b + n < 256 THEN b = b + n ELSE b = 255
  2041.         _MEMPUT buffer, o, b AS _UNSIGNED _BYTE
  2042.         b = _MEMGET(buffer, o + 1, _UNSIGNED _BYTE)
  2043.         IF b + n < 256 THEN b = b + n ELSE b = 255
  2044.         _MEMPUT buffer, o + 1, b AS _UNSIGNED _BYTE
  2045.         b = _MEMGET(buffer, o + 2, _UNSIGNED _BYTE)
  2046.         IF b + n < 256 THEN b = b + n ELSE b = 255
  2047.         _MEMPUT buffer, o + 2, b AS _UNSIGNED _BYTE
  2048.         o = o + 4
  2049.     LOOP UNTIL o = o2
  2050.     _MEMFREE buffer
  2051.  
  2052. SUB centerImage (img&)
  2053.     _PUTIMAGE ((_WIDTH / 2) - (_WIDTH(img&) / 2), (_HEIGHT / 2) - (_HEIGHT(img&) / 2))-STEP(_WIDTH(img&), _HEIGHT(img&)), img&
  2054.  
  2055. SUB showCredits ()
  2056.     DIM k&, f&, i AS INTEGER, f2&, yy AS INTEGER
  2057.  
  2058.     k& = _LOADIMAGE("Images/credits.png", 33)
  2059.     f& = _NEWIMAGE(_WIDTH(k&), _HEIGHT(k&), 32)
  2060.     _DEST f&
  2061.     FOR i = 0 TO 255
  2062.         LINE (0, (_HEIGHT - 255) + i)-(_WIDTH, (_HEIGHT - 255) + i), _RGBA(0, 0, 0, i)
  2063.         LINE (0, 255 - i)-(_WIDTH, 255 - i), _RGBA(0, 0, 0, i)
  2064.     NEXT
  2065.     _DEST 0
  2066.     f2& = _COPYIMAGE(f&, 33)
  2067.     SWAP f&, f2&
  2068.     _FREEIMAGE f2&
  2069.     yy = _HEIGHT + 50
  2070.     DO
  2071.  
  2072.         _PUTIMAGE (50, yy), k&
  2073.         _PUTIMAGE , f&
  2074.         yy = yy - 1
  2075.  
  2076.         _DISPLAY
  2077.         _LIMIT W.fps
  2078.     LOOP UNTIL yy < -_HEIGHT(k&)
  2079.     _FREEIMAGE f&
  2080.     _FREEIMAGE k&
  2081.  
  2082. ' SUB showCredits2 ()
  2083. ' CLS
  2084. ' _FONT Fonts.bigger
  2085. ' _PRINTSTRING (CenterPrintX("Super Hunters 2017-18"), 250), "Super Hunters 2017-18"
  2086. ' _FONT Fonts.normal
  2087. ' _PRINTSTRING (CenterPrintX("By Ashish Kushwaha"), 290), "By Ashish Kushwaha"
  2088. ' initTextParticles _RGB(255, 255, 255)
  2089. ' CLS
  2090. ' DO
  2091. ' CLS
  2092. ' moveTextParticles
  2093. ' _LIMIT W.fps
  2094. ' _DISPLAY
  2095. ' LOOP UNTIL Text_Particles_Status = 1
  2096. ' _DELAY 1
  2097. ' fallTextParticles "fall"
  2098. ' CLS
  2099. ' _FONT Fonts.bigger
  2100. ' _PRINTSTRING (CenterPrintX("Programmer"), 250), "Programmer"
  2101. ' _FONT Fonts.normal
  2102. ' _PRINTSTRING (CenterPrintX("Ashish Kushwaha"), 290), "Ashish Kushwaha"
  2103. ' initTextParticles _RGB(255, 255, 255)
  2104. ' ' _DISPLAY: SLEEP
  2105. ' CLS
  2106. ' DO
  2107. ' CLS
  2108. ' moveTextParticles
  2109. ' _LIMIT W.fps
  2110. ' _DISPLAY
  2111. ' LOOP UNTIL Text_Particles_Status = 1
  2112. ' _DELAY 1
  2113. ' fallTextParticles "lessgravity"
  2114. ' CLS
  2115. ' _FONT Fonts.bigger
  2116. ' _PRINTSTRING (CenterPrintX("Graphic Designer"), 250), "Graphic Designer"
  2117. ' _FONT Fonts.normal
  2118. ' _PRINTSTRING (CenterPrintX("Google Images & Ashish Kushwaha"), 290), "Google Images & Ashish Kushwaha"
  2119. ' initTextParticles _RGB(255, 255, 255)
  2120. ' CLS
  2121. ' DO
  2122. ' CLS
  2123. ' moveTextParticles
  2124. ' _LIMIT W.fps
  2125. ' _DISPLAY
  2126. ' LOOP UNTIL Text_Particles_Status = 1
  2127. ' _DELAY 1
  2128. ' fallTextParticles "explode"
  2129. ' CLS
  2130. ' _FONT Fonts.bigger
  2131. ' _PRINTSTRING (CenterPrintX("Level Designer"), 250), "Level Designer"
  2132. ' _FONT Fonts.normal
  2133. ' _PRINTSTRING (CenterPrintX("Ashish Kushwaha"), 290), "Ashish Kushwaha"
  2134. ' initTextParticles _RGB(255, 255, 255)
  2135. ' CLS
  2136. ' DO
  2137. ' CLS
  2138. ' moveTextParticles
  2139. ' _LIMIT W.fps
  2140. ' _DISPLAY
  2141. ' LOOP UNTIL Text_Particles_Status = 1
  2142. ' _DELAY 1
  2143. ' fallTextParticles "horizontal"
  2144. ' CLS
  2145. ' _FONT Fonts.bigger
  2146. ' _PRINTSTRING (CenterPrintX("Special Thanks -"), 230), "Special Thanks -"
  2147. ' _FONT Fonts.normal
  2148. ' _PRINTSTRING (CenterPrintX("Terry Ritchie for sprite library"), 270), "Terry Ritchie for sprite library"
  2149. ' _PRINTSTRING (CenterPrintX("Unseenmachine & [banned user] for BlurImage"), 320), "Unseenmachine & [banned user] for BlurImage"
  2150. ' _PRINTSTRING (CenterPrintX("and player of this game!"), 345), "and player of this game!"
  2151. ' initTextParticles _RGB(255, 255, 255)
  2152. ' CLS
  2153. ' DO
  2154. ' CLS
  2155. ' moveTextParticles
  2156. ' _LIMIT W.fps
  2157. ' _DISPLAY
  2158. ' LOOP UNTIL Text_Particles_Status = 1
  2159. ' _DELAY 1
  2160. ' fallTextParticles "boom"
  2161.  
  2162. ' END SUB
  2163.  
  2164. ' SUB initTextParticles (which~&)
  2165. ' SHARED Text_Particles() AS Vector_Particles_Text_Type
  2166. ' FOR y = 0 TO _HEIGHT - 1
  2167. ' FOR x = 0 TO _WIDTH - 1
  2168. ' col~& = POINT(x, y)
  2169. ' IF col~& = which~& THEN n = n + 1
  2170. ' NEXT x, y
  2171.  
  2172. ' REDIM Text_Particles(n) AS Vector_Particles_Text_Type
  2173. ' n = 0
  2174. ' Text_Particles_Color = which~&
  2175. ' FOR x = 0 TO _WIDTH - 1
  2176. ' FOR y = 0 TO _HEIGHT - 1
  2177. ' col~& = POINT(x, y)
  2178. ' IF col~& = which~& THEN
  2179. ' Text_Particles(n).x = x
  2180. ' Text_Particles(n).y = y
  2181. ' Text_Particles(n).vx = p5random(0, _WIDTH)
  2182. ' Text_Particles(n).vy = p5random(0, _HEIGHT)
  2183. ' Text_Particles(n).dist = dist(Text_Particles(n).vx, Text_Particles(n).vy, Text_Particles(n).x, Text_Particles(n).y)
  2184. ' Text_Particles(n).distX = ABS(Text_Particles(n).x - Text_Particles(n).vx)
  2185. ' Text_Particles(n).distY = ABS(Text_Particles(n).y - Text_Particles(n).vy)
  2186. ' n = n + 1
  2187. ' END IF
  2188. ' NEXT y, x
  2189. ' END SUB
  2190.  
  2191. ' SUB moveTextParticles ()
  2192. ' SHARED Text_Particles() AS Vector_Particles_Text_Type
  2193. ' FOR i = 0 TO UBOUND(Text_Particles)
  2194. ' IF Text_Particles(i).k < Text_Particles(i).dist THEN
  2195. ' PSET (Text_Particles(i).vx + Text_Particles(i).delX, Text_Particles(i).vy + Text_Particles(i).delY), Text_Particles_Color
  2196. ' IF Text_Particles(i).vx > Text_Particles(i).x THEN Text_Particles(i).delX = Text_Particles(i).delX - Text_Particles(i).distX / Text_Particles(i).dist ELSE Text_Particles(i).delX = Text_Particles(i).delX + Text_Particles(i).distX / Text_Particles(i).dist
  2197. ' IF Text_Particles(i).vy > Text_Particles(i).y THEN Text_Particles(i).delY = Text_Particles(i).delY - Text_Particles(i).distY / Text_Particles(i).dist ELSE Text_Particles(i).delY = Text_Particles(i).delY + Text_Particles(i).distY / Text_Particles(i).dist
  2198. ' Text_Particles(i).k = Text_Particles(i).k + 1
  2199. ' ELSE
  2200. ' PSET (Text_Particles(i).x, Text_Particles(i).y), Text_Particles_Color
  2201. ' check = check + 1
  2202. ' END IF
  2203. ' NEXT
  2204. ' IF check >= UBOUND(text_particles) THEN Text_Particles_Status = 1: EXIT SUB ELSE Text_Particles_Status = 0
  2205.  
  2206. ' END SUB
  2207.  
  2208. ' SUB fallTextParticles (typ$)
  2209. ' SHARED Text_Particles() AS Vector_Particles_Text_Type
  2210. ' typ$ = LCASE$(typ$)
  2211. ' SELECT CASE typ$
  2212. ' CASE "explode"
  2213. ' FOR i = 0 TO UBOUND(Text_Particles)
  2214. ' Text_Particles(i).vx = 0
  2215. ' Text_Particles(i).vy = 0
  2216. ' Text_Particles(i).delX = p5random(-0.1, 0.1)
  2217. ' Text_Particles(i).delY = p5random(-0.1, 0.1)
  2218. ' NEXT
  2219. ' DO
  2220. ' CLS
  2221. ' z = 0
  2222. ' FOR i = 0 TO UBOUND(Text_Particles)
  2223.  
  2224. ' PSET (Text_Particles(i).x, Text_Particles(i).y), Text_Particles_Color
  2225. ' IF i < array_len THEN
  2226. ' Text_Particles(i).x = Text_Particles(i).x + Text_Particles(i).vx
  2227. ' Text_Particles(i).y = Text_Particles(i).y + Text_Particles(i).vy
  2228. ' Text_Particles(i).vx = Text_Particles(i).vx + Text_Particles(i).delX
  2229. ' Text_Particles(i).vy = Text_Particles(i).vy + Text_Particles(i).delY
  2230. ' END IF
  2231. ' IF Text_Particles(i).x > _WIDTH OR Text_Particles(i).x < 0 OR Text_Particles(i).y > _HEIGHT OR Text_Particles(i).y < 0 THEN z = z + 1
  2232. ' NEXT
  2233. ' IF array_len < UBOUND(Text_Particles) THEN array_len = array_len + steps
  2234. ' _DISPLAY
  2235. ' _LIMIT W.fps
  2236. ' steps = steps + 1
  2237. ' IF z > UBOUND(Text_Particles) THEN EXIT DO
  2238. ' LOOP UNTIL INKEY$ <> ""
  2239. ' EXIT SUB
  2240. ' CASE "fall"
  2241. ' FOR i = 0 TO UBOUND(text_particles)
  2242. ' Text_Particles(i).vx = 0
  2243. ' Text_Particles(i).vy = 0
  2244. ' Text_Particles(i).delX = p5random(-.02, .02)
  2245. ' Text_Particles(i).delY = p5random(0.1, 0.2)
  2246. ' NEXT
  2247. ' DO
  2248. ' CLS
  2249. ' z = 0
  2250. ' FOR i = 0 TO UBOUND(text_particles)
  2251. ' PSET (Text_Particles(i).x, Text_Particles(i).y), Text_Particles_Color
  2252. ' IF i < array_len THEN
  2253. ' Text_Particles(i).x = Text_Particles(i).x + Text_Particles(i).vx
  2254. ' Text_Particles(i).y = Text_Particles(i).y + Text_Particles(i).vy
  2255. ' Text_Particles(i).vx = Text_Particles(i).vx + Text_Particles(i).delX
  2256. ' Text_Particles(i).vy = Text_Particles(i).vy + Text_Particles(i).delY
  2257. ' END IF
  2258. ' IF Text_Particles(i).x > _WIDTH OR Text_Particles(i).x < 0 OR Text_Particles(i).y > _HEIGHT OR Text_Particles(i).y < 0 THEN z = z + 1
  2259. ' NEXT
  2260. ' IF array_len < UBOUND(text_particles) THEN array_len = array_len + steps
  2261. ' _DISPLAY
  2262. ' _LIMIT W.fps
  2263. ' steps = steps + 1
  2264. ' IF z = UBOUND(text_particles) THEN EXIT DO
  2265. ' LOOP
  2266. ' EXIT SUB
  2267.  
  2268. ' CASE "lessgravity"
  2269. ' FOR i = 0 TO UBOUND(Text_Particles)
  2270. ' Text_Particles(i).vx = 0
  2271. ' Text_Particles(i).vy = 0
  2272. ' Text_Particles(i).delX = p5random(-.02, .02)
  2273. ' Text_Particles(i).delY = p5random(-0.1, -0.2)
  2274. ' NEXT
  2275. ' DO
  2276. ' CLS
  2277. ' z = 0
  2278. ' FOR i = 0 TO UBOUND(Text_Particles)
  2279. ' PSET (Text_Particles(i).x, Text_Particles(i).y), Text_Particles_Color
  2280. ' IF i < array_len THEN
  2281. ' Text_Particles(i).x = Text_Particles(i).x + Text_Particles(i).vx
  2282. ' Text_Particles(i).y = Text_Particles(i).y + Text_Particles(i).vy
  2283. ' Text_Particles(i).vx = Text_Particles(i).vx + Text_Particles(i).delX
  2284. ' Text_Particles(i).vy = Text_Particles(i).vy + Text_Particles(i).delY
  2285. ' END IF
  2286. ' IF Text_Particles(i).x > _WIDTH OR Text_Particles(i).x < 0 OR Text_Particles(i).y > _HEIGHT OR Text_Particles(i).y < 0 THEN z = z + 1
  2287. ' NEXT
  2288. ' IF array_len < UBOUND(Text_Particles) THEN array_len = array_len + steps
  2289. ' _DISPLAY
  2290. ' _LIMIT W.fps
  2291. ' steps = steps + 1
  2292. ' LOOP UNTIL INKEY$ <> "" OR z >= UBOUND(text_particles)
  2293. ' EXIT SUB
  2294. ' CASE "horizontal"
  2295. ' FOR i = 0 TO UBOUND(Text_Particles)
  2296. ' Text_Particles(i).vx = 0
  2297. ' Text_Particles(i).vy = 0
  2298. ' Text_Particles(i).delX = p5random(-.2, .2)
  2299. ' Text_Particles(i).delY = 0
  2300. ' NEXT
  2301. ' DO
  2302. ' CLS
  2303. ' z = 0
  2304. ' FOR i = 0 TO UBOUND(Text_Particles)
  2305. ' PSET (Text_Particles(i).x, Text_Particles(i).y), Text_Particles_Color
  2306. ' Text_Particles(i).x = Text_Particles(i).x + Text_Particles(i).vx
  2307. ' Text_Particles(i).y = Text_Particles(i).y + Text_Particles(i).vy
  2308. ' Text_Particles(i).vx = Text_Particles(i).vx + Text_Particles(i).delX
  2309. ' Text_Particles(i).vy = Text_Particles(i).vy + Text_Particles(i).delY
  2310. ' IF Text_Particles(i).x > _WIDTH OR Text_Particles(i).x < 0 OR Text_Particles(i).y > _HEIGHT OR Text_Particles(i).y < 0 THEN z = z + 1
  2311. ' NEXT
  2312. ' _DISPLAY
  2313. ' _LIMIT W.fps
  2314. ' LOOP UNTIL INKEY$ <> "" OR z >= UBOUND(text_particles)
  2315. ' EXIT SUB
  2316. ' CASE "vertical"
  2317. ' FOR i = 0 TO UBOUND(Text_Particles)
  2318. ' Text_Particles(i).vx = 0
  2319. ' Text_Particles(i).vy = 0
  2320. ' Text_Particles(i).delX = 0
  2321. ' Text_Particles(i).delY = p5random(-0.2, 0.2)
  2322. ' NEXT
  2323. ' DO
  2324. ' CLS
  2325. ' z = 0
  2326. ' FOR i = 0 TO UBOUND(Text_Particles)
  2327. ' PSET (Text_Particles(i).x, Text_Particles(i).y), Text_Particles_Color
  2328.  
  2329. ' Text_Particles(i).x = Text_Particles(i).x + Text_Particles(i).vx
  2330. ' Text_Particles(i).y = Text_Particles(i).y + Text_Particles(i).vy
  2331. ' Text_Particles(i).vx = Text_Particles(i).vx + Text_Particles(i).delX
  2332. ' Text_Particles(i).vy = Text_Particles(i).vy + Text_Particles(i).delY
  2333.  
  2334. ' IF Text_Particles(i).x > _WIDTH OR Text_Particles(i).x < 0 OR Text_Particles(i).y > _HEIGHT OR Text_Particles(i).y < 0 THEN z = z + 1
  2335. ' NEXT
  2336. ' _DISPLAY
  2337. ' _LIMIT W.fps
  2338. ' LOOP UNTIL INKEY$ <> "" OR z >= UBOUND(text_particles)
  2339. ' EXIT SUB
  2340.  
  2341. ' CASE "boom"
  2342. ' FOR i = 0 TO UBOUND(Text_Particles)
  2343. ' Text_Particles(i).vx = 0
  2344. ' Text_Particles(i).vy = 0
  2345. ' Text_Particles(i).delX = p5random(-.1, .1)
  2346. ' Text_Particles(i).delY = p5random(-0.1, 0.1)
  2347. ' NEXT
  2348. ' DO
  2349. ' CLS
  2350. ' steps = 0
  2351. ' FOR i = 0 TO UBOUND(Text_Particles)
  2352. ' PSET (Text_Particles(i).x, Text_Particles(i).y), Text_Particles_Color
  2353. ' Text_Particles(i).x = Text_Particles(i).x + Text_Particles(i).vx
  2354. ' Text_Particles(i).y = Text_Particles(i).y + Text_Particles(i).vy
  2355. ' Text_Particles(i).vx = Text_Particles(i).vx + Text_Particles(i).delX
  2356. ' Text_Particles(i).vy = Text_Particles(i).vy + Text_Particles(i).delY
  2357. ' IF Text_Particles(i).x > _WIDTH OR Text_Particles(i).x < 0 OR Text_Particles(i).y > _HEIGHT OR Text_Particles(i).y < 0 THEN steps = steps + 1
  2358. ' NEXT
  2359. ' _DISPLAY
  2360. ' _LIMIT W.fps
  2361. ' IF steps > UBOUND(Text_Particles) THEN EXIT DO
  2362. ' LOOP UNTIL INKEY$ <> "" OR steps > UBOUND(text_particles)
  2363. ' EXIT SUB
  2364. ' END SELECT
  2365. ' END SUB
  2366.  
  2367. SUB centerPrint (a$, b)
  2368.     DIM i AS INTEGER, v AS INTEGER
  2369.     FOR i = 1 TO LEN(a$)
  2370.         v = v + _PRINTWIDTH(MID$(a$, i, 1))
  2371.     NEXT
  2372.     _PRINTSTRING (_WIDTH / 2 - v / 2, b), a$
  2373.  
  2374. FUNCTION txtWidth (a$)
  2375.     DIM i AS INTEGER, v AS INTEGER, g AS INTEGER
  2376.     FOR i = 1 TO LEN(a$)
  2377.         g = _PRINTWIDTH(MID$(a$, i, 1))
  2378.         v = v + g
  2379.     NEXT
  2380.     txtWidth = v
  2381. 'these p5random(), p5map! (original map!) and dist() functions are taken from p5js.bas
  2382. FUNCTION p5random! (mn!, mx!)
  2383.     DIM tmp!
  2384.  
  2385.     IF mn! > mx! THEN
  2386.         tmp! = mn!
  2387.         mn! = mx!
  2388.         mx! = tmp!
  2389.     END IF
  2390.     p5random! = RND * (mx! - mn!) + mn!
  2391.  
  2392. FUNCTION dist! (x1!, y1!, x2!, y2!)
  2393.     dist! = SQR((x2! - x1!) ^ 2 + (y2! - y1!) ^ 2)
  2394.  
  2395. FUNCTION p5map! (value!, minRange!, maxRange!, newMinRange!, newMaxRange!)
  2396.     p5map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange!
  2397.  
  2398.  
  2399. 'By UnseenMachine & [banned user]
  2400. 'http://www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index.php?topic=12658
  2401. SUB BLURIMAGE (Image AS LONG, Blurs AS _UNSIGNED INTEGER)
  2402.  
  2403.     DIM ImageMemory AS _MEM
  2404.     DIM ImageOffsetCurrent AS _OFFSET
  2405.     DIM ImageOffsetStart AS _OFFSET
  2406.     DIM ImageOffsetEnd AS _OFFSET
  2407.  
  2408.     DIM TopOffset AS _OFFSET
  2409.     DIM LeftOffset AS _OFFSET
  2410.     DIM RightOffset AS _OFFSET
  2411.     DIM BottomOffset AS _OFFSET
  2412.  
  2413.     DIM Red1 AS _UNSIGNED _BYTE
  2414.     DIM Green1 AS _UNSIGNED _BYTE
  2415.     DIM Blue1 AS _UNSIGNED _BYTE
  2416.     DIM Alpha1 AS _UNSIGNED _BYTE
  2417.  
  2418.     DIM Red2 AS _UNSIGNED _BYTE
  2419.     DIM Green2 AS _UNSIGNED _BYTE
  2420.     DIM Blue2 AS _UNSIGNED _BYTE
  2421.     DIM Alpha2 AS _UNSIGNED _BYTE
  2422.  
  2423.     DIM Red3 AS _UNSIGNED _BYTE
  2424.     DIM Green3 AS _UNSIGNED _BYTE
  2425.     DIM Blue3 AS _UNSIGNED _BYTE
  2426.     DIM Alpha3 AS _UNSIGNED _BYTE
  2427.  
  2428.     DIM Red4 AS _UNSIGNED _BYTE
  2429.     DIM Green4 AS _UNSIGNED _BYTE
  2430.     DIM Blue4 AS _UNSIGNED _BYTE
  2431.     DIM Alpha4 AS _UNSIGNED _BYTE
  2432.  
  2433.     ImageMemory = _MEMIMAGE(Image)
  2434.  
  2435.  
  2436.     DIM iterations%
  2437.  
  2438.     FOR iterations% = 0 TO Blurs - 1
  2439.  
  2440.         ImageOffsetStart = ImageMemory.OFFSET
  2441.         ImageOffsetCurrent = ImageOffsetStart
  2442.         ImageOffsetEnd = ImageOffsetStart + _WIDTH(Image) * _HEIGHT(Image) * 4
  2443.  
  2444.         DO
  2445.             TopOffset = ImageOffsetCurrent - _WIDTH(Image) * 4
  2446.             LeftOffset = ImageOffsetCurrent - 4
  2447.             RightOffset = ImageOffsetCurrent + 4
  2448.             BottomOffset = ImageOffsetCurrent + _WIDTH(Image) * 4
  2449.  
  2450.             ' *** Let's go ahead and set the color values to zero, and only change them when required.
  2451.             Red1 = 0: Green1 = 0: Blue1 = 0: Alpha1 = 0
  2452.             Red2 = 0: Green2 = 0: Blue2 = 0: Alpha2 = 0
  2453.             Red3 = 0: Green3 = 0: Blue3 = 0: Alpha3 = 0
  2454.             Red4 = 0: Green4 = 0: Blue4 = 0: Alpha4 = 0
  2455.  
  2456.             ' *** Get the color values from the pixel above the current pixel, if it is with the image.
  2457.             IF TopOffset >= ImageOffsetStart THEN
  2458.                 Red1 = _MEMGET(ImageMemory, TopOffset + 2, _UNSIGNED _BYTE)
  2459.                 Green1 = _MEMGET(ImageMemory, TopOffset + 1, _UNSIGNED _BYTE)
  2460.                 Blue1 = _MEMGET(ImageMemory, TopOffset, _UNSIGNED _BYTE)
  2461.                 Alpha1 = _MEMGET(ImageMemory, TopOffset + 3, _UNSIGNED _BYTE)
  2462.             END IF
  2463.  
  2464.             ' *** Get the color values from the pixel to the left of the current pixel, if it is with the image.
  2465.             IF ((((LeftOffset - ImageOffsetStart) / 4) MOD _WIDTH(Image)) < (((ImageOffsetCurrent - ImageOffsetStart) / 4) MOD _WIDTH(Image))) THEN
  2466.                 Red2 = _MEMGET(ImageMemory, LeftOffset + 2, _UNSIGNED _BYTE)
  2467.                 Green2 = _MEMGET(ImageMemory, LeftOffset + 1, _UNSIGNED _BYTE)
  2468.                 Blue2 = _MEMGET(ImageMemory, LeftOffset, _UNSIGNED _BYTE)
  2469.                 Alpha2 = _MEMGET(ImageMemory, LeftOffset + 3, _UNSIGNED _BYTE)
  2470.             END IF
  2471.  
  2472.             ' *** Get the color values from the pixel to the right of the current pixel, if it is with the image.
  2473.             IF ((((RightOffset - ImageOffsetStart) / 4) MOD _WIDTH(Image)) > (((ImageOffsetCurrent - ImageOffsetStart) / 4) MOD _WIDTH(Image))) THEN
  2474.                 Red3 = _MEMGET(ImageMemory, RightOffset + 2, _UNSIGNED _BYTE)
  2475.                 Green3 = _MEMGET(ImageMemory, RightOffset + 1, _UNSIGNED _BYTE)
  2476.                 Blue3 = _MEMGET(ImageMemory, RightOffset, _UNSIGNED _BYTE)
  2477.                 Alpha3 = _MEMGET(ImageMemory, RightOffset + 3, _UNSIGNED _BYTE)
  2478.             END IF
  2479.  
  2480.             ' *** Get the color values from the pixel below the current pixel, if it is with the image.
  2481.             IF BottomOffset < ImageOffsetEnd THEN
  2482.                 Red4 = _MEMGET(ImageMemory, BottomOffset + 2, _UNSIGNED _BYTE)
  2483.                 Green4 = _MEMGET(ImageMemory, BottomOffset + 1, _UNSIGNED _BYTE)
  2484.                 Blue4 = _MEMGET(ImageMemory, BottomOffset, _UNSIGNED _BYTE)
  2485.                 Alpha4 = _MEMGET(ImageMemory, BottomOffset + 3, _UNSIGNED _BYTE)
  2486.             END IF
  2487.  
  2488.             ' *** draw the current pixel with a newly defined _RGBA color value.
  2489.             _MEMPUT ImageMemory, ImageOffsetCurrent, _RGBA((Red1 + Red2 + Red3 + Red4) / 4, (Green1 + Green2 + Green3 + Green4) / 4, (Blue1 + Blue2 + Blue3 + Blue4) / 4, (Alpha1 + Alpha2 + Alpha3 + Alpha4) / 4) AS _UNSIGNED LONG
  2490.  
  2491.             '' *** These are here for fun nd testing purposes.
  2492.             '_MEMPUT ImageMemory, ImageOffsetCurrent, _RGBA((Red1 + Red2 + Red3 + Red4) / 4, (Green1 + Green2 + Green3 + Green4) / 4, (Blue1 + Blue2 + Blue3 + Blue4) / 4, 255) AS _UNSIGNED LONG
  2493.             '_MEMPUT ImageMemory, ImageOffsetCurrent, _RGBA(0, 0, (Blue1 + Blue2 + Blue3 + Blue4) / 4, 255) AS _UNSIGNED LONG
  2494.             '_MEMPUT ImageMemory, ImageOffsetCurrent, _RGBA(0, (Green1 + Green2 + Green3 + Green4) / 4, 0, 255) AS _UNSIGNED LONG
  2495.             '_MEMPUT ImageMemory, ImageOffsetCurrent, _RGBA((Red1 + Red2 + Red3 + Red4) / 4, 0, 0, 255) AS _UNSIGNED LONG
  2496.  
  2497.             ImageOffsetCurrent = ImageOffsetCurrent + 4
  2498.  
  2499.         LOOP UNTIL ImageOffsetCurrent = ImageOffsetEnd
  2500.  
  2501.     NEXT
  2502.  
  2503.     _MEMFREE ImageMemory
  2504.  
  2505. '$include:'Vendor\sprite.bi'
  2506.  
  2507. 'End of Code ! :)
  2508.  

 
Hunter's Revenge Screenshot.jpg
* Hunter-Revenge-master.zip (Filesize: 15.98 MB, Downloads: 373)
« Last Edit: March 27, 2020, 05:51:08 am by Qwerkey »