Advertisement
Guest User

heartbreak_mod.bas

a guest
Feb 7th, 2013
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.52 KB | None | 0 0
  1. rem Generated 1/28/2013 1:50:36 PM by Visual bB Version 1.0.0.548
  2. rem **********************************
  3. rem *heartbreak.bin *
  4. rem *A re-imagning of breakout with a lonely heart trapped in a void... *
  5. rem *Cybearg (aka Nic) *
  6. rem *cybearg.plays@gmail.com *
  7. rem **********************************
  8.  
  9.  
  10. rem ==============
  11. rem INITIALIZATION
  12. rem ==============
  13.  
  14. rem set up settings/optimization
  15. set optimization speed
  16. set optimization noinlinedata
  17.  
  18. rem set up my variables
  19. dim blckcnt = q
  20. dim base = r
  21. dim level = s
  22. dim cooldown=t
  23. dim anglevar=u
  24. dim pulse=v
  25. dim flicker=w
  26. dim offset=x
  27. dim ballcolor=y
  28. dim heartcolor=z
  29.  
  30. blckcnt=16
  31.  
  32. rem set offset to a number greater than 0 to allow for "negative" values
  33. offset = 50
  34.  
  35. rem set heartcolor to begin at red
  36. heartcolor = 64
  37.  
  38. rem set player 0's location
  39. player0x=80:player0y=48
  40.  
  41.  
  42. rem ==========
  43. rem MAIN LOOP
  44. rem ==========
  45.  
  46. draw_loop
  47.  
  48. rem clear the playfield
  49. pfclear
  50.  
  51. rem increment the multi-purpose cooldown variable
  52. cooldown = cooldown + 1
  53.  
  54. rem mute sound at 7 cooldown cycles or after 20 cycles if there's been a titlescreen restart
  55. if cooldown = 7 || cooldown = 70 then AUDV0 = 0 : AUDV1 = 0
  56.  
  57.  
  58. rem ===============
  59. rem BEATING HEART
  60. rem ===============
  61.  
  62. rem increment pulse counter
  63. pulse = pulse +1
  64.  
  65. rem cooldown to make sure that player doesn't leave the title screen by firing a ball
  66. if pulse = 45 && cooldown >= 50 then cooldown = 0
  67.  
  68. rem after 45 cycles, increment color
  69. if pulse = 45 then pulse = 0
  70.  
  71. rem special occasion for first level
  72. if level = 0 then heartcolor = 64: goto 10
  73.  
  74. rem special occasion for second level
  75. if level = 1 && heartcolor = 64 && pulse = 0 then heartcolor = 28: goto 10
  76. if level = 1 && heartcolor = 28 && pulse = 0 then heartcolor = 64: goto 10
  77.  
  78. rem increment the colors
  79. if heartcolor = 28 && pulse = 0 then heartcolor = 148: goto 10
  80. if heartcolor = 64 && pulse = 0 then heartcolor = 28: goto 10
  81. if heartcolor = 148 && pulse = 0 then heartcolor = 64
  82.  
  83. 10
  84.  
  85. rem set the playfield colors
  86. COLUP0 = heartcolor
  87.  
  88. rem turn the score red if player is on the last life
  89. if lives = 1 then scorecolor = 64 else scorecolor = 10
  90.  
  91. rem swap the heart sprite for 5 cycles to create illusion of beating
  92. if pulse < 40 then goto 40 else goto 44
  93.  
  94. rem values for the up-beat (40 out of 45 cycles)
  95. 40 if lives = 0 then goto 80
  96. 41 if lives = 1 then goto 70
  97. 42 if lives = 2 then goto 60
  98. 43 if lives = 3 then goto 50
  99.  
  100. rem values for the down-beat (5 out of 45 cycles)
  101. 44 if lives = 0 then goto 80
  102. 45 if lives = 1 then goto 90
  103. 46 if lives = 2 then goto 70
  104. 47 if lives = 3 then goto 60
  105.  
  106. rem the various player 0 heart sprites
  107. 50
  108. player0:
  109. %00010000
  110. %00111000
  111. %01111100
  112. %11111110
  113. %11111110
  114. %11111110
  115. %01101100
  116. %00000000
  117. end
  118.  
  119. 55 goto 100
  120.  
  121. 60
  122. player0:
  123. %00000000
  124. %00010000
  125. %00111000
  126. %01111100
  127. %01111100
  128. %00101000
  129. %00000000
  130. %00000000
  131. end
  132.  
  133. 65 goto 100
  134.  
  135. 70
  136. player0:
  137. %00000000
  138. %00000000
  139. %00010000
  140. %00111000
  141. %00101000
  142. %00000000
  143. %00000000
  144. %00000000
  145. end
  146.  
  147. 75 goto 100
  148.  
  149. 80
  150.  
  151. 90
  152. player0:
  153. %00000000
  154. %00000000
  155. %00000000
  156. %00000000
  157. %00000000
  158. %00000000
  159. %00000000
  160. %00000000
  161. end
  162.  
  163.  
  164. rem ==============
  165. rem COLOR FLICKER
  166. rem ==============
  167.  
  168. 100
  169.  
  170. rem if the player has zero lives, skip this part
  171. if lives = 0 then goto 410 else goto 110
  172.  
  173. rem set up possible colors
  174. data blkc
  175. 64, 28, 154, 44, 202, 122, 14, 0
  176. end
  177.  
  178. rem set up possible pfpixel locations
  179. data ctbl
  180. 16, 20, 24, 27, 28, 27, 24, 20, 16, 12, 8, 5, 4, 5, 8, 12
  181. end
  182.  
  183. data rtbl
  184. 0, 0, 1, 3, 5, 7, 9, 10, 10, 10, 9, 7, 5, 3, 1, 0
  185. end
  186.  
  187. 110
  188. rem cycle through pfpixels, turning them on if they are equal to the color being drawn
  189. temp3 = blkc[flicker]
  190.  
  191. for temp5 = 0 to 15
  192. temp6 = temp5 + base & $0F
  193. if a[temp6] = temp3 then pfpixel ctbl[temp5] rtbl[temp5] on: temp4 = 1
  194. next
  195. flicker = flicker + 1 & 7
  196. rem determines if a color shows up; if not, don't bother drawing that color and return for the next
  197. if temp4 then COLUPF = temp3 else goto 110
  198.  
  199. rem ==================
  200. rem MAIN DRAWSCREEN
  201. rem ==================
  202.  
  203. rem main drawscreen
  204. drawscreen
  205.  
  206. rem skip to COLOR MOVEMENT
  207. goto 415
  208.  
  209.  
  210. rem =============
  211. rem TITLE SCREEN
  212. rem =============
  213.  
  214.  
  215. 410
  216.  
  217. rem set the beat of the title screen heart to the ongoing pulse
  218. if pulse < 40 then goto 413 else goto 412
  219.  
  220. rem the two possible title screen frames
  221. 412
  222.  
  223. playfield:
  224. ................................
  225. ...X.X.XXX..X..XX.XXX...........
  226. ...X.X.X...X.X.X.X.X............
  227. ...XXX.XX..XXX.XX..X............
  228. ...X.X.XXX.X.X.X.X.X............
  229. ..............................
  230. ...........XX..XX..XXX..X..X.X..
  231. ....X.X....X.X.X.X.X...X.X.X.X..
  232. ....XXX....XX..XX..XX..XXX.XX...
  233. .....X.....X.X.X.X.XXX.X.X.X.X..
  234. ...........XXX..................
  235. end
  236.  
  237. rem skip to color
  238. goto 414
  239.  
  240. 413
  241.  
  242. playfield:
  243. ................................
  244. ...X.X.XXX..X..XX.XXX...........
  245. ...X.X.X...X.X.X.X.X............
  246. ...XXX.XX..XXX.XX..X............
  247. ...X.X.XXX.X.X.X.X.X............
  248. ................................
  249. ...XX.XX...XX..XX..XXX..X..X.X..
  250. ..XXXXXXX..X.X.X.X.X...X.X.X.X..
  251. ...XXXXX...XX..XX..XX..XXX.XX...
  252. ....XXX....X.X.X.X.XXX.X.X.X.X..
  253. .....X.....XXX..................
  254. end
  255.  
  256. 414
  257.  
  258. rem color the title screen playfield
  259. COLUPF = 64
  260.  
  261. rem drawscreen for titlescreen only
  262. drawscreen
  263.  
  264. rem skip everything else and wait for a trigger
  265. goto 760
  266.  
  267.  
  268. rem =================
  269. rem COLOR MOVEMENT
  270. rem =================
  271.  
  272. 415
  273.  
  274. rem NOTE: offset base is 50, so the numbers below determine how sensitive the controls are
  275.  
  276. rem determine block offset
  277. if joy0left && offset < 56 then offset = offset + 1
  278. if joy0right && offset > 44 then offset = offset - 1
  279.  
  280.  
  281. rem adjust block offset
  282. 420
  283. if offset > 55 goto rotl
  284. if offset < 45 goto rotr
  285.  
  286. rem if no adjustments are necessary, skip this part
  287. goto 500
  288.  
  289.  
  290. rem move all block values to the left (counter clockwise)
  291. rotl
  292. base = base + 1 & $0F
  293. goto 450
  294.  
  295. rem move all blocks to the right (clockwise)
  296. rotr
  297. base = base - 1 & $0F
  298. rem reset the offset
  299.  
  300. 450
  301. offset = 50
  302.  
  303.  
  304. rem ============
  305. rem PLAYER FIRE
  306. rem ============
  307.  
  308. 500
  309.  
  310. rem checks to see that a few cool-down measures are a go, then moves the ball (player 1) to the center of the heart (player 0)
  311. rem cooldown ensures that the player cannot fire while a ball is at play
  312. rem cooldown also ensures the player doesn't exit a title screen by firing a ball prematurely
  313. if joy0fire && lives > 0 && player1x = 0 && player1y = 0 && cooldown < 50 then player1x=80:player1y=48 else goto 600
  314.  
  315. rem moves the ball's current color from heartcolor (set in the BEATING HEART section) to ballcolor for safe-keeping
  316. ballcolor = heartcolor
  317.  
  318. rem set player 1's sprite
  319.  
  320. player1:
  321. %00000000
  322. %00000000
  323. %00000000
  324. %00011000
  325. %00011000
  326. %00000000
  327. %00000000
  328. %00000000
  329. end
  330.  
  331. rem generate random number to determine ball movement
  332. rem variables ensure that ball speed/angle does not vary once ball has been generated
  333.  
  334. anglevar = (rand/32)
  335.  
  336.  
  337. rem =========
  338. rem THE BALL
  339. rem =========
  340.  
  341. 600
  342.  
  343. rem skip everything dealing with the ball if it is at its resting position (0,0)
  344. if player1x = 0 && player1y = 0 then goto 800
  345.  
  346. rem maintain the color of the ball at the moment of firing
  347.  
  348. COLUP1 = ballcolor
  349.  
  350. rem all ball movement possibilities
  351. rem allows for ball movement in a direction every 45 degrees
  352.  
  353. 650
  354.  
  355. rem cooldown is used to manage the speed of the ball
  356. if cooldown > 8 then cooldown = 0
  357. goto skipd2
  358.  
  359. rem x motion table
  360. data xmtbl
  361. 50, 51, 51, 51, 50, 49, 49, 49
  362. end
  363.  
  364. rem y motion table
  365. data ymtbl
  366. 51, 51, 50, 49, 49, 49, 50, 51
  367. end
  368.  
  369. skipd2
  370. rem separate out cardinal from diagonal directions
  371. if anglevar <> 0 && anglevar <> 2 && anglevar <> 4 && anglevar <> 6 then goto 670 else goto 680
  372.  
  373. 670
  374. rem movements for diagonal directions (45, 125, 225, 315) -- applies a cooldown to ensure that diagonals do not move too fast
  375. if cooldown <> 1 && cooldown <> 3 && cooldown <> 5 && cooldown <> 7 then player1x = player1x + xmtbl[anglevar] - 50: player1y = player1y + ymtbl[anglevar] - 50: goto 700 else goto 700
  376.  
  377. 680
  378. rem movement values for cardinal (0, 90, 180, 270 degrees) directions -- applies a cooldown to ensure that cardinal directions do not move too fast
  379. if cooldown <> 3 && cooldown <> 7 then player1x = player1x + xmtbl[anglevar] - 50
  380. if cooldown <> 3 && cooldown <> 7 then player1y = player1y + ymtbl[anglevar] - 50
  381.  
  382. rem ====================
  383. rem COLLISION DETECTION
  384. rem === thanks to bogax ===
  385. rem ====================
  386.  
  387. 700
  388.  
  389. rem check to see if player 1 is out of bounds
  390. if player1x = 25 || player1y = 0 then goto 750
  391. if player1x=133 || player1y = 140 then goto 750
  392.  
  393. temp4 = 4 - anglevar & $07
  394. temp4 = temp4 * 2
  395. temp5 = player1x - bxtbl[temp4]
  396. temp6 = player1y - bytbl[temp4]
  397.  
  398. if temp5 < 4 && temp6 < 8 then goto 710
  399.  
  400. rem if no collision is detected, skip to the end of the main loop
  401. goto 800
  402.  
  403. rem minimum collision data locations (x, y)
  404.  
  405. data bxtbl
  406. 79
  407. end
  408.  
  409. data bytbl
  410. 5, 110,13, 126,45, 110,77, 78,85, 46,77, 30,45, 46,13
  411. end
  412.  
  413. rem check for collision type
  414. 710
  415.  
  416. temp4 = temp4 + base & $0F
  417. rem check if the block is already dead
  418. if a[temp4] = 0 then goto 800
  419.  
  420. rem check ball color against block color
  421. if a[temp4]<>ballcolor then goto bad_hit
  422.  
  423. rem if the hit is good...
  424. good_hit
  425.  
  426. rem set current block to dead
  427. a[temp4] = 0 : blckcnt = blckcnt - 1
  428.  
  429. rem increment score
  430. score = score + 25
  431.  
  432. rem play good hit sound
  433. AUDV1 = 6
  434. AUDC1 = 12
  435. AUDF1 = 19
  436.  
  437. goto 725
  438.  
  439. rem if the hit is bad...
  440. bad_hit
  441.  
  442. rem lose a life
  443. lives = lives - 1
  444.  
  445. rem play bad hit sound
  446. AUDV1 = 6
  447. AUDC1 = 6
  448. AUDF1 = 16
  449.  
  450. rem reset sound cooldown counter
  451. 725
  452. if lives > 0 then cooldown = 0 else cooldown = 50: pulse = 0
  453.  
  454. 750
  455.  
  456. rem reset player 1 location, unlocking player 0 fire
  457. player1x = 0: player1y = 0
  458.  
  459.  
  460. rem ==================
  461. rem STAGE GENERATION
  462. rem ==================
  463.  
  464. 760
  465.  
  466. rem exits title screen and generates a new stage
  467. if joy0fire && lives = 0 && cooldown < 50 then score = 0: pulse = 0: cooldown = 50: level = 0: goto 775
  468.  
  469. rem all blocks destroyed?
  470. if blckcnt then goto 800
  471.  
  472. rem if so, then score bonus points for completing stage and continue
  473. if lives = 3 then score = score + 600
  474. if lives = 2 then score = score + 400
  475. if lives = 1 then score = score + 200
  476.  
  477. rem increment the level counter, but make sure it doesn't go too high
  478. if level < 10 then level = level + 1
  479.  
  480. rem generates new stage by looping through and inserting new colors taken from data set under COLOR FLICKER
  481. 775
  482.  
  483. rem different values for different levels
  484. if level = 0 then goto 776
  485. if level = 1 then goto 777 else goto 780
  486.  
  487. 776
  488. rem first level has only red blocks, to teach basic mechanics of firing a ball and rotating blocks
  489. for temp1 = 0 to 15
  490. a[temp1] = blkc[0]
  491. next
  492. goto 799
  493.  
  494. 777
  495. rem second level teaches the differences between the colors and how the right color must go to the right ball
  496. for temp1 = 0 to 15
  497. temp2 = rand
  498. if temp2 < 128 then a[temp1] = blkc[1] else a[temp1] = blkc[0]
  499. next
  500.  
  501. goto 799
  502.  
  503. 780
  504. rem third level introduces all three primary colors
  505. for temp1 = 0 to 15
  506. temp2 = rand
  507. if temp2 < 86 then a[temp1] = blkc[0]
  508. if temp2 > 85 then a[temp1] = blkc[1]
  509. if temp2 > 170 then a[temp1] = blkc[2]
  510. next
  511.  
  512. 799
  513. rem complete reset by giving full lives
  514. lives = 3 : blckcnt = 16
  515.  
  516. rem end loop
  517. 800 goto draw_loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement