Run!
Here is a quick run and jump side scroller with pretty smooth jumping. Pressing up jump and left-right control the direction. Avoid falling, running out of time and getting by the bullets. Special items float by to freeze time and speed up time. The objective is to get 4 of the keys floating by..
It was my first write using batari, and my friend Bucket did the design and characters.
Cheers!
- Broch
set smartbranching on
set romsize 4k
set optimization speed
rem Run!
rem programmed by Broch
rem designed by Bucket
rem change log:
rem 9/28/2005 : first version
rem 9/29/2005 : cleaned up code base
rem *** variables
rem *** available:
rem *** ctrl variable f,g,i
rem *** flow - programstart ->init vars ->renderpf->rendertop->doneplayerfield->rendertop
score = 0
ballx = 5
ballheight = 0
goto startme
programstart
rem * CLEAR *
gosub clear
rem * DEFINE VARS
x = 0 : rem * player x
y = 50 : rem * player y
dim peg1 = u
dim peg2 = v
dim peg3 = t
dim pegr1 = l
dim pegr2 = j
dim pegr3 = k
dim timefreezepos = q
dim mastertick = p
dim mastertick2 = b
dim missilepos = c
dim item = z
dim movingx = o
dim winner = w
dim powerup = m
dim mscore = s
dim falling = h
dim velocity = d.e
dim panim = i
dim tick = a
dim tick2 = n
data bcolors
0, 20, 10, 120, 99, 0
end
rem *INIT VARS
NUSIZ0=$13
velocity = 0 : falling = 1 : panim = 1 : tick = 0
COLUBK = bcolors[ballx] : COLUP0 = 30 : COLUP1 = 88 : COLUPF = 214 : x = 0 : y = 50 : mastertick2 = 0 : player0x = x : player0y = y
item = 1
timefreezepos = 60 : missilepos = 60
peg3 = 55 : peg2 = 43 : peg1 = 31 : pegr1 = 10 : pegr2 = 7 : pegr3 = 4
scorecolor = 14
pfhline 0 0 20 on
pfhline 0 10 4 on
movingx = 40 : mastertick = 0 : mastertick2 = 0
mscore = 23
powerup = 0
winner = 0
velocity = 0
i = 0
f = 0
g = 0
rendertop
rem ** BEGIN
goto renderpf
rem ** LOGIC
renlogic
player0y = player0y + velocity : player0y = player0y + 12
if !collision(player0,playfield) then falling = 1 else falling = 0 : velocity = 0
if collision(player0,playfield) && y < 30 then falling = 1
player0y = player0y - velocity : player0y = player0y - 12
if joy0up && falling = 0 then falling = 1 : velocity = -2.1
if falling = 1 then velocity = velocity + 0.1
if falling = 0 then velocity = 0
y = y + velocity
if y > 90 then y = 0: velocity = 0: falling = 1
if y > 85 && mscore < 23 then goto gameover
if joy0left then x = x - 1 : tick = tick + 1 : REFP0 = 8
if x < 28 then x = 28
if joy0right then x = x + 1 : tick = tick + 1 : REFP0 = 0
if x > 152 then x = 152
if tick > 3 then tick = 0 : panim = panim + 1
if panim > 3 then panim = 1
if falling = 1 then panim = 4
player0x = x : player0y = y
if collision(player1,player0) && item = 1 && powerup = 0 then powerup = 1 : score = score + 200 : tick2 = 0 : mscore = 23
if collision(player1,player0) && item = 3 && powerup <> 3 then tick2 = 200: score = score + 800 : powerup = 3 : winner = winner + 1 : g = winner * 2 : g = 31 - g : pfpixel g 0 on
if collision(player1,player0) && item = 4 && powerup = 0 then powerup = 4 : score = score + 500 : tick2 = 0
if winner > 250 then winner = 0
if collision(player0,missile0) && mscore < 30 then goto gameover
if collision(player0,missile1) && mscore < 30 then goto gameover
if tick2 > 250 then powerup = 0 : tick2 = 0 : COLUBK = bcolors[ballx]
if powerup = 1 then tick2 = tick2 + 1 : AUDV0 = 15 - tick2 : AUDC0 = 4 : AUDF0 = 31
if powerup = 3 then tick2 = tick2 + 1 : AUDV0 = 5 : AUDC0 = 8 : AUDF0 = 31 - tick2
if powerup = 4 then tick2 = tick2 + 1 : AUDV0 = 5 : AUDC0 = 3 : AUDF0 = 31 + tick2 : COLUBK = tick
if powerup = 0 then AUDV0 = 0
if mscore < 32 then AUDV1 = 1 : AUDC1 = 3 : AUDF1 = mscore
if joy0up && velocity > 0 && powerup = 0 && falling = 1 then AUDV1 = 5 : AUDC1 = 4 : AUDF1 = y
234 if panim = 1 then goto 241
235 if panim = 2 then goto 245
236 if panim = 3 then goto 247
237 if panim = 4 then goto 249
241 player0:
%10000110
%11100100
%00101000
%00110000
%00111100
%00010000
%00001100
%00001100
end
242
243 goto 255
245 player0:
%00011000
%00110000
%00010000
%01110000
%00111000
%00010000
%00001100
%00001100
end
246 goto 255
247 player0:
%01100000
%00101100
%00011000
%00110000
%00110000
%00010000
%00001100
%00001100
end
248 goto 255
249 player0:
%01000000
%01101100
%00111000
%00110000
%00110110
%10011000
%01101100
%00001100
end
250 goto 255
255 rem time freeze
256 if item=1 then goto 260
258 if item=3 then goto 264
259 if item=4 then goto 266
260 player1:
%01111111
%00100010
%01000001
%01001101
%01001001
%00100010
%00011100
%00100010
end
261 goto doneplayfield
264 player1:
%00100010
%00110110
%00011100
%00111110
%01111111
%00001000
%00001000
%00000000
end
265 goto doneplayfield
266 player1:
%00001000
%00001100
%01111110
%01111111
%01111110
%00001100
%00001000
%00000000
end
267 goto doneplayfield
rem *** RENDER
rem ** PLAY FIELD **
renderpf
rem ** PADS
if mastertick > 0 then goto renderitems
if peg1 = 250 then peg1 = 31 : g = rand else f1
if pegr3 = 10 then pegr1 = 7 : goto f1
if pegr3 = 7 && g > 170 then pegr1 = 4 : goto f1
if pegr3 = 7 && g > 85 then pegr1 = 7 : goto f1
if pegr3 = 7 && g >= 0 then pegr1 = 10: goto f1
if pegr3 = 4 then pegr1 = 7
f1
peg1 = peg1 - 1
if peg1>=0 && peg1 <=31 then pfpixel peg1 pegr1 on
peg1 = peg1 + 5
if peg1>=0 && peg1 <=31 then pfpixel peg1 pegr1 off
peg1 = peg1 - 5
if peg2 = 250 then peg2 = 31 : g = rand else goto f2
if pegr1 = 10 then pegr2 = 7 : goto f2
if pegr1 = 7 && g > 170 then pegr2 = 4 : goto f2
if pegr1 = 7 && g > 85 then pegr2 = 7 : goto f2
if pegr1 = 7 && g >= 0 then pegr2 = 10 : goto f2
if pegr1 = 4 then pegr2 = 7
f2
peg2 = peg2 - 1
if peg2>=0 && peg2 <=31 then pfpixel peg2 pegr2 on
peg2 = peg2 + 5
if peg2>=0 && peg2 <=31 then pfpixel peg2 pegr2 off
peg2 = peg2 - 5
if peg3 = 250 then peg3 = 31 : g = rand else goto f3
if pegr2 = 10 then pegr3 = 7 : goto f3
if pegr2 = 7 && g > 170 then pegr3 = 4 : goto f3
if pegr2 = 7 && g > 85 then pegr3 = 7 : goto f3
if pegr2 = 7 && g >= 0 then pegr3 = 10: goto f3
if pegr2 = 4 then pegr3 = 7
f3
peg3 = peg3 - 1
if peg3>=0 && peg3 <=31 then pfpixel peg3 pegr3 on
peg3 = peg3 + 5
if peg3>=0 && peg3 <=31 then pfpixel peg3 pegr3 off
peg3 = peg3 - 5
renderitems
rem ** ITEMS **
f = movingx : f = f * 6
player1y = timefreezepos
if f > 28 && f < 152 then player1x = f else player1x = 0 : player1y = 0 : g=30
f=rand
if player1x = 0 && g=30 && f > 170 then timefreezepos = 25 : g = 0
if player1x = 0 && g=30 && f > 25 then timefreezepos = 52 : g = 0
if player1x = 0 && g=30 && f >= 0 then timefreezepos = 75
if player1x > 0 then goto ij
f = rand
if f > 200 then item = 4 : goto ij
if f > 100 then item = 3 : goto ij
if f > 0 then item = 1
ij
rem ** missiles **
rem if missile0x < 250 then missile0x = 41
f = movingx - 70 : f = f * 6 : f = 0 - f
if f > 28 && f < 152 then missile0x = f : missile0y = pegr1 * 2 : missile0height = 1 else missile0x = 0 : missile0y = 0 : missile0height = 0
if missile0x = 0 then missilepos = rand
rem if missile1x < 250 then missile1x = 41
f = movingx - 70 : f = f * 6 : f = 0 - f : g = rand
if f > 28 && f < 152 && g > 129 then missile1x = f-30 : missile1y = pegr1 * 5 : missile1height = 1 else missile1x = 0 : missile1y = 0 : missile1height = 0
goto renlogic
doneplayfield
if powerup = 0 && mastertick2 > 100 then mscore = mscore - 1 : score = score + 25 : mastertick2 = 0 : pfpixel mscore 0 off
if mscore <= 1 then score = 0: drawscreen: goto gameover
mastertick = mastertick + 1
mastertick2 = mastertick2 +1
f = ballx - 1
if mastertick > ballx && powerup = 0 || powerup = 3 then movingx = movingx - 1 : mastertick = 0
if mastertick > f && powerup = 4 then movingx = movingx - 1 : mastertick = 0
if mastertick > f && powerup = 1 then movingx = movingx - 1 : mastertick = 0
if winner >= 4 then goto nextlevel
g = 0
if movingx = 0 then g = 0 : movingx=41
drawscreen
goto rendertop
rem ** GAME OVER **
gameover
drawscreen : f = 0 : COLUBK = 0
goverloop
AUDV1 = 5 : AUDC1 = 7 : AUDF1 = rand : AUDV0 = 0
COLUPF = 0 : COLUBK = 0
COLUP0 = rand
COLUP1 = 0 : scorecolor = 0
drawscreen
f = f + 1
if f < 60 then goto goverloop
for g = 0 to 11
pfhline 0 g 31 offa
next g
score = 0 : AUDV1 = 0
drawscreen : goto programstart
goto goverloop
rem ** NEXT LEVLE
nextlevel
gosub clear
COLUPF = 14
gosub logo
COLUP0 = 0
COLUP1 = 0 : scorecolor = 0 : player0x=0:player1x=255
g = 78
m = 5
for f = 1 to 180
AUDV1 = m : AUDC1 = 12 : AUDF1 = f : AUDV0 = 0 : COLUBK = g : COLUP0 = g : COLUP1 = g
g = g - 1
if g < 64 then g = 64
drawscreen
next
winner = 0
score = score + 2500
AUDV1 = 0
ballx=ballx - 1
if ballx = 255 then goto startme
goto programstart
rem ** start screen
startme
gosub clear
COLUPF = 14
gosub logo
COLUP0 = 0
COLUP1 = 0 : scorecolor = 0 : player0x=0:player1x=255
500
g = g + 1
COLUBK = g : COLUP0 = g : COLUP1 = g : COLUPF = 255-g
drawscreen
if joy0fire then goto programstart
goto 500
rem * logo
logo
pfpixel 1 1 on:pfpixel 2 1 on:pfpixel 3 1 on:pfpixel 14 1 on
pfpixel 27 1 on:pfpixel 28 1 on:pfpixel 1 2 on:pfpixel 4 2 on
pfpixel 14 2 on:pfpixel 27 2 on:pfpixel 28 2 on:pfpixel 1 3 on
pfpixel 4 3 on:pfpixel 6 3 on:pfpixel 8 3 on:pfpixel 10 3 on
pfpixel 11 3 on:pfpixel 14 3 on:pfpixel 26 3 on:pfpixel 1 4 on
pfpixel 2 4 on:pfpixel 3 4 on:pfpixel 6 4 on:pfpixel 8 4 on
pfpixel 10 4 on:pfpixel 12 4 on:pfpixel 25 4 on:pfpixel 26 4 on
pfpixel 27 4 on:pfpixel 28 4 on:pfpixel 1 5 on:pfpixel 4 5 on
pfpixel 7 5 on:pfpixel 8 5 on:pfpixel 10 5 on:pfpixel 12 5 on
pfpixel 14 5 on:pfpixel 25 5 on:pfpixel 26 5 on:pfpixel 23 6 on
pfpixel 24 6 on:pfpixel 25 6 on:pfpixel 27 6 on:pfpixel 23 7 on
pfpixel 28 7 on:pfpixel 28 8 on:pfpixel 29 8 on
return
rem * CLEAR draw buff
clear
r29 asm
ldx #47
lda #0
clearpf
sta playfield,x
dex
bpl clearpf
end
return
run.zip