Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rem Generated 1/28/2013 1:50:36 PM by Visual bB Version 1.0.0.548
- rem **********************************
- rem *heartbreak.bin *
- rem *A re-imagning of breakout with a lonely heart trapped in a void... *
- rem *Cybearg (aka Nic) *
- rem *cybearg.plays@gmail.com *
- rem **********************************
- rem ==============
- rem INITIALIZATION
- rem ==============
- rem set up settings/optimization
- set optimization speed
- set optimization noinlinedata
- rem set up my variables
- dim blckcnt = q
- dim base = r
- dim level = s
- dim cooldown=t
- dim anglevar=u
- dim pulse=v
- dim flicker=w
- dim offset=x
- dim ballcolor=y
- dim heartcolor=z
- blckcnt=16
- rem set offset to a number greater than 0 to allow for "negative" values
- offset = 50
- rem set heartcolor to begin at red
- heartcolor = 64
- rem set player 0's location
- player0x=80:player0y=48
- rem ==========
- rem MAIN LOOP
- rem ==========
- draw_loop
- rem clear the playfield
- pfclear
- rem increment the multi-purpose cooldown variable
- cooldown = cooldown + 1
- rem mute sound at 7 cooldown cycles or after 20 cycles if there's been a titlescreen restart
- if cooldown = 7 || cooldown = 70 then AUDV0 = 0 : AUDV1 = 0
- rem ===============
- rem BEATING HEART
- rem ===============
- rem increment pulse counter
- pulse = pulse +1
- rem cooldown to make sure that player doesn't leave the title screen by firing a ball
- if pulse = 45 && cooldown >= 50 then cooldown = 0
- rem after 45 cycles, increment color
- if pulse = 45 then pulse = 0
- rem special occasion for first level
- if level = 0 then heartcolor = 64: goto 10
- rem special occasion for second level
- if level = 1 && heartcolor = 64 && pulse = 0 then heartcolor = 28: goto 10
- if level = 1 && heartcolor = 28 && pulse = 0 then heartcolor = 64: goto 10
- rem increment the colors
- if heartcolor = 28 && pulse = 0 then heartcolor = 148: goto 10
- if heartcolor = 64 && pulse = 0 then heartcolor = 28: goto 10
- if heartcolor = 148 && pulse = 0 then heartcolor = 64
- 10
- rem set the playfield colors
- COLUP0 = heartcolor
- rem turn the score red if player is on the last life
- if lives = 1 then scorecolor = 64 else scorecolor = 10
- rem swap the heart sprite for 5 cycles to create illusion of beating
- if pulse < 40 then goto 40 else goto 44
- rem values for the up-beat (40 out of 45 cycles)
- 40 if lives = 0 then goto 80
- 41 if lives = 1 then goto 70
- 42 if lives = 2 then goto 60
- 43 if lives = 3 then goto 50
- rem values for the down-beat (5 out of 45 cycles)
- 44 if lives = 0 then goto 80
- 45 if lives = 1 then goto 90
- 46 if lives = 2 then goto 70
- 47 if lives = 3 then goto 60
- rem the various player 0 heart sprites
- 50
- player0:
- %00010000
- %00111000
- %01111100
- %11111110
- %11111110
- %11111110
- %01101100
- %00000000
- end
- 55 goto 100
- 60
- player0:
- %00000000
- %00010000
- %00111000
- %01111100
- %01111100
- %00101000
- %00000000
- %00000000
- end
- 65 goto 100
- 70
- player0:
- %00000000
- %00000000
- %00010000
- %00111000
- %00101000
- %00000000
- %00000000
- %00000000
- end
- 75 goto 100
- 80
- 90
- player0:
- %00000000
- %00000000
- %00000000
- %00000000
- %00000000
- %00000000
- %00000000
- %00000000
- end
- rem ==============
- rem COLOR FLICKER
- rem ==============
- 100
- rem if the player has zero lives, skip this part
- if lives = 0 then goto 410 else goto 110
- rem set up possible colors
- data blkc
- 64, 28, 154, 44, 202, 122, 14, 0
- end
- rem set up possible pfpixel locations
- data ctbl
- 16, 20, 24, 27, 28, 27, 24, 20, 16, 12, 8, 5, 4, 5, 8, 12
- end
- data rtbl
- 0, 0, 1, 3, 5, 7, 9, 10, 10, 10, 9, 7, 5, 3, 1, 0
- end
- 110
- rem cycle through pfpixels, turning them on if they are equal to the color being drawn
- temp3 = blkc[flicker]
- for temp5 = 0 to 15
- temp6 = temp5 + base & $0F
- if a[temp6] = temp3 then pfpixel ctbl[temp5] rtbl[temp5] on: temp4 = 1
- next
- flicker = flicker + 1 & 7
- rem determines if a color shows up; if not, don't bother drawing that color and return for the next
- if temp4 then COLUPF = temp3 else goto 110
- rem ==================
- rem MAIN DRAWSCREEN
- rem ==================
- rem main drawscreen
- drawscreen
- rem skip to COLOR MOVEMENT
- goto 415
- rem =============
- rem TITLE SCREEN
- rem =============
- 410
- rem set the beat of the title screen heart to the ongoing pulse
- if pulse < 40 then goto 413 else goto 412
- rem the two possible title screen frames
- 412
- playfield:
- ................................
- ...X.X.XXX..X..XX.XXX...........
- ...X.X.X...X.X.X.X.X............
- ...XXX.XX..XXX.XX..X............
- ...X.X.XXX.X.X.X.X.X............
- ..............................
- ...........XX..XX..XXX..X..X.X..
- ....X.X....X.X.X.X.X...X.X.X.X..
- ....XXX....XX..XX..XX..XXX.XX...
- .....X.....X.X.X.X.XXX.X.X.X.X..
- ...........XXX..................
- end
- rem skip to color
- goto 414
- 413
- playfield:
- ................................
- ...X.X.XXX..X..XX.XXX...........
- ...X.X.X...X.X.X.X.X............
- ...XXX.XX..XXX.XX..X............
- ...X.X.XXX.X.X.X.X.X............
- ................................
- ...XX.XX...XX..XX..XXX..X..X.X..
- ..XXXXXXX..X.X.X.X.X...X.X.X.X..
- ...XXXXX...XX..XX..XX..XXX.XX...
- ....XXX....X.X.X.X.XXX.X.X.X.X..
- .....X.....XXX..................
- end
- 414
- rem color the title screen playfield
- COLUPF = 64
- rem drawscreen for titlescreen only
- drawscreen
- rem skip everything else and wait for a trigger
- goto 760
- rem =================
- rem COLOR MOVEMENT
- rem =================
- 415
- rem NOTE: offset base is 50, so the numbers below determine how sensitive the controls are
- rem determine block offset
- if joy0left && offset < 56 then offset = offset + 1
- if joy0right && offset > 44 then offset = offset - 1
- rem adjust block offset
- 420
- if offset > 55 goto rotl
- if offset < 45 goto rotr
- rem if no adjustments are necessary, skip this part
- goto 500
- rem move all block values to the left (counter clockwise)
- rotl
- base = base + 1 & $0F
- goto 450
- rem move all blocks to the right (clockwise)
- rotr
- base = base - 1 & $0F
- rem reset the offset
- 450
- offset = 50
- rem ============
- rem PLAYER FIRE
- rem ============
- 500
- 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)
- rem cooldown ensures that the player cannot fire while a ball is at play
- rem cooldown also ensures the player doesn't exit a title screen by firing a ball prematurely
- if joy0fire && lives > 0 && player1x = 0 && player1y = 0 && cooldown < 50 then player1x=80:player1y=48 else goto 600
- rem moves the ball's current color from heartcolor (set in the BEATING HEART section) to ballcolor for safe-keeping
- ballcolor = heartcolor
- rem set player 1's sprite
- player1:
- %00000000
- %00000000
- %00000000
- %00011000
- %00011000
- %00000000
- %00000000
- %00000000
- end
- rem generate random number to determine ball movement
- rem variables ensure that ball speed/angle does not vary once ball has been generated
- anglevar = (rand/32)
- rem =========
- rem THE BALL
- rem =========
- 600
- rem skip everything dealing with the ball if it is at its resting position (0,0)
- if player1x = 0 && player1y = 0 then goto 800
- rem maintain the color of the ball at the moment of firing
- COLUP1 = ballcolor
- rem all ball movement possibilities
- rem allows for ball movement in a direction every 45 degrees
- 650
- rem cooldown is used to manage the speed of the ball
- if cooldown > 8 then cooldown = 0
- goto skipd2
- rem x motion table
- data xmtbl
- 50, 51, 51, 51, 50, 49, 49, 49
- end
- rem y motion table
- data ymtbl
- 51, 51, 50, 49, 49, 49, 50, 51
- end
- skipd2
- rem separate out cardinal from diagonal directions
- if anglevar <> 0 && anglevar <> 2 && anglevar <> 4 && anglevar <> 6 then goto 670 else goto 680
- 670
- rem movements for diagonal directions (45, 125, 225, 315) -- applies a cooldown to ensure that diagonals do not move too fast
- 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
- 680
- rem movement values for cardinal (0, 90, 180, 270 degrees) directions -- applies a cooldown to ensure that cardinal directions do not move too fast
- if cooldown <> 3 && cooldown <> 7 then player1x = player1x + xmtbl[anglevar] - 50
- if cooldown <> 3 && cooldown <> 7 then player1y = player1y + ymtbl[anglevar] - 50
- rem ====================
- rem COLLISION DETECTION
- rem === thanks to bogax ===
- rem ====================
- 700
- rem check to see if player 1 is out of bounds
- if player1x = 25 || player1y = 0 then goto 750
- if player1x=133 || player1y = 140 then goto 750
- temp4 = 4 - anglevar & $07
- temp4 = temp4 * 2
- temp5 = player1x - bxtbl[temp4]
- temp6 = player1y - bytbl[temp4]
- if temp5 < 4 && temp6 < 8 then goto 710
- rem if no collision is detected, skip to the end of the main loop
- goto 800
- rem minimum collision data locations (x, y)
- data bxtbl
- 79
- end
- data bytbl
- 5, 110,13, 126,45, 110,77, 78,85, 46,77, 30,45, 46,13
- end
- rem check for collision type
- 710
- temp4 = temp4 + base & $0F
- rem check if the block is already dead
- if a[temp4] = 0 then goto 800
- rem check ball color against block color
- if a[temp4]<>ballcolor then goto bad_hit
- rem if the hit is good...
- good_hit
- rem set current block to dead
- a[temp4] = 0 : blckcnt = blckcnt - 1
- rem increment score
- score = score + 25
- rem play good hit sound
- AUDV1 = 6
- AUDC1 = 12
- AUDF1 = 19
- goto 725
- rem if the hit is bad...
- bad_hit
- rem lose a life
- lives = lives - 1
- rem play bad hit sound
- AUDV1 = 6
- AUDC1 = 6
- AUDF1 = 16
- rem reset sound cooldown counter
- 725
- if lives > 0 then cooldown = 0 else cooldown = 50: pulse = 0
- 750
- rem reset player 1 location, unlocking player 0 fire
- player1x = 0: player1y = 0
- rem ==================
- rem STAGE GENERATION
- rem ==================
- 760
- rem exits title screen and generates a new stage
- if joy0fire && lives = 0 && cooldown < 50 then score = 0: pulse = 0: cooldown = 50: level = 0: goto 775
- rem all blocks destroyed?
- if blckcnt then goto 800
- rem if so, then score bonus points for completing stage and continue
- if lives = 3 then score = score + 600
- if lives = 2 then score = score + 400
- if lives = 1 then score = score + 200
- rem increment the level counter, but make sure it doesn't go too high
- if level < 10 then level = level + 1
- rem generates new stage by looping through and inserting new colors taken from data set under COLOR FLICKER
- 775
- rem different values for different levels
- if level = 0 then goto 776
- if level = 1 then goto 777 else goto 780
- 776
- rem first level has only red blocks, to teach basic mechanics of firing a ball and rotating blocks
- for temp1 = 0 to 15
- a[temp1] = blkc[0]
- next
- goto 799
- 777
- rem second level teaches the differences between the colors and how the right color must go to the right ball
- for temp1 = 0 to 15
- temp2 = rand
- if temp2 < 128 then a[temp1] = blkc[1] else a[temp1] = blkc[0]
- next
- goto 799
- 780
- rem third level introduces all three primary colors
- for temp1 = 0 to 15
- temp2 = rand
- if temp2 < 86 then a[temp1] = blkc[0]
- if temp2 > 85 then a[temp1] = blkc[1]
- if temp2 > 170 then a[temp1] = blkc[2]
- next
- 799
- rem complete reset by giving full lives
- lives = 3 : blckcnt = 16
- rem end loop
- 800 goto draw_loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement