I just saw this flash game the other day, and i wanted to code something like it to learn from. I dont have the original games URL or name, i just tried it briefly. Well, theres no media, and its coded in a few hours. I plan to maby make a level editor (also just for learning purposes), so the level making gets easier.
Currently it has four levels (just started the fifth.)
well.. Here ya go..
Oh, and this is DBP. I forgot to add it to the subject line. Mod's, feel free to add if you'd like.
sync on : sync rate 90 : backdrop on : color backdrop 0
for x = 1 to 4000 : ink rgb(rnd(255),255,255),0 : dot rnd(1024),rnd(768) : next x
get image 5000,0,0,1024,768
sprite 5000,0,0,5000
rem Create our little dude :)
ink rgb(0,0,255),0 : for x = 1 to 20 : ellipse 30,30,x,x : next x : rem body
ink rgb(255,255,255),0 : for x = 4 to 5 : circle 40,20,x : next x : rem eye
ink rgb(255,0,0),0 : for x = 1 to 2 : circle 40,20,x : next x : rem iris
ink rgb(255,255,255),0 : line 45,45,38,44 : line 38,44,32,38 : rem mouth
get image 1,10,10,50,50
sprite 1,0,600,1
offset sprite 1, sprite width(1) / 2, sprite height(1) / 2
set sprite priority 1,5
rem small obstacle box
ink rgb(255,0,0),0 : box 0,0,30,100 : get image 2,0,0,30,100 : cls
sprite 2,2000,2000,2 : offset sprite 2,15,100 : set sprite priority 2,2
rem large obstacle box
ink rgb(255,0,0),0 : box 0,0,30,200 : get image 3,0,0,30,200 : cls
sprite 3,2000,2000,3 : offset sprite 3,15,200 : set sprite priority 3,2
rem floor
ink rgb(150,150,150),0 : box 0,0,1024,168 : get image 4000,0,0,1024,168 : cls
sprite 4000,0,643,4000 : set sprite priority 4000,1
StartPosX = 0 : StartPosY = 623 : posx = 0 : posy = 623 : rem Startup variables
type level as level
Tutorial as String
SmallX as Integer
SmallY as Integer
BigX as Integer
BigY as Integer
endtype
dim level(10,10) as level
level(1).Tutorial = "Use spacekey to make a low jump"
level(1,1).SmallX = screen width() / 2 : level(1,1).SmallY = 643
level(2).Tutorial = "Use arrow up key to make a high jump"
level(2,2).BigX = screen width() / 2 : level(2,2).BigY = 643
level(3).Tutorial = "Combine the two jumps!"
level(3,1).SmallX = 250 : level(3,1).SmallY = 300
level(3,2).BigX = 250 : level(3,2).BigY = 643
level(3,3).SmallX = 600 : level(3,3).SmallY = 643
level(3,4).BigX = 600 : level(3,4).BigY = 443
level(4).Tutorial = "You are now on your own! Have fun!"
level(4,1).SmallX = 150 : level(4,1).SmallY = 643
level(4,2).SmallX = 400 : level(4,2).SmallY = 643
level(4,3).BigX = 275 : level(4,3).BigY = 523
level(4,4).SmallX = 780 : level(4,4).SmallY = 643
level(4,5).BigX = 1024 : level(4,5).BigY = 643
level(4,6).SmallX = 1024 : level(4,6).SmallY = 300
level(5,1).BigX = 5 : level(5,1).BigY = 643
level(5,2).SmallX = 5 : level(5,2).SmallY = 300
currentlevel = 1 : playerlives = 20
gosub drawlevel
do
rem High jump code
if highjump = 1
run# = 2
posy = posy - speed#
if speed# => 0
speed# = speed# - 0.05
endif
rotate sprite 1,rotate#
rotate# = rotate# + 2.4
endif
rem Low jump code
if lowjump = 1
run# = 2
posy = posy - speedlow#
if speedlow# => 0
speedlow# = speedlow# - 0.05
endif
rotate sprite 1,rotate#
rotate# = rotate# + 3.5
endif
rem Gravity
if sprite y(1) < 623
posy = posy + gravity#
if gravity# =< 5
gravity# = gravity# + 0.05
run# = 2
endif
endif
rem Resetting when hitting the ground
if sprite y(1) = 623
run# = 1
lowjump = 0
highjump = 0
gravity# = 0
speed# = 6.2
speedlow# = 4.2
rotate sprite 1,0 : rotate# = 0
endif
rem Collision detection
for x = 2 to 300
if sprite hit (1,x)
wait 1000
playerlives = playerlives - 1
posx = StartPosX
posy = StartPosY
endif
next x
rem High Jump
if upkey()
if sprite y(1) = 623
highjump = 1
endif
endif
rem Low Jump
if spacekey()
if sprite y(1) = 623
lowjump = 1
endif
endif
text 965,16,str$(Mousex())
text 965,32,str$(Mousey())
text 965,0,"FPS: " + str$(Screen fps())
rem Basic player info
text 0,0,"Lives: " + str$(playerlives)
text 0,16,"Level: " + str$(currentlevel)
if level(currentlevel).Tutorial > "" then center text screen width() / 2, 200,level(currentlevel).Tutorial
rem if player has crossed the screen, go to the next level
if posx > screen width()
posx = StartPosX
StartPosY = posy
for x = 100 to 300
if sprite exist(x)
delete sprite x
endif
next x
currentlevel = currentlevel + 1
gosub drawlevel
endif
rem Paste our little guy "running"
sprite 1,posx,posy,1
posx = sprite x(1) + run#
sync
loop
rem Drawing the current level
drawlevel:
rem Check for Small Boxes to place (currently max 10)
for x = 1 to 10
if level(currentlevel,x).SmallX > 0
if level(currentlevel,x).SmallX > 0
clone sprite 2,100 + x
sprite 100 + x, level(currentlevel,x).SmallX, level(currentlevel,x).SmallY, 2
endif
endif
next x
rem Check for Large boxes to place (currently max 10)
for x = 1 to 10
if level(currentlevel,x).BigX > 0
if level(currentlevel,x).BigX > 0
clone sprite 3,200 + x
sprite 200 + x, level(currentlevel,x).BigX, level(currentlevel,x).BigY, 3
endif
endif
next x
return