Jump around
Community Forums/Showcase/Jump around
| ||
| ** Update City ** Well this appears to be going rather well! Here's the link for the latest and greatest version of jump around ( http://www.frecle.net/misc/JumpAround.zip ) The updates are coming thick and fast so Fredborg is now the code-keeper (please note, whenever you say code-keeper you need to add an echo effect to your voice). If you add stuff let everyone know where and what has been changed, this way it's going to be pretty straight forward copy and pasting your snippet in. Please do not post full source code anymore as this thread has got insanely huge. Anyway... Please add away, this is turning into a fantastic game! Here have start of a game... please add to it and post it back. Controls: Left key: angle left right key: angle right down key: hold to jump (builds up power) Graphics 640,480,0,2 x#=GraphicsWidth()/2 y#=GraphicsHeight()/2 xd#=0 yd#=0 angle#=180 power#=0 Const keyleft=203 Const keyright=205 Const keyjump=208 Global gotr=0 Global gotg=0 Global gotb=0 SetBuffer BackBuffer() Repeat Cls If KeyDown(keyright) And angle<270 Then angle=angle+5 If KeyDown(keyleft) And angle>90 Then angle=angle-5 If KeyDown(keyjump) And deck=True And Int(xd+yd)=0 Then power=power+2 If power>100 Then power=0 ; jump If KeyDown(keyjump)=False And power>0 power=power/10 xd=Sin(-angle)*power yd=Cos(-angle)*power power=0 EndIf yd=yd+.1 xd=xd*.99 yd=yd*.99 oldx#=x oldy#=y x=x+xd y=y+yd ; draw level Color 0,255,0 Rect 0,GraphicsHeight()-10,GraphicsWidth(),10 Rect 0,0,GraphicsWidth(),10 Rect 0,10,10,GraphicsHeight()-20 Rect GraphicsWidth()-10,10,10,GraphicsHeight()-20 SeedRnd 1010 For n=1 To 50 Rect Rand(0,GraphicsWidth()),Rand(0,GraphicsHeight()),Rand(0,200),10 Next ; check of hitting sides, anypixel with a green component counts as solid. deck=False LockBuffer BackBuffer() If yd>0 getrgb(BackBuffer(),x,y+2) deck=True Else getrgb(BackBuffer(),x,y-2) EndIf If gotg>0 y=oldy xd=xd*.9 yd=-yd/3 EndIf If xd>0 getrgb(BackBuffer(),x+2,y) Else getrgb(BackBuffer(),x-2,y) EndIf If gotg>0 x=oldx xd=-xd/2 EndIf UnlockBuffer BackBuffer() ; draw player Color 255,255,255 Rect x-2,y-2,5,5,True Line x,y,x+(Sin(-angle)*10),y+(Cos(-angle)*10) ; draw power bar Color 255,0,0 Rect 0,2,(GraphicsWidth()/100)*power,6 Flip Until KeyHit(1) Function getrgb(buffer,x,y) argb=ReadPixelFast(x,y,buffer) gotr=(ARGB Shr 16) And $ff gotg=(ARGB Shr 8) And $ff gotb=ARGB And $ff End Function |
| ||
Minor modification, use Right shift to fine adjust the angle.Code removed to reduce the size of the thread *EDIT* Nice idea by the way :) |
| ||
| Remarkably similar to the prototype I did of FleaFall! www.fleafall.com. Almost identical graphics and everything. Fundamentally different control system of course. I like the physics. Nice job. |
| ||
Scrolling and game over :)Type box Field x#,y#,w,h End Type Graphics 640,480,0,2 x#=GraphicsWidth()/2 y#=GraphicsHeight()/2 xd#=0 yd#=0 angle#=180 power#=0 Const keyleft=203 Const keyright=205 Const keyjump=208 Const keyFineAngle = 54 Global gotr=0 Global gotg=0 Global gotb=0 Global angleMod = 5 SetBuffer BackBuffer() SeedRnd 1010 For n=1 To 50 box.box = New box box\x = Rand(0,GraphicsWidth()) box\y = Rand(0,GraphicsHeight()) box\w = Rand(0,200) box\h = 10 Next Repeat Cls If KeyDown(keyFineAngle) Then angleMod = 1 Else angleMod = 5 If KeyDown(keyright) And angle<270 Then angle=angle+angleMod If KeyDown(keyleft) And angle>90 Then angle=angle-angleMod If KeyDown(keyjump) And deck=True And Int(xd+yd)=0 Then power=power+2 If power>100 Then power=0 ; jump If KeyDown(keyjump)=False And power>0 power=power/10 xd=Sin(-angle)*power yd=Cos(-angle)*power power=0 EndIf yd=yd+.1 xd=xd*.99 yd=yd*.99 oldx#=x oldy#=y x=x+xd y=y+yd ; draw level Color 255,255,0 Rect 0,GraphicsHeight()-10,GraphicsWidth(),10 Color 0,255,0 Rect 0,0,GraphicsWidth(),10 Rect 0,10,10,GraphicsHeight()-20 Rect GraphicsWidth()-10,10,10,GraphicsHeight()-20 For box.box = Each box Rect box\x,box\y,box\w,box\h,True box\y = box\y + 0.05 If box\y > GraphicsHeight() box\x = Rand(0,GraphicsWidth()) box\y = -10 box\w = Rand(0,200) box\h = 10 End If Next ; check of hitting sides, anypixel with a green component counts as solid. deck=False LockBuffer BackBuffer() If yd>0 getrgb(BackBuffer(),x,y+2) deck=True Else getrgb(BackBuffer(),x,y-2) EndIf If gotg>0 If gotr>0 gameover = True End If y=oldy xd=xd*.9 yd=-yd/3 EndIf If xd>0 getrgb(BackBuffer(),x+2,y) Else getrgb(BackBuffer(),x-2,y) EndIf If gotg>0 x=oldx xd=-xd/2 EndIf UnlockBuffer BackBuffer() If gameover Color 255,255,255 Text GraphicsWidth()/2,GraphicsHeight()/2,"GAME OVER",True,True Else ; draw player Color 255,255,255 Rect x-2,y-2,5,5,True Line x,y,x+(Sin(-angle)*10),y+(Cos(-angle)*10) ; draw power bar Color 255,0,0 Rect 0,2,(GraphicsWidth()/100)*power,6 End If Flip Until KeyHit(1) End Function getrgb(buffer,x,y) argb=ReadPixelFast(x,y,buffer) gotr=(ARGB Shr 16) And $ff gotg=(ARGB Shr 8) And $ff gotb=ARGB And $ff End Function |
| ||
Scroll speed increases over timecode removed to reduce the size of the thread |
| ||
Added simple scoring systemsame as the others |
| ||
Coins and graphicsType box
Field x#,y#,w,h
End Type
Type coin
Field x#,y#,frame#
End Type
Graphics 640,480,0,2
x#=GraphicsWidth()/2
y#=GraphicsHeight()/2
xd#=0
yd#=0
angle#=180
power#=0
Const keyleft=203
Const keyright=205
Const keyjump=208
Const keyFineAngle = 54
Global gotr=0
Global gotg=0
Global gotb=0
Global angleMod = 5
SetBuffer BackBuffer()
SeedRnd 1010
For n=1 To 20
box.box = New box
box\x = Rand(0,GraphicsWidth()/32)*32
box\y = Rand(0,GraphicsHeight()/32)*32
box\w = Rand(2,5)*32
box\h = 32
Next
For box.box = Each box
If Rand(0,5) = 1
coin.coin = New coin
coin\x = Rand(box\x,box\x+box\w)
coin\y = box\y-16
End If
Next
backdrop = LoadImage("Background00.png")
tiles = LoadAnimImage("Tiles00.png",32,32,0,3)
coins = LoadAnimImage("Coins00.png",16,16,0,8)
backscroll# = GraphicsHeight()-ImageHeight(backdrop)
scrollspeed# = 0.05
Score = 0
ClsColor 154,198,237
Repeat
Cls
backscroll = backscroll + (scrollspeed*0.1)
DrawImage backdrop,0,backscroll
If KeyDown(keyFineAngle) Then angleMod = 1 Else angleMod = 5
If KeyDown(keyright) And angle<270 Then angle=angle+angleMod
If KeyDown(keyleft) And angle>90 Then angle=angle-angleMod
If KeyDown(keyjump) And deck=True And Int(xd+yd)=0 Then power=power+2
If power>100 Then power=0
; jump
If KeyDown(keyjump)=False And power>0
power=power/10
xd=Sin(-angle)*power
yd=Cos(-angle)*power
power=0
EndIf
yd=yd+.1
xd=xd*.99
yd=yd*.99
oldx#=x
oldy#=y
x=x+xd
y=y+yd
; draw level
For box.box = Each box
For sx = 0 To box\w-32 Step 32
frame = 1
If sx = 0 Then frame = 0
If sx = box\w-32 Then frame = 2
DrawImage tiles,box\x+sx,box\y,frame
Next
box\y = box\y + ScrollSpeed
If box\y > GraphicsHeight()
box\x = Rand(0,GraphicsWidth()/32)*32
box\y = -32
box\w = Rand(2,5)*32
If Rand(0,5) = 1
coin.coin = New coin
coin\x = Rand(box\x,box\x+box\w)
coin\y = box\y-16
End If
End If
Next
For coin.coin = Each coin
DrawImage coins,coin\x,coin\y,coin\frame
coin\y = coin\y + ScrollSpeed
coin\frame = (coin\frame + 0.25) Mod 7
If RectsOverlap(x-2,y-2,5,5,coin\x,coin\y,16,16)
score = score + 100
Delete coin
ElseIf coin\y > GraphicsHeight()
Delete coin
End If
Next
; check of hitting sides, anypixel with a green component counts as solid.
deck=False
; Sides of screen
If x<10 Or x>GraphicsWidth()-10
x = oldx
xd = -xd/2
End If
; Bottom of screen
If y>GraphicsHeight()
gameover = True
End If
For box.box = Each box
; Y Collision
If yd>0
collision = PointInBox(x,y+2,box)
deck=True
Else
collision = PointInBox(x,y-2,box)
EndIf
If collision
y = oldy
xd=xd*.9
yd=-yd/3
EndIf
; X Collision
If xd>0
collision = PointInBox(x+2,y,box)
Else
collision = PointInBox(x-2,y,box)
EndIf
If collision
x=oldx
xd=-xd/2
EndIf
Next
Color 255,255,255
Outline_Text GraphicsWidth()-120,10,"SCORE "+Replace(RSet(score,8)," ","0")
If gameover
Color 255,255,255
Outline_Text GraphicsWidth()/2,GraphicsHeight()/2,"GAME OVER",True,True
Else
; draw player
Color 255,255,255
Rect x-2,y-2,5,5,True
Line x,y,x+(Sin(-angle)*10),y+(Cos(-angle)*10)
; draw power bar
Color 255,0,0
Rect 0,2,(GraphicsWidth()/100)*power,6
End If
Flip
ScrollSpeed = ScrollSpeed + 0.00001
Until KeyHit(1)
End
Function Outline_Text(x,y,t$,cx=False,cy=False)
Color 0,0,0
For i = -1 To 1
For j = -1 To 1
Text x+i,y+j,t,cx,cy
Next
Next
Color 255,255,255
Text x,y,t,cx,cy
End Function
Function PointInBox(x,y,box.box)
If x=>box\x And x<=box\x+box\w
If y=>box\y And y<=box\y+box\h
Return True
End If
End If
Return False
End FunctionYou need these:![]() ![]() ![]() Somebody make a character for the player! And monsters :) |
| ||
![]() Maybe this? |
| ||
Not quite working...... |
| ||
| I changed the character (to get the animation right, but the frog was cuter!) and a bit of other stuff. You can control the blob while you are in the air by pressing left and right. And you don't bounce off sides or bottoms of platforms anymore. Type box
Field x#,y#,w,h
End Type
Type coin
Field x#,y#,frame#
End Type
Type Player
Field x#,y#,frame#
Field xd#,yd#,angle#
Field Width, Height
End Type
Type Message
Field x,y#,life,txt$
End Type
Graphics 640,480,0,2
power#=0
Const keyleft=203
Const keyright=205
Const keyjump=208
Const keyFineAngle = 54
Global gotr=0
Global gotg=0
Global gotb=0
Global angleMod = 5
Global Player.Player = New Player
Player\x#=GraphicsWidth()/2
Player\y#=GraphicsHeight()/2
Player\frame = 5
Player\xd# = 0
Player\yd# = 0
Player\angle# = 180
Player\Width = 16
Player\Height = 16
SetBuffer BackBuffer()
SeedRnd 1010
For n=1 To 20
box.box = New box
box\x = Rand(0,GraphicsWidth()/32)*32
box\y = Rand(0,GraphicsHeight()/32)*32
box\w = Rand(2,5)*32
box\h = 32
Next
For box.box = Each box
If Rand(0,2) = 1
coin.coin = New coin
coin\x = Rand(box\x,box\x+box\w)
coin\y = box\y-16
End If
Next
backdrop = LoadImage("Background00.png")
tiles = LoadAnimImage("Tiles00.png",32,32,0,3)
coins = LoadAnimImage("Coins00.png",16,16,0,8)
character = LoadAnimImage("character00.png", 16,16,0,11*5)
HandleImage character, Player\Width/2,Player\Height-2
backscroll# = GraphicsHeight()-ImageHeight(backdrop)
scrollspeed# = 0.1
Score = 0
ClsColor 154,198,237
jump = True
SetFont LoadFont("tahoma",11)
Repeat
Cls
backscroll = backscroll + (scrollspeed*0.025)
DrawImage backdrop,0,backscroll
If jump = False
If KeyDown(keyFineAngle) Then angleMod = 1 Else angleMod = 5
If KeyDown(keyright) And Player\angle<270 Then Player\angle=Player\angle+angleMod
If KeyDown(keyleft) And Player\angle>90 Then Player\angle=Player\angle-angleMod
Else
If KeyDown(keyright) Then player\xd = player\xd+0.05
If KeyDown(keyleft) Then player\xd = player\xd-0.05
End If
If KeyDown(keyjump) And jump=False And Int(xd+yd)=0 Then power=power+2
If power>100 Then power=100
; jump
If KeyDown(keyjump)=False And power>0
power=power/10
Player\xd=Sin(-Player\angle)*power
Player\yd=Cos(-Player\angle)*power
power=0
jump = True
deck=False
EndIf
If jump
Player\yd = Player\yd+.1
Player\xd = Player\xd*.99
Player\yd = Player\yd*.99
Else
player\yd = 0
player\xd = 0
End If
oldx#=Player\x
oldy#=Player\y
Player\x=Player\x+Player\xd
Player\y=Player\y+Player\yd+scrollspeed
; draw level
For box.box = Each box
For sx = 0 To box\w-32 Step 32
frame = 1
If sx = 0 Then frame = 0
If sx = box\w-32 Then frame = 2
DrawImage tiles,box\x+sx,box\y,frame
Next
box\y = box\y + ScrollSpeed
If box\y > GraphicsHeight()
box\x = Rand(0,GraphicsWidth()/32)*32
box\y = -32
box\w = Rand(2,5)*32
If Rand(0,2) = 1
coin.coin = New coin
coin\x = Rand(box\x,box\x+box\w)
coin\y = box\y-16
End If
End If
Next
For coin.coin = Each coin
DrawImage coins,coin\x,coin\y,coin\frame
coin\y = coin\y + ScrollSpeed
coin\frame = (coin\frame + 0.1) Mod 7
If RectsOverlap(Player\x-2,Player\y-2,5,5,coin\x,coin\y,16,16)
score = score + 100
m.message = New message
m\x = coin\x
m\y = coin\y-10
m\life = 100
m\txt = "100"
Delete coin
ElseIf coin\y > GraphicsHeight()
Delete coin
End If
Next
; Player frame
temp = Abs(Int(player\yd))*11
If temp>22 Then temp = 22
Player\frame = 27 + (((player\angle-180)/90.0)*5) - (Int(power/50)*11) + temp
; check of hitting sides, anypixel with a green component counts as solid.
; Sides of screen
If Player\x<10 Or Player\x>GraphicsWidth()-10
Player\x = oldx
Player\xd = -Player\xd/2
End If
; Top of screen
If player\y<0
player\y = oldy
player\yd = 0
End If
; Bottom of screen
If Player\y>GraphicsHeight()+40
gameover = True
End If
For box.box = Each box
; Y Collision
If Player\yd>0
collisionA = PointInBox(Player\x,Player\y+1,box)
collisionB = PointInBox(Player\x,Player\y-5,box)
If collisionA = True And collisionB = False
deck = True
Player\y = oldy
Player\xd=Player\xd*.9
Player\yd=-Player\yd/3
If Abs(player\xd)<0.2 And Abs(player\yd)<0.2
jump = False
End If
EndIf
EndIf
; X Collision
;If Player\xd>0
; collision = PointInBox(Player\x+2,Player\y,box)
;Else
; collision = PointInBox(Player\x-2,Player\y,box)
;EndIf
;If collision
; Player\x=oldx
; Player\xd=-Player\xd/2
;EndIf
Next
If gameover
Outline_Text GraphicsWidth()/2,GraphicsHeight()/2,"GAME OVER",True,True
Else
; draw player
If jump = False
Color 255,0,0
Line Player\x+(Sin(-Player\angle)*16),Player\y-4+(Cos(-Player\angle)*16),Player\x+(Sin(-Player\angle)*32),Player\y-4+(Cos(-Player\angle)*32)
End If
DrawImage character, Player\X,Player\Y,Player\frame
; draw power bar
Color power*2.55,255-(power*1.28),0
Rect 8,GraphicsHeight()-power-24,12,power
End If
Color 0,0,0
Rect 8 ,GraphicsHeight()-100-24,14,100,False
Rect 10,GraphicsHeight()-100-22,10,96,False
Color 255,255,255
Rect 9,GraphicsHeight()-100-23,12,98,False
Outline_Text 8,GraphicsHeight()-18,"POWER"
Outline_Text GraphicsWidth()-84,10,"SCORE "+Replace(RSet(score,8)," ","0")
For m.message = Each message
m\y = m\y - 0.5
m\life = m\life - 1
If Rand(0,50)<m\life
Outline_Text m\x,m\y,m\txt,True,True
End If
If m\life <= 0
Delete m
End If
Next
Flip
ScrollSpeed = ScrollSpeed + 0.00001
Until KeyHit(1)
End
Function Outline_Text(x,y,t$,cx=False,cy=False)
Color 0,0,0
For i = -1 To 1
For j = -1 To 1
Text x+i,y+j,t,cx,cy
Next
Next
Color 255,255,255
Text x,y,t,cx,cy
End Function
Function PointInBox(x,y,box.box)
If x=>box\x And x<=box\x+box\w
If y=>box\y And y<=box\y+box\h
Return True
End If
End If
Return False
End FunctionNew character image:![]() Changed the coin image as well (you may need to reload): ![]() Same old: ![]() ![]() This is great fun, everybody should contribute! |
| ||
| Lol ! very great code fredborg !!! :) |
| ||
| http://67.18.68.179/~gaianova/currentgame.zip Added rockfall :) was a quickjob, but it's fun |
| ||
| Lives and warning arrows before the rocks come crashing down :) http://www.frecle.net/misc/JumpAround.zip |
| ||
| added sound - coins, rocks, background and die. |
| ||
Added thrust for every 500 points (use up arrow to activate)thread preservation society ![]() *EDIT* modified to take into account the version with sounds. |
| ||
| A few extra effects :) http://www.frecle.net/misc/JumpAround.zip |
| ||
| cool :) |
| ||
Added monsters:![]()
Type box
Field x#,y#,w,h
End Type
Type coin
Field x#,y#,frame#
End Type
Type Player
Field x#,y#,frame#
Field xd#,yd#,angle#
Field Width, Height
End Type
Type monster
Field x#,y#,frame#
Field xd#
Field box.box
End Type
Graphics 640,480,0,2
power#=0
Const keyleft=203
Const keyright=205
Const keyjump=208
Const keyFineAngle = 54
Global gotr=0
Global gotg=0
Global gotb=0
Global angleMod = 5
Global Player.Player = New Player
Global jump
Global Score
Global Scrollspeed#
Global highscore=200
SetBuffer BackBuffer()
Reset()
backdrop = LoadImage("Background00.png")
tiles = LoadAnimImage("Tiles00.png",32,32,0,3)
coins = LoadAnimImage("Coins00.png",16,16,0,8)
character = LoadAnimImage("character00.png", 16,16,0,11*5)
monsters = LoadAnimImage("Monster00.png",16,16,0,4)
HandleImage character, Player\Width/2,Player\Height-2
backscroll# = GraphicsHeight()-ImageHeight(backdrop)
ClsColor 154,198,237
gameover=True
Repeat
Cls
backscroll = backscroll + (scrollspeed*0.025)
DrawImage backdrop,0,backscroll
If jump = False
If KeyDown(keyFineAngle) Then angleMod = 1 Else angleMod = 5
If KeyDown(keyright) And Player\angle<270 Then Player\angle=Player\angle+angleMod
If KeyDown(keyleft) And Player\angle>90 Then Player\angle=Player\angle-angleMod
Else
If KeyDown(keyright) Then player\xd = player\xd+0.05
If KeyDown(keyleft) Then player\xd = player\xd-0.05
End If
If KeyDown(keyjump) And jump=False And Int(xd+yd)=0 Then power=power+2
If power>100 Then power=100
; jump
If KeyDown(keyjump)=False And power>0
power=power/10
Player\xd=Sin(-Player\angle)*power
Player\yd=Cos(-Player\angle)*power
power=0
jump = True
deck=False
EndIf
If jump
Player\yd = Player\yd+.1
Player\xd = Player\xd*.99
Player\yd = Player\yd*.99
Else
player\yd = 0
player\xd = 0
End If
oldx#=Player\x
oldy#=Player\y
Player\x=Player\x+Player\xd
Player\y=Player\y+Player\yd+scrollspeed
; draw level
For box.box = Each box
For sx = 0 To box\w-32 Step 32
frame = 1
If sx = 0 Then frame = 0
If sx = box\w-32 Then frame = 2
DrawImage tiles,box\x+sx,box\y,frame
Next
box\y = box\y + ScrollSpeed
If box\y > GraphicsHeight()
box\x = Rand(0,GraphicsWidth()/32)*32
box\y = -32
box\w = Rand(2,5)*32
If Rand(0,2) = 1
coin.coin = New coin
coin\x = Rand(box\x,box\x+box\w)
coin\y = box\y-16
End If
If Rand(0,3)=1
monster.monster=New monster
monster\x=Rand(box\x,box\x+box\w)
monster\y=box\y-16
monster\box=box
If Rand(0,1)=0
monster\xd=-Rnd(0.1,0.5)
Else
monster\xd=Rnd(0.1,0.5)
EndIf
EndIf
End If
Next
For coin.coin = Each coin
DrawImage coins,coin\x,coin\y,coin\frame
coin\y = coin\y + ScrollSpeed
coin\frame = (coin\frame + 0.1) Mod 7
If RectsOverlap(Player\x-2,Player\y-2,5,5,coin\x,coin\y,16,16)
score = score + 100
If score>highscore
highscore=score
EndIf
Delete coin
ElseIf coin\y > GraphicsHeight()
Delete coin
End If
Next
For monster.monster=Each monster
DrawImage monsters,monster\x,monster\y,monster\frame
monster\y=monster\y+ScrollSpeed
monster\frame = (monster\frame + 0.1) Mod 3
monster\x=monster\x+monster\xd
If monster\x+16>monster\box\x+monster\box\w
monster\xd=-Rnd(0.1,0.5)
ElseIf monster\x<monster\box\x
monster\xd=Rnd(0.1,0.5)
EndIf
If RectsOverlap(Player\x-2,Player\y-2,5,5,monster\x,monster\y,16,16)
gameover = True
ElseIf monster\y > GraphicsHeight()
Delete monster
End If
Next
; Player frame
temp = Abs(Int(player\yd))*11
If temp>22 Then temp = 22
Player\frame = 27 + (((player\angle-180)/90.0)*5) - (Int(power/50)*11) + temp
; check of hitting sides, anypixel with a green component counts as solid.
; Sides of screen
If Player\x<10 Or Player\x>GraphicsWidth()-10
Player\x = oldx
Player\xd = -Player\xd/2
End If
; Top of screen
If player\y<0
player\y = oldy
player\yd = 0
End If
; Bottom of screen
If Player\y>GraphicsHeight()+40
gameover = True
End If
For box.box = Each box
; Y Collision
If Player\yd>0
collisionA = PointInBox(Player\x,Player\y+1,box)
collisionB = PointInBox(Player\x,Player\y-5,box)
If collisionA = True And collisionB = False
deck = True
Player\y = oldy
Player\xd=Player\xd*.9
Player\yd=-Player\yd/3
If Abs(player\xd)<0.2 And Abs(player\yd)<0.2
jump = False
End If
EndIf
EndIf
; X Collision
;If Player\xd>0
; collision = PointInBox(Player\x+2,Player\y,box)
;Else
; collision = PointInBox(Player\x-2,Player\y,box)
;EndIf
;If collision
; Player\x=oldx
; Player\xd=-Player\xd/2
;EndIf
Next
If gameover
Outline_Text GraphicsWidth()/2,GraphicsHeight()/2,"GAME OVER",True,True
If Sin(MilliSecs()/2)>0
Outline_Text GraphicsWidth()/2,GraphicsHeight()/2+GraphicsHeight()/4,"INSERT COIN",True,True
EndIf
If KeyDown(57)
gameover=False
Reset()
EndIf
Else
; draw player
If jump = False
Color 255,0,0
Line Player\x+(Sin(-Player\angle)*16),Player\y-4+(Cos(-Player\angle)*16),Player\x+(Sin(-Player\angle)*32),Player\y-4+(Cos(-Player\angle)*32)
End If
DrawImage character, Player\X,Player\Y,Player\frame
; draw power bar
Color power*2.55,255-(power*1.28),0
Rect 8,GraphicsHeight()-power-24,12,power
End If
Color 0,0,0
Rect 8 ,GraphicsHeight()-100-24,14,100,False
Rect 10,GraphicsHeight()-100-22,10,96,False
Color 255,255,255
Rect 9,GraphicsHeight()-100-23,12,98,False
Outline_Text 8,GraphicsHeight()-18,"POWER"
Outline_Text GraphicsWidth()-120,10,"SCORE "+Replace(RSet(score,8)," ","0")
Outline_Text 10,10,"HIGHSCORE "+Replace(RSet(highscore,8)," ","0")
Flip
ScrollSpeed = ScrollSpeed + 0.00001
Until KeyHit(1)
End
Function Reset(seed=1014)
Delete Each box
Delete Each coin
Delete Each monster
Player\x#=GraphicsWidth()/2
Player\y#=GraphicsHeight()/2
Player\frame = 5
Player\xd# = 0
Player\yd# = 0
Player\angle# = 180
Player\Width = 16
Player\Height = 16
SeedRnd seed
box.box=New box
box\x=0
box\y=GraphicsHeight()-128
box\w=GraphicsWidth()
box\h=32
For n=1 To 20
box.box = New box
box\x = Rand(0,GraphicsWidth()/32)*32
box\y = Rand(0,(GraphicsHeight()-160)/32)*32
box\w = Rand(2,5)*32
box\h = 32
Next
For box.box = Each box
If Rand(0,2) = 1
coin.coin = New coin
coin\x = Rand(box\x,box\x+box\w)
coin\y = box\y-16
End If
If Rand(0,3)=1
monster.monster=New monster
monster\x=Rand(box\x,box\x+box\w)
monster\y=box\y-16
monster\box=box
If Rand(0,1)=0
monster\xd=-Rnd(0.1,0.5)
Else
monster\xd=Rnd(0.1,0.5)
EndIf
EndIf
Next
jump = True
scrollspeed# = 0.1
Score = 0
End Function
Function Outline_Text(x,y,t$,cx=False,cy=False)
Color 0,0,0
For i = -1 To 1
For j = -1 To 1
Text x+i,y+j,t,cx,cy
Next
Next
Color 255,255,255
Text x,y,t,cx,cy
End Function
Function PointInBox(x,y,box.box)
If x=>box\x And x<=box\x+box\w
If y=>box\y And y<=box\y+box\h
Return True
End If
End If
Return False
End Function
|
| ||
| Haha, that's cool Jeppe! You should put it into this version: http://www.frecle.net/misc/JumpAround.zip Best fun I've had for ages! |
| ||
| Best fun I've had for ages! Yeah, and I don't think this game would have evolved so quickly with just one person. This should be added to the code archives for people to learn from. *EDIT* I also think this should be a regular thing. It encourages community cooperation and will help everyone improve their skills. |
| ||
This is pretty fun, actually. I have added the monsters to the latest version, and added saveable highscore, and a reset() game function, to start the game after you´re game over:
Type box
Field x#,y#,w,h
End Type
Type coin
Field x#,y#,frame#
End Type
Type Player
Field x#,y#,frame#
Field xd#,yd#,angle#
Field Width, Height
Field lives
Field Thrust#
Field Thrusting
Field ThrustFrame
Field ThrustFrameDir
End Type
Type Message
Field x,y#,life,txt$
End Type
Type rock
Field x#,y#
Field speed#
End Type
Type poof
Field x#,y#,sx#,sy#
Field count
End Type
Type dust
Field x#,y#,sx#,sy#
End Type
Type monster
Field x#,y#,frame#
Field xd#
Field box.box
End Type
Graphics 640,480,0,2
HidePointer
power#=0
Const keyleft=203
Const keyright=205
Const keyjump=208
Const keyUp = 200
Const keyFineAngle = 54
Global gotr=0
Global gotg=0
Global gotb=0
Global angleMod = 5
Global Player.Player = New Player
Global jump
Global Score
Global Scrollspeed#
Global highscore
highfile=OpenFile("HighScore")
If highfile
highscore=ReadLine(highfile)
CloseFile highfile
Else
highscore=200
highfile=WriteFile("HighScore")
WriteLine highfile,highscore
CloseFile highfile
EndIf
Global gameover = True
SetBuffer BackBuffer()
Reset()
Global getcoin = LoadSound("coin.wav")
Global die = LoadSound("die.wav")
Global dieplayed = False
Global bg = LoadSound("bg.ogg")
LoopSound bg
Global bgchannel = PlaySound(bg)
Global boom = LoadSound("boom.wav")
backdrop = LoadImage("Background00.png")
arrow = LoadImage("arrow00.png")
rockimage = LoadImage("Fall00.png")
poofimage = LoadImage("poof00.png")
tiles = LoadAnimImage("Tiles00.png",32,32,0,3)
coins = LoadAnimImage("Coins00.png",16,16,0,8)
character = LoadAnimImage("character00.png", 16,16,0,11*5)
HandleImage character, Player\Width/2,Player\Height-2
thruster = LoadAnimImage("thrust00.png", 16,16,0,3)
HandleImage thruster, 8, 0
monsters = LoadAnimImage("Monster00.png",16,16,0,4)
backscroll# = GraphicsHeight()-ImageHeight(backdrop)
ClsColor 154,198,237
SetFont LoadFont("tahoma",11)
Repeat
Cls
backscroll = backscroll + (scrollspeed*0.025)
DrawImage backdrop,0,backscroll
If jump = False
If KeyDown(keyFineAngle) Then angleMod = 1 Else angleMod = 5
If KeyDown(keyright) And Player\angle<270 Then Player\angle=Player\angle+angleMod
If KeyDown(keyleft) And Player\angle>90 Then Player\angle=Player\angle-angleMod
Else
If KeyDown(keyright) Then player\xd = player\xd+0.05
If KeyDown(keyleft) Then player\xd = player\xd-0.05
End If
If KeyDown(keyUp) And Player\Thrust > 0 Then
Player\yd = Player\yd-0.2
Player\Thrust = Player\Thrust - 0.1
Player\Thrusting = True
jump = True
DebugLog Player\Thrust
Else
Player\Thrusting = False
EndIf
If KeyDown(keyjump) And jump=False And Int(xd+yd)=0 Then power=power+2
If power>100 Then power=100
; jump
If KeyDown(keyjump)=False And power>0
power=power/10
Player\xd=Sin(-Player\angle)*power
Player\yd=Cos(-Player\angle)*power
power=0
jump = True
deck=False
EndIf
If jump
Player\yd = Player\yd+.1
Player\xd = Player\xd*.99
Player\yd = Player\yd*.99
Else
player\yd = 0
player\xd = 0
End If
oldx#=Player\x
oldy#=Player\y
Player\x=Player\x+Player\xd
Player\y=Player\y+Player\yd+scrollspeed
; draw level
For box.box = Each box
For sx = 0 To box\w-32 Step 32
frame = 1
If sx = 0 Then frame = 0
If sx = box\w-32 Then frame = 2
DrawImage tiles,box\x+sx,box\y,frame
Next
box\y = box\y + ScrollSpeed
If box\y > GraphicsHeight()
box\x = Rand(0,GraphicsWidth()/32)*32
box\y = -32
box\w = Rand(2,5)*32
If Rand(0,2) = 1
coin.coin = New coin
coin\x = Rand(box\x,box\x+box\w)
coin\y = box\y-16
End If
If Rand(0,3)=1
monster.monster=New monster
monster\x=Rand(box\x,box\x+box\w)
monster\y=box\y-16
monster\box=box
If Rand(0,1)=0
monster\xd=-Rnd(0.1,0.5)
Else
monster\xd=Rnd(0.1,0.5)
EndIf
EndIf
End If
Next
For coin.coin = Each coin
DrawImage coins,coin\x,coin\y,coin\frame
coin\y = coin\y + ScrollSpeed
coin\frame = (coin\frame + 0.1) Mod 7
If RectsOverlap(Player\x-2,Player\y-2,5,5,coin\x,coin\y,16,16)
score = score + 100
If score>highscore
highscore=score
highfile=WriteFile("HighScore")
WriteLine highfile,highscore
CloseFile highfile
EndIf
m.message = New message
m\x = coin\x
m\y = coin\y-10
m\life = 100
m\txt = "100"
PlaySound(getcoin)
Delete coin
If (Score Mod 500) = 0 Then Player\Thrust=Player\Thrust+10
ElseIf coin\y > GraphicsHeight()
Delete coin
End If
Next
For monster.monster=Each monster
DrawImage monsters,monster\x,monster\y,monster\frame
monster\y=monster\y+ScrollSpeed
monster\frame = (monster\frame + 0.1) Mod 3
monster\x=monster\x+monster\xd
If monster\x+16>monster\box\x+monster\box\w
monster\xd=-Rnd(0.1,0.5)
ElseIf monster\x<monster\box\x
monster\xd=Rnd(0.1,0.5)
EndIf
dx#=((monster\x+8)-player\x)
dy#=(monster\y+8-player\y)
If (dx*dx+dy*dy)<32*32
If Sin(MilliSecs())>0
Outline_text player\x,player\y-30,"Watch out!",1,1
EndIf
EndIf
If RectsOverlap(Player\x-2,Player\y-2,5,5,monster\x,monster\y,16,16)
LooseLife(player)
ElseIf monster\y > GraphicsHeight()
Delete monster
End If
Next
; Player frame
temp = Abs(Int(player\yd))*11
If temp>22 Then temp = 22
Player\frame = 27 + (((player\angle-180)/90.0)*5) - (Int(power/50)*11) + temp
; check of hitting sides, anypixel with a green component counts as solid.
; Sides of screen
If Player\x<10 Or Player\x>GraphicsWidth()-10
Player\x = oldx
Player\xd = -Player\xd/2
End If
; Top of screen
If player\y<0
player\y = oldy
player\yd = 0
End If
; Bottom of screen
If Player\y>GraphicsHeight()+40
LooseLife(player)
End If
For box.box = Each box
; Y Collision
If Player\yd>0
collisionA = PointInBox(Player\x,Player\y+1,box)
collisionB = PointInBox(Player\x,Player\y-5,box)
If collisionA = True And collisionB = False
deck = True
Player\y = oldy
Player\xd=Player\xd*.9
Player\yd=-Player\yd/3
If Abs(player\xd)<0.2 And Abs(player\yd)<0.2
jump = False
End If
EndIf
EndIf
Next
If gameover
Outline_Text GraphicsWidth()/2,GraphicsHeight()/2,"GAME OVER",True,True
If Sin(MilliSecs()/2)>0
Outline_Text GraphicsWidth()/2,GraphicsHeight()/2+GraphicsHeight()/4,"INSERT COIN",True,True
EndIf
If KeyDown(57)
gameover=False
Reset()
EndIf
Else
; draw player
If jump = False
Color 255,0,0
Line Player\x+(Sin(-Player\angle)*16),Player\y-4+(Cos(-Player\angle)*16),Player\x+(Sin(-Player\angle)*32),Player\y-4+(Cos(-Player\angle)*32)
End If
DrawImage character, Player\X,Player\Y,Player\frame
If Player\Thrusting Then
;DebugLog Player\ThrustFrame
DrawImage thruster, Player\X,Player\Y+2,Player\ThrustFrame
If Player\ThrustFrame = 0 Then Player\ThrustFrameDir = 1 ElseIf Player\ThrustFrame = 2 Then Player\ThrustFrameDir = -1
Player\ThrustFrame = Player\ThrustFrame + Player\ThrustFrameDir
EndIf
End If
; Draw Power bar
DrawBar(8,GraphicsHeight(),power,100,"POWER")
; Draw Thrust bar
DrawBar(GraphicsWidth()-24,GraphicsHeight(),player\thrust,10,"THRUST",True)
; rocks!
If Rand(0,100) = 0
rock.rock = New rock
rock\x = Rand(16,GraphicsWidth()-16)
rock\y = -600
rock\speed = Rnd(2,4)
EndIf
For rock.Rock = Each rock
kill =False
rock\y = rock\y + rock\speed
If rock\y<-32
If Rand(-600,-100)<rock\y
DrawImage arrow,rock\x,8
End If
Else
DrawImage rockImage, rock\x,rock\y
End If
If rock\y > GraphicsHeight()
kill = True
EndIf
For box.box = Each box
collisionA = PointInBox(rock\x,rock\y+16,box)
collisionB = PointInBox(rock\x,rock\y+10,box)
If collisionA = True And collisionB = False
For i = 0 To 10
poof.poof = New poof
poof\x = rock\x
poof\y = rock\y
a# = Rnd(0,360)
ms# = Rnd(1.5,5.0)
poof\sx = Sin(a)*ms
poof\sy = Cos(a)*ms
Next
Dustify(rock\x+16,rock\y,120,100,80)
kill = True
EndIf
Next
If ImagesOverlap(character,player\x,player\y,rockImage,rock\x,rock\y)
For i = 0 To 10
poof.poof = New poof
poof\x = rock\x
poof\y = rock\y
a# = Rnd(0,360)
ms# = Rnd(1.5,5.0)
poof\sx = Sin(a)*ms
poof\sy = Cos(a)*ms
Next
Dustify(rock\x+16,rock\y,120,180,140)
kill = True
LooseLife(player)
EndIf
If kill
SoundVolume boom,.1
PlaySound(boom)
Delete rock
End If
Next
drawpoof = Not drawpoof
If drawpoof
For poof.poof = Each poof
poof\x = poof\x + poof\sx
poof\y = poof\y + poof\sy
poof\sx = poof\sx * 0.9
poof\sy = poof\sy * 0.9
If Rand(10,20)>poof\count
DrawImage poofImage, poof\x,poof\y
End If
poof\count = poof\count + 1
If poof\count > 20 Then Delete poof
Next
End If
Color 120,100,80
For dust.dust = Each dust
dust\x = dust\x + dust\sx
dust\y = dust\y + dust\sy
dust\sx = dust\sx * Rnd(0.95,0.999)
dust\sy = (dust\sy * Rnd(0.95,0.999)) + 0.1
Rect dust\x,dust\y,2,2
If dust\y > GraphicsHeight() Then Delete dust
Next
Outline_Text GraphicsWidth()-84,10,"SCORE "+Replace(RSet(score,8)," ","0")
Outline_Text GraphicsWidth()/2,10,"HIGHSCORE "+Replace(RSet(highscore,8)," ","0"),True
For i = 1 To player\lives
DrawImage character,((i-1)*16)+8,12,27
Next
For m.message = Each message
m\y = m\y - 0.5
m\life = m\life - 1
If Rand(0,50)<m\life
Outline_Text m\x,m\y,m\txt,True,True
End If
If m\life <= 0
Delete m
End If
Next
Flip
ScrollSpeed = ScrollSpeed + 0.00001
Until KeyHit(1)
End
Function Reset(seed=1014)
Delete Each box
Delete Each coin
Delete Each monster
Delete Each Message
Delete Each rock
Delete Each poof
Delete Each dust
Player\x#=GraphicsWidth()/2
Player\y#=GraphicsHeight()/2
Player\frame = 5
Player\xd# = 0
Player\yd# = 0
Player\angle# = 180
Player\Width = 16
Player\Height = 16
Player\lives=3
SeedRnd seed
box.box=New box
box\x=0
box\y=GraphicsHeight()-128
box\w=GraphicsWidth()
box\h=32
For n=1 To 20
box.box = New box
box\x = Rand(0,GraphicsWidth()/32)*32
box\y = Rand(0,(GraphicsHeight()-160)/32)*32
box\w = Rand(2,5)*32
box\h = 32
Next
For box.box = Each box
If Rand(0,2) = 1
coin.coin = New coin
coin\x = Rand(box\x,box\x+box\w)
coin\y = box\y-16
End If
If Rand(0,3)=1
monster.monster=New monster
monster\x=Rand(box\x,box\x+box\w)
monster\y=box\y-16
monster\box=box
If Rand(0,1)=0
monster\xd=-Rnd(0.1,0.5)
Else
monster\xd=Rnd(0.1,0.5)
EndIf
EndIf
Next
jump = True
scrollspeed# = 0.1
Score = 0
End Function
Function DrawBar(x,y,val#,max#,txt$,lf=False)
val = val/(max/100.0)
Color val*2.55,255-(val*1.28),0
Rect x,y-val-24,12,val
Color 0,0,0
Rect x ,y-100-24,14,100,False
Rect x+2,y-100-22,10,96,False
Color 255,255,255
Rect x+1,y-100-23,12,98,False
If lf
Outline_Text x+14-StringWidth(txt),y-18,txt$
Else
Outline_Text x,y-18,txt$
End If
End Function
Function Dustify(x,y,r,g,b)
For i = 0 To 30
d.dust = New dust
d\x = x
d\y = y
d\sx = Rnd(-2.0,2.0)
d\sy = Rnd(-5.0,2.0)
Next
End Function
Function LooseLife(player.player)
player\lives = player\lives-1
If player\lives < 0
gameover = True
player\x=-100
Return
Else
; reposition player
For box.box = Each box
If box\y<GraphicsHeight()-100 And box\y>100
If box\x>0 And box\x+box\w<GraphicsWidth()
player\y = box\y-32
player\x = Rand(box\x,box\x+box\w)
player\xd = 0
player\yd = 0
Exit
End If
End If
Next
End If
channel = PlaySound(die)
End Function
Function Outline_Text(x,y,t$,cx=False,cy=False)
Color 0,0,0
For i = -1 To 1
For j = -1 To 1
Text x+i,y+j,t,cx,cy
Next
Next
Color 255,255,255
Text x,y,t,cx,cy
End Function
Function PointInBox(x,y,box.box)
If x=>box\x And x<=box\x+box\w
If y=>box\y And y<=box\y+box\h
Return True
End If
End If
Return False
End Function
It is pretty nice to see how this has developed, if you see what it began with :) |
| ||
| I love those little monsters :) WATCH OUT :) I put an updated zip together: http://www.frecle.net/misc/JumpAround.zip |
| ||
Thread police, code confiscated BUGFIXES: Corrected spelling of function LoseLife Limited thrust via THRUST_MAX const, preventing thrust bar exceeding bounds of box. Prevented coin being placed too far to the right. *EDIT* Angle now resets to 180 when deck is true |
| ||
For those that don't look at games without a screenshot, here's what it currently looks like: |
| ||
| And a zip with code and media is here: http://www.frecle.net/misc/JumpAround.zip |
| ||
Now added birds, in the background :)![]() I forgot to mention before, that I also have added a "watch out!" text above the players head, if he is to close to any monsters.
Type box
Field x#,y#,w,h
End Type
Type coin
Field x#,y#,frame#
End Type
Type Player
Field x#,y#,frame#
Field xd#,yd#,angle#
Field Width, Height
Field lives
Field Thrust#
Field Thrusting
Field ThrustFrame
Field ThrustFrameDir
End Type
Type Message
Field x,y#,life,txt$
End Type
Type rock
Field x#,y#
Field speed#
End Type
Type poof
Field x#,y#,sx#,sy#
Field count
End Type
Type dust
Field x#,y#,sx#,sy#
End Type
Type monster
Field x#,y#,frame#
Field xd#
Field box.box
End Type
Type bird
Field x#,y#,frame#
Field vx#,vy#
End Type
Graphics 640,480,0,2
HidePointer
power#=0
Const keyleft=203
Const keyright=205
Const keyjump=208
Const keyUp = 200
Const keyFineAngle = 54
Const THRUST_MAX = 50
Global gotr=0
Global gotg=0
Global gotb=0
Global angleMod = 5
Global Player.Player = New Player
Global jump
Global Score
Global Scrollspeed#
Global highscore
highfile=OpenFile("HighScore")
If highfile
highscore=ReadLine(highfile)
CloseFile highfile
Else
highscore=200
highfile=WriteFile("HighScore")
WriteLine highfile,highscore
CloseFile highfile
EndIf
Global gameover = True
SetBuffer BackBuffer()
Reset()
Global getcoin = LoadSound("coin.wav")
Global die = LoadSound("die.wav")
Global dieplayed = False
Global bg = LoadSound("bg.ogg")
LoopSound bg
Global bgchannel = PlaySound(bg)
Global boom = LoadSound("boom.wav")
backdrop = LoadImage("Background00.png")
arrow = LoadImage("arrow00.png")
rockimage = LoadImage("Fall00.png")
poofimage = LoadImage("poof00.png")
tiles = LoadAnimImage("Tiles00.png",32,32,0,3)
coins = LoadAnimImage("Coins00.png",16,16,0,8)
character = LoadAnimImage("character00.png", 16,16,0,11*5)
HandleImage character, Player\Width/2,Player\Height-2
thruster = LoadAnimImage("thrust00.png", 16,16,0,3)
HandleImage thruster, 8, 0
monsters = LoadAnimImage("Monster00.png",16,16,0,4)
birds = LoadAnimImage("Bird00.png",16,16,0,4)
backscroll# = GraphicsHeight()-ImageHeight(backdrop)
ClsColor 154,198,237
SetFont LoadFont("tahoma",11)
Repeat
Cls
backscroll = backscroll + (scrollspeed*0.025)
DrawImage backdrop,0,backscroll
If jump = False
If KeyDown(keyFineAngle) Then angleMod = 1 Else angleMod = 5
If KeyDown(keyright) And Player\angle<270 Then Player\angle=Player\angle+angleMod
If KeyDown(keyleft) And Player\angle>90 Then Player\angle=Player\angle-angleMod
Else
If KeyDown(keyright) Then player\xd = player\xd+0.05
If KeyDown(keyleft) Then player\xd = player\xd-0.05
End If
If KeyDown(keyUp) And Player\Thrust > 0 Then
Player\yd = Player\yd-0.2
Player\Thrust = Player\Thrust - 0.1
Player\Thrusting = True
jump = True
DebugLog Player\Thrust
Else
Player\Thrusting = False
EndIf
If KeyDown(keyjump) And jump=False And Int(xd+yd)=0 Then power=power+2
If power>100 Then power=100
; jump
If KeyDown(keyjump)=False And power>0
power=power/10
Player\xd=Sin(-Player\angle)*power
Player\yd=Cos(-Player\angle)*power
power=0
jump = True
deck=False
EndIf
If jump
Player\yd = Player\yd+.1
Player\xd = Player\xd*.99
Player\yd = Player\yd*.99
Else
player\yd = 0
player\xd = 0
End If
oldx#=Player\x
oldy#=Player\y
Player\x=Player\x+Player\xd
Player\y=Player\y+Player\yd+scrollspeed
For bird.bird=Each bird
DrawImage birds,bird\x,bird\y,bird\frame
bird\x=bird\x+bird\vx
bird\y=bird\y+bird\vy+ScrollSpeed
bird\frame = (bird\frame + 0.1) Mod 3
If bird\x<0
bird\x=GraphicsWidth()
EndIf
If bird\y<0
bird\y=GraphicsHeight()
EndIf
If bird\x>GraphicsWidth()
bird\x=0
EndIf
If bird\y>GraphicsHeight()
bird\y=0
EndIf
Next
; draw level
For box.box = Each box
For sx = 0 To box\w-32 Step 32
frame = 1
If sx = 0 Then frame = 0
If sx = box\w-32 Then frame = 2
DrawImage tiles,box\x+sx,box\y,frame
Next
box\y = box\y + ScrollSpeed
If box\y > GraphicsHeight()
box\x = Rand(0,GraphicsWidth()/32)*32
box\y = -32
box\w = Rand(2,5)*32
If Rand(0,2) = 1
coin.coin = New coin
coin\x = Rand(box\x,box\x+box\w)
;prevent a coin appearing too far to the right where the player can't reach it
If coin\x > GraphicsWidth()-10 Then coin\x = GraphicsWidth()-10
coin\y = box\y-16
End If
If Rand(0,3)=1
monster.monster=New monster
monster\x=Rand(box\x,box\x+box\w)
monster\y=box\y-16
monster\box=box
If Rand(0,1)=0
monster\xd=-Rnd(0.1,0.5)
Else
monster\xd=Rnd(0.1,0.5)
EndIf
EndIf
End If
Next
For coin.coin = Each coin
DrawImage coins,coin\x,coin\y,coin\frame
coin\y = coin\y + ScrollSpeed
coin\frame = (coin\frame + 0.1) Mod 7
If RectsOverlap(Player\x-2,Player\y-2,5,5,coin\x,coin\y,16,16)
score = score + 100
If score>highscore
highscore=score
highfile=WriteFile("HighScore")
WriteLine highfile,highscore
CloseFile highfile
EndIf
m.message = New message
m\x = coin\x
m\y = coin\y-10
m\life = 100
m\txt = "100"
PlaySound(getcoin)
Delete coin
If (Score Mod 500) = 0 Then Player\Thrust=Player\Thrust+10
If Player\Thrust > THRUST_MAX Then Player\Thrust = THRUST_MAX
If (Score Mod 5000) = 0 Then Player\Lives = Player\Lives + 1
ElseIf coin\y > GraphicsHeight()
Delete coin
End If
Next
For monster.monster=Each monster
DrawImage monsters,monster\x,monster\y,monster\frame
monster\y=monster\y+ScrollSpeed
monster\frame = (monster\frame + 0.1) Mod 3
monster\x=monster\x+monster\xd
If monster\x+16>monster\box\x+monster\box\w
monster\xd=-Rnd(0.1,0.5)
ElseIf monster\x<monster\box\x
monster\xd=Rnd(0.1,0.5)
EndIf
dx#=((monster\x+8)-player\x)
dy#=(monster\y+8-player\y)
If (dx*dx+dy*dy)<32*32
If Sin(MilliSecs())>0
Outline_text player\x,player\y-30,"Watch out!",1,1
EndIf
EndIf
If RectsOverlap(Player\x-2,Player\y-2,5,5,monster\x,monster\y,16,16)
LoseLife(player)
ElseIf monster\y > GraphicsHeight()
Delete monster
End If
Next
; Player frame
temp = Abs(Int(player\yd))*11
If temp>22 Then temp = 22
Player\frame = 27 + (((player\angle-180)/90.0)*5) - (Int(power/50)*11) + temp
; check of hitting sides, anypixel with a green component counts as solid.
; Sides of screen
If Player\x<10 Or Player\x>GraphicsWidth()-10
Player\x = oldx
Player\xd = -Player\xd/2
End If
; Top of screen
If player\y<0
player\y = oldy
player\yd = 0
End If
; Bottom of screen
If Player\y>GraphicsHeight()+40
LoseLife(player)
End If
For box.box = Each box
; Y Collision
If Player\yd>0
collisionA = PointInBox(Player\x,Player\y+1,box)
collisionB = PointInBox(Player\x,Player\y-5,box)
If collisionA = True And collisionB = False
deck = True
Player\y = oldy
Player\xd=Player\xd*.9
Player\yd=-Player\yd/3
Player\Angle = 180
If Abs(player\xd)<0.2 And Abs(player\yd)<0.2
jump = False
End If
EndIf
EndIf
Next
If gameover
Outline_Text GraphicsWidth()/2,GraphicsHeight()/2,"GAME OVER",True,True
If Sin(MilliSecs()/2)>0
Outline_Text GraphicsWidth()/2,GraphicsHeight()/2+GraphicsHeight()/4,"INSERT COIN",True,True
EndIf
If KeyDown(57)
gameover=False
Reset()
EndIf
Else
; draw player
If jump = False
Color 255,0,0
Line Player\x+(Sin(-Player\angle)*16),Player\y-4+(Cos(-Player\angle)*16),Player\x+(Sin(-Player\angle)*32),Player\y-4+(Cos(-Player\angle)*32)
End If
DrawImage character, Player\X,Player\Y,Player\frame
If Player\Thrusting Then
;DebugLog Player\ThrustFrame
DrawImage thruster, Player\X,Player\Y+2,Player\ThrustFrame
If Player\ThrustFrame = 0 Then Player\ThrustFrameDir = 1 ElseIf Player\ThrustFrame = 2 Then Player\ThrustFrameDir = -1
Player\ThrustFrame = Player\ThrustFrame + Player\ThrustFrameDir
EndIf
End If
; Draw Power bar
DrawBar(8,GraphicsHeight(),power,100,"POWER")
; Draw Thrust bar
DrawBar(GraphicsWidth()-24,GraphicsHeight(),player\thrust,THRUST_MAX,"THRUST",True)
; rocks!
If Rand(0,100) = 0
rock.rock = New rock
rock\x = Rand(16,GraphicsWidth()-16)
rock\y = -600
rock\speed = Rnd(2,4)
EndIf
For rock.Rock = Each rock
kill =False
rock\y = rock\y + rock\speed
If rock\y<-32
If Rand(-600,-100)<rock\y
DrawImage arrow,rock\x,8
End If
Else
DrawImage rockImage, rock\x,rock\y
End If
If rock\y > GraphicsHeight()
kill = True
EndIf
For box.box = Each box
collisionA = PointInBox(rock\x,rock\y+16,box)
collisionB = PointInBox(rock\x,rock\y+10,box)
If collisionA = True And collisionB = False
For i = 0 To 10
poof.poof = New poof
poof\x = rock\x
poof\y = rock\y
a# = Rnd(0,360)
ms# = Rnd(1.5,5.0)
poof\sx = Sin(a)*ms
poof\sy = Cos(a)*ms
Next
Dustify(rock\x+16,rock\y,120,100,80)
kill = True
EndIf
Next
If ImagesOverlap(character,player\x,player\y,rockImage,rock\x,rock\y)
For i = 0 To 10
poof.poof = New poof
poof\x = rock\x
poof\y = rock\y
a# = Rnd(0,360)
ms# = Rnd(1.5,5.0)
poof\sx = Sin(a)*ms
poof\sy = Cos(a)*ms
Next
Dustify(rock\x+16,rock\y,120,180,140)
kill = True
LoseLife(player)
EndIf
If kill
SoundVolume boom,.1
PlaySound(boom)
Delete rock
End If
Next
drawpoof = Not drawpoof
If drawpoof
For poof.poof = Each poof
poof\x = poof\x + poof\sx
poof\y = poof\y + poof\sy
poof\sx = poof\sx * 0.9
poof\sy = poof\sy * 0.9
If Rand(10,20)>poof\count
DrawImage poofImage, poof\x,poof\y
End If
poof\count = poof\count + 1
If poof\count > 20 Then Delete poof
Next
End If
Color 120,100,80
For dust.dust = Each dust
dust\x = dust\x + dust\sx
dust\y = dust\y + dust\sy
dust\sx = dust\sx * Rnd(0.95,0.999)
dust\sy = (dust\sy * Rnd(0.95,0.999)) + 0.1
Rect dust\x,dust\y,2,2
If dust\y > GraphicsHeight() Then Delete dust
Next
Outline_Text GraphicsWidth()-84,10,"SCORE "+Replace(RSet(score,8)," ","0")
Outline_Text GraphicsWidth()/2,10,"HIGHSCORE "+Replace(RSet(highscore,8)," ","0"),True
For i = 1 To player\lives
DrawImage character,((i-1)*16)+8,12,27
Next
For m.message = Each message
m\y = m\y - 0.5
m\life = m\life - 1
If Rand(0,50)<m\life
Outline_Text m\x,m\y,m\txt,True,True
End If
If m\life <= 0
Delete m
End If
Next
Flip
ScrollSpeed = ScrollSpeed + 0.00001
Until KeyHit(1)
End
Function Reset(seed=1014)
Delete Each box
Delete Each coin
Delete Each monster
Delete Each Message
Delete Each rock
Delete Each poof
Delete Each dust
Delete Each bird
Player\x#=GraphicsWidth()/2
Player\y#=GraphicsHeight()/2
Player\frame = 5
Player\xd# = 0
Player\yd# = 0
Player\angle# = 180
Player\Width = 16
Player\Height = 16
Player\lives=3
SeedRnd seed
box.box=New box
box\x=0
box\y=GraphicsHeight()-128
box\w=GraphicsWidth()
box\h=32
For n=1 To 20
box.box = New box
box\x = Rand(0,GraphicsWidth()/32)*32
box\y = Rand(0,(GraphicsHeight()-160)/32)*32
box\w = Rand(2,5)*32
box\h = 32
Next
For box.box = Each box
If Rand(0,2) = 1
coin.coin = New coin
coin\x = Rand(box\x,box\x+box\w)
coin\y = box\y-16
End If
If Rand(0,3)=1
monster.monster=New monster
monster\x=Rand(box\x,box\x+box\w)
monster\y=box\y-16
monster\box=box
If Rand(0,1)=0
monster\xd=-Rnd(0.1,0.5)
Else
monster\xd=Rnd(0.1,0.5)
EndIf
EndIf
Next
For n=1 To 20
bird.bird=New bird
bird\x = Rand(0,GraphicsWidth())
bird\y = Rand(0,GraphicsHeight())
If Rand(0,1)=0
bird\vx=Rnd(0.1,1)
Else
bird\vx=-Rnd(0.1,1)
EndIf
If Rand(0,1)=0
bird\vy=Rnd(0.1,1)
Else
bird\vy=-Rnd(0.1,1)
EndIf
Next
jump = True
scrollspeed# = 0.1
Score = 0
End Function
Function DrawBar(x,y,val#,max#,txt$,lf=False)
val = val/(max/100.0)
Color val*2.55,255-(val*1.28),0
Rect x,y-val-24,12,val
Color 0,0,0
Rect x ,y-100-24,14,100,False
Rect x+2,y-100-22,10,96,False
Color 255,255,255
Rect x+1,y-100-23,12,98,False
If lf
Outline_Text x+14-StringWidth(txt),y-18,txt$
Else
Outline_Text x,y-18,txt$
End If
End Function
Function Dustify(x,y,r,g,b)
For i = 0 To 30
d.dust = New dust
d\x = x
d\y = y
d\sx = Rnd(-2.0,2.0)
d\sy = Rnd(-5.0,2.0)
Next
End Function
Function LoseLife(player.player)
player\lives = player\lives-1
player\thrust = 10
If player\lives < 0
gameover = True
player\x=-100
Return
Else
; reposition player
For box.box = Each box
If box\y<GraphicsHeight()-100 And box\y>100
If box\x>0 And box\x+box\w<GraphicsWidth()
player\y = box\y-32
player\x = Rand(box\x,box\x+box\w)
player\xd = 0
player\yd = 0
Exit
End If
End If
Next
End If
channel = PlaySound(die)
End Function
Function Outline_Text(x,y,t$,cx=False,cy=False)
Color 0,0,0
For i = -1 To 1
For j = -1 To 1
Text x+i,y+j,t,cx,cy
Next
Next
Color 255,255,255
Text x,y,t,cx,cy
End Function
Function PointInBox(x,y,box.box)
If x=>box\x And x<=box\x+box\w
If y=>box\y And y<=box\y+box\h
Return True
End If
End If
Return False
End Function
|
| ||
Nee naw, nee naw! ADDED: Credits Modified: Birds Y speed seemed a little fast, slowed them down and the animations as well. BUGFIXES: Angle now resets on death |
| ||
| Damn, this is a fun little game. I love the graphics, and the latest version (well, latest zipped version) is much more fun to play than the original because the controls are much easier to handle. |
| ||
| Bloody hell! My child is born! This is really good fun... Am I the only one who thinks this is going to reach commerical quality by Thursday? Oh and Berbank, Kinda inspired from Fleafall! Obviously! Everyone else: Wow, this is stunning, I didn't think anyone would pick up on this! Fantastic work and keep it coming! |
| ||
| Better Rock->Platform collision, and the platforms can't extend beyond the right side of the screen anymore. http://www.frecle.net/misc/JumpAround.zip |
| ||
| Amazing! Having played it, I would say it would be nice if the pointer didn't reset after each jump, and also it sometimes swings a bit too fast for fine control. Don't get me wrong though, it's really addictive! |
| ||
| Yeah I love this. Im planning to add some work to it when I get home. I will upload any new code and files when its done. |
| ||
| Shield for the player and monsters get killed by rocks :) http://www.frecle.net/misc/JumpAround.zip Mr. Tricks: You can hold shift to adjust fine angle. |
| ||
| I got a few cool ideas I will add l8r... In the meantime though there is a small nug in that some times the platforms are to far appart to jump. Should be easy ehough to fix. |
| ||
| Yavin you've got the thuster for that... just found out if you hit Up you get thrust! Ideas: A front end - explaining the controls Levels - So you actually finish a level to move onto the next one 2 (or more) player mode? - 2 squidgys bouncing around on the same screen. (this would mean a slight re-design of the positions of the thrust, jump meters though) Some way of killing the bad guys It could be worth trying to throw this into a 3D mode so we can have alphaed sprites using syntax error's sprited library? I do have a single surface sprite library I've done but it doesn't use pixel positions so it will screw up all the maths, however, I'll post it up tomorrow. Why tomorrow?... I'm at work at the moment, I don't have internet at home, so I'll have to stick it on a floppy tonight, bring it into work and upload it! Fun fun fun!! |
| ||
| Added a front endish thing including instructions Updated the outline text function so you can give it a colour. Increased the size of the font and called it regfont. Added an extra bigfont for game title Type box
Field x#,y#,w,h
End Type
Type coin
Field x#,y#,frame#
End Type
Type Player
Field x#,y#,frame#
Field xd#,yd#,angle#
Field Width, Height
Field lives
Field Thrust#
Field Thrusting
Field ThrustFrame
Field ThrustFrameDir
Field shieldtime
End Type
Type Message
Field x,y#,life,txt$
End Type
Type rock
Field x#,y#
Field speed#
End Type
Type poof
Field x#,y#,sx#,sy#
Field count
End Type
Type dust
Field x#,y#,sx#,sy#
End Type
Type monster
Field x#,y#,frame#
Field xd#
Field box.box
End Type
Type bird
Field x#,y#,frame#
Field vx#,vy#
End Type
Graphics 640,480,0,1
HidePointer
power#=0
Dim CreditsArray$(8)
CreditsArray(0) = "A BlitzBasic Community Project"
CreditsArray(1) = "Created by the following people"
CreditsArray(2) = "In order they appeared in the thread:"
CreditsArray(3) = "Rob Farley (original codebase)"
CreditsArray(4) = "Perturbatio"
CreditsArray(5) = "Fredborg"
CreditsArray(6) = "RetroBooster"
CreditsArray(7) = "Marcus"
CreditsArray(8) = "Jeppe Nielsen"
Dim instructionsArray$(8)
instructionsArray(0) = "Jump from platform to platform"
instructionsArray(1) = "Blah blah blah blah"
instructionsArray(2) = ""
instructionsArray(3) = "Keys:"
instructionsArray(4) = "Left: Angle left"
instructionsArray(5) = "Right: Angle right"
instructionsArray(6) = "Down: Jump (hold to increase power)"
instructionsArray(7) = "Up: Thrust (if you have any thurst)"
instructionsArray(8) = "Shift: Fine tune angle"
Const keyleft=203
Const keyright=205
Const keyjump=208
Const keyUp = 200
Const keyFineAngle = 54
Const THRUST_MAX = 50
Global gotr=0
Global gotg=0
Global gotb=0
Global angleMod = 5
Global Player.Player = New Player
Global jump
Global Score
Global Scrollspeed#
Global highscore
Global oldtime, newtime
highfile=OpenFile("HighScore")
If highfile
highscore=ReadLine(highfile)
CloseFile highfile
Else
highscore=200
highfile=WriteFile("HighScore")
WriteLine highfile,highscore
CloseFile highfile
EndIf
Global gameover = True
SetBuffer BackBuffer()
Reset()
Global getcoin = LoadSound("coin.wav")
Global die = LoadSound("die.wav")
Global dieplayed = False
Global bg = LoadSound("bg.ogg")
LoopSound bg
Global bgchannel = PlaySound(bg)
Global boom = LoadSound("boom.wav")
backdrop = LoadImage("Background00.png")
arrow = LoadImage("arrow00.png")
rockimage = LoadImage("Fall00.png")
poofimage = LoadImage("poof00.png")
tiles = LoadAnimImage("Tiles00.png",32,32,0,3)
coins = LoadAnimImage("Coins00.png",16,16,0,8)
character = LoadAnimImage("character00.png", 16,16,0,11*5)
HandleImage character, Player\Width/2,Player\Height-2
thruster = LoadAnimImage("thrust00.png", 16,16,0,3)
HandleImage thruster, 8, 0
monsters = LoadAnimImage("Monster00.png",16,16,0,4)
birds = LoadAnimImage("Bird00.png",16,16,0,4)
backscroll# = GraphicsHeight()-ImageHeight(backdrop)
ClsColor 154,198,237
Global regfont=LoadFont("tahoma",15,True)
Global bigfont=LoadFont("tahoma",35,True)
SetFont regfont
Repeat
Cls
backscroll = backscroll + (scrollspeed*0.025)
DrawImage backdrop,0,backscroll
If jump = False
If KeyDown(keyFineAngle) Then angleMod = 1 Else angleMod = 5
If KeyDown(keyright) And Player\angle<270 Then Player\angle=Player\angle+angleMod
If KeyDown(keyleft) And Player\angle>90 Then Player\angle=Player\angle-angleMod
Else
If KeyDown(keyright) Then player\xd = player\xd+0.05
If KeyDown(keyleft) Then player\xd = player\xd-0.05
End If
If KeyDown(keyUp) And Player\Thrust > 0 Then
Player\yd = Player\yd-0.2
Player\Thrust = Player\Thrust - 0.1
Player\Thrusting = True
jump = True
DebugLog Player\Thrust
Else
Player\Thrusting = False
EndIf
; Down grade shield time
If player\shieldtime>0
player\shieldtime = player\shieldtime - 1
End If
If KeyDown(keyjump) And jump=False And Int(xd+yd)=0 Then power=power+2
If power>100 Then power=100
; jump
If KeyDown(keyjump)=False And power>0
power=power/10
Player\xd=Sin(-Player\angle)*power
Player\yd=Cos(-Player\angle)*power
power=0
jump = True
deck=False
EndIf
If jump
Player\yd = Player\yd+.1
Player\xd = Player\xd*.99
Player\yd = Player\yd*.99
Else
player\yd = 0
player\xd = 0
End If
oldx#=Player\x
oldy#=Player\y
Player\x=Player\x+Player\xd
Player\y=Player\y+Player\yd+scrollspeed
For bird.bird=Each bird
DrawImage birds,bird\x,bird\y,bird\frame
bird\x=bird\x+bird\vx
bird\y=bird\y+bird\vy+ScrollSpeed
bird\frame = (bird\frame + 0.05) Mod 3
If bird\x<0
bird\x=GraphicsWidth()
EndIf
If bird\y<0
bird\y=GraphicsHeight()
EndIf
If bird\x>GraphicsWidth()
bird\x=0
EndIf
If bird\y>GraphicsHeight()
bird\y=0
EndIf
Next
; draw level
For box.box = Each box
For sx = 0 To box\w-32 Step 32
frame = 1
If sx = 0 Then frame = 0
If sx = box\w-32 Then frame = 2
DrawImage tiles,box\x+sx,box\y,frame
Next
box\y = box\y + ScrollSpeed
If box\y > GraphicsHeight()
box\x = Rand(0,(GraphicsWidth()-64)/32)*32
box\y = -32
box\w = Rand(2,5)*32
If box\x+box\w>GraphicsWidth()
box\w = 64
End If
If Rand(0,2) = 1
coin.coin = New coin
coin\x = Rand(box\x,box\x+box\w)
;prevent a coin appearing too far to the right where the player can't reach it
If coin\x > GraphicsWidth()-10 Then coin\x = GraphicsWidth()-10
coin\y = box\y-16
End If
If Rand(0,3)=1
monster.monster=New monster
monster\x=Rand(box\x,box\x+box\w)
monster\y=box\y-16
monster\box=box
If Rand(0,1)=0
monster\xd=-Rnd(0.1,0.5)
Else
monster\xd=Rnd(0.1,0.5)
EndIf
EndIf
End If
Next
For coin.coin = Each coin
DrawImage coins,coin\x,coin\y,coin\frame
coin\y = coin\y + ScrollSpeed
coin\frame = (coin\frame + 0.1) Mod 7
If RectsOverlap(Player\x-2,Player\y-2,5,5,coin\x,coin\y,16,16)
score = score + 100
If score>highscore
highscore=score
highfile=WriteFile("HighScore")
WriteLine highfile,highscore
CloseFile highfile
EndIf
m.message = New message
m\x = coin\x
m\y = coin\y-10
m\life = 100
m\txt = "100"
PlaySound(getcoin)
Delete coin
If (Score Mod 500) = 0
Player\Thrust=Player\Thrust+10
m\txt$ = "EXTRA THRUST"
End If
If Player\Thrust > THRUST_MAX Then Player\Thrust = THRUST_MAX
If (Score Mod 5000) = 0
Player\Lives = Player\Lives + 1
m\txt$ = "EXTRA LIFE"
End If
ElseIf coin\y > GraphicsHeight()
Delete coin
End If
Next
For monster.monster=Each monster
DrawImage monsters,monster\x,monster\y,monster\frame
monster\y=monster\y+ScrollSpeed
monster\frame = (monster\frame + 0.1) Mod 3
monster\x=monster\x+monster\xd
If monster\x+16>monster\box\x+monster\box\w
monster\xd=-Rnd(0.1,0.5)
ElseIf monster\x<monster\box\x
monster\xd=Rnd(0.1,0.5)
EndIf
dx#=((monster\x+8)-player\x)
dy#=(monster\y+8-player\y)
If (dx*dx+dy*dy)<32*32
If Sin(MilliSecs())>0
Outline_text player\x,player\y-30,"Watch out!",1,1
EndIf
EndIf
If RectsOverlap(Player\x-2,Player\y-2,5,5,monster\x,monster\y,16,16)
If player\shieldtime = 0
LoseLife(player)
End If
ElseIf monster\y > GraphicsHeight()
Delete monster
End If
Next
For rock.rock = Each rock
For monster.monster = Each monster
If ImagesOverlap(monsters,monster\x,monster\y,rockImage,rock\x,rock\y)
Delete monster
End If
Next
Next
; Player frame
temp = Abs(Int(player\yd))*11
If temp>22 Then temp = 22
Player\frame = 27 + (((player\angle-180)/90.0)*5) - (Int(power/50)*11) + temp
; check of hitting sides, anypixel with a green component counts as solid.
; Sides of screen
If Player\x<10 Or Player\x>GraphicsWidth()-10
Player\x = oldx
Player\xd = -Player\xd/2
End If
; Top of screen
If player\y<0
player\y = oldy
player\yd = 0
End If
; Bottom of screen
If Player\y>GraphicsHeight()+40
LoseLife(player)
End If
For box.box = Each box
; Y Collision
If Player\yd>0
collisionA = PointInBox(Player\x,Player\y+1,box)
collisionB = PointInBox(Player\x,Player\y-5,box)
If collisionA = True And collisionB = False
deck = True
Player\y = oldy
Player\xd=Player\xd*.9
Player\yd=-Player\yd/3
Player\Angle = 180
If Abs(player\xd)<0.2 And Abs(player\yd)<0.2
jump = False
End If
EndIf
EndIf
Next
If gameover
frontend()
If KeyDown(57)
gameover=False
Reset()
EndIf
Else
; draw player
If jump = False
Color 255,0,0
Line Player\x+(Sin(-Player\angle)*16),Player\y-4+(Cos(-Player\angle)*16),Player\x+(Sin(-Player\angle)*32),Player\y-4+(Cos(-Player\angle)*32)
End If
DrawImage character, Player\X,Player\Y,Player\frame
If Player\Thrusting Then
DrawImage thruster, Player\X,Player\Y+2,Player\ThrustFrame
If Player\ThrustFrame = 0 Then Player\ThrustFrameDir = 1 ElseIf Player\ThrustFrame = 2 Then Player\ThrustFrameDir = -1
Player\ThrustFrame = Player\ThrustFrame + Player\ThrustFrameDir
EndIf
If player\shieldtime>0
If Rand(0,100)<player\shieldtime
Color 255,255,255
Oval player\x-10,player\y-14,20,20,False
End If
End If
End If
; Draw Power bar
DrawBar(8,GraphicsHeight(),power,100,"POWER")
; Draw Thrust bar
DrawBar(GraphicsWidth()-24,GraphicsHeight(),player\thrust,THRUST_MAX,"THRUST",True)
; rocks!
If Rand(0,400) = 0
rock.rock = New rock
rock\x = Rand(16,GraphicsWidth()-16)
rock\y = -600
rock\speed = Rnd(2,4)
EndIf
For rock.Rock = Each rock
kill =False
rock\y = rock\y + rock\speed
If rock\y<-32
If Rand(-600,-100)<rock\y
DrawImage arrow,rock\x,0
End If
Else
DrawImage rockImage, rock\x,rock\y
End If
If rock\y > GraphicsHeight()
kill = True
EndIf
For box.box = Each box
If ImageRectCollide(rockimage,rock\x,rock\y,0,box\x,box\y,box\w,box\h)
For i = 0 To 10
poof.poof = New poof
poof\x = rock\x
poof\y = rock\y
a# = Rnd(0,360)
ms# = Rnd(1.5,5.0)
poof\sx = Sin(a)*ms
poof\sy = Cos(a)*ms
Next
Dustify(rock\x+16,rock\y,120,100,80)
kill = True
EndIf
Next
If ImagesOverlap(character,player\x,player\y,rockImage,rock\x,rock\y)
For i = 0 To 10
poof.poof = New poof
poof\x = rock\x
poof\y = rock\y
a# = Rnd(0,360)
ms# = Rnd(1.5,5.0)
poof\sx = Sin(a)*ms
poof\sy = Cos(a)*ms
Next
Dustify(rock\x+16,rock\y,120,180,140)
kill = True
If player\shieldtime = 0
LoseLife(player)
End If
EndIf
If kill
SoundVolume boom,.1
PlaySound(boom)
Delete rock
End If
Next
drawpoof = Not drawpoof
If drawpoof
For poof.poof = Each poof
poof\x = poof\x + poof\sx
poof\y = poof\y + poof\sy
poof\sx = poof\sx * 0.9
poof\sy = poof\sy * 0.9
If Rand(10,20)>poof\count
DrawImage poofImage, poof\x,poof\y
End If
poof\count = poof\count + 1
If poof\count > 20 Then Delete poof
Next
End If
Color 120,100,80
For dust.dust = Each dust
dust\x = dust\x + dust\sx
dust\y = dust\y + dust\sy
dust\sx = dust\sx * Rnd(0.95,0.999)
dust\sy = (dust\sy * Rnd(0.95,0.999)) + 0.1
Rect dust\x,dust\y,2,2
If dust\y > GraphicsHeight() Then Delete dust
Next
Outline_Text GraphicsWidth()-120,10,"SCORE "+Replace(RSet(score,8)," ","0")
Outline_Text GraphicsWidth()/2,10,"HIGHSCORE "+Replace(RSet(highscore,8)," ","0"),True
For i = 1 To player\lives
DrawImage character,((i-1)*16)+16,16,27
Next
For m.message = Each message
m\y = m\y - 0.5
m\life = m\life - 1
If Rand(0,50)<m\life
Outline_Text m\x,m\y,m\txt,True,True
End If
If m\life <= 0
Delete m
End If
Next
Flip
ScrollSpeed = ScrollSpeed + 0.00001
Until KeyHit(1)
End
Function Reset(seed=1014)
Delete Each box
Delete Each coin
Delete Each monster
Delete Each Message
Delete Each rock
Delete Each poof
Delete Each dust
Delete Each bird
Player\x#=GraphicsWidth()/2
Player\y#=GraphicsHeight()/2
Player\frame = 5
Player\xd# = 0
Player\yd# = 0
Player\angle# = 180
Player\Width = 16
Player\Height = 16
Player\lives=3
player\shieldtime = 500
SeedRnd seed
box.box=New box
box\x=0
box\y=GraphicsHeight()-128
box\w=GraphicsWidth()
box\h=32
For n=1 To 20
box.box = New box
box\x = Rand(0,(GraphicsWidth()-64)/32)*32
box\y = Rand(0,(GraphicsHeight()-160)/32)*32
box\w = Rand(2,5)*32
If box\x+box\w>GraphicsWidth()
box\w = 64
End If
box\h = 32
Next
For box.box = Each box
If Rand(0,2) = 1
coin.coin = New coin
coin\x = Rand(box\x,box\x+box\w)
coin\y = box\y-16
End If
If Rand(0,3)=1
monster.monster=New monster
monster\x=Rand(box\x,box\x+box\w)
monster\y=box\y-16
monster\box=box
If Rand(0,1)=0
monster\xd=-Rnd(0.1,0.5)
Else
monster\xd=Rnd(0.1,0.5)
EndIf
EndIf
Next
For n=1 To 20
bird.bird=New bird
bird\x = Rand(0,GraphicsWidth())
bird\y = Rand(0,GraphicsHeight())
If Rand(0,1)=0
bird\vx=Rnd(0.1,1)
Else
bird\vx=-Rnd(0.1,1)
EndIf
If Rand(0,1)=0
bird\vy=Rnd(0.01,0.5)
Else
bird\vy=-Rnd(0.1,1)
EndIf
Next
jump = True
scrollspeed# = 0.1
Score = 0
End Function
Function DrawBar(x,y,val#,max#,txt$,lf=False)
val = val/(max/100.0)
Color val*2.55,255-(val*1.28),0
Rect x,y-val-24,12,val
Color 0,0,0
Rect x ,y-100-24,14,100,False
Rect x+2,y-100-22,10,96,False
Color 255,255,255
Rect x+1,y-100-23,12,98,False
If lf
Outline_Text x+14-StringWidth(txt),y-18,txt$
Else
Outline_Text x,y-18,txt$
End If
End Function
Function Dustify(x,y,r,g,b)
For i = 0 To 30
d.dust = New dust
d\x = x
d\y = y
d\sx = Rnd(-2.0,2.0)
d\sy = Rnd(-5.0,2.0)
Next
End Function
Function LoseLife(player.player)
player\lives = player\lives-1
player\thrust = 10
player\angle = 180
player\shieldtime = 500
If player\lives < 0
gameover = True
player\x=-100
Return
Else
; reposition player
For box.box = Each box
If box\y<GraphicsHeight()-100 And box\y>100
If box\x>0 And box\x+box\w<GraphicsWidth()
player\y = box\y-32
player\x = Rand(box\x,box\x+box\w)
player\xd = 0
player\yd = 0
Exit
End If
End If
Next
End If
channel = PlaySound(die)
End Function
Function Outline_Text(x,y,t$,cx=False,cy=False,r=255,g=255,b=255)
Color 0,0,0
For i = -1 To 1
For j = -1 To 1
Text x+i,y+j,t,cx,cy
Next
Next
Color r,g,b
Text x,y,t,cx,cy
End Function
Function PointInBox(x,y,box.box)
If x=>box\x And x<=box\x+box\w
If y=>box\y And y<=box\y+box\h
Return True
End If
End If
Return False
End Function
Function DisplayCredits()
gwid=GraphicsWidth()/2
g10th=GraphicsHeight()/10
For i = 0 To 8
Color 255,255,255
Outline_Text(gwid, (g10th*4)+(i*15),CreditsArray(i),True,True,255-(i*30),i*30,255)
Next
End Function
Function displayinstructions()
gwid=GraphicsWidth()/2
g10th=GraphicsHeight()/10
For i = 0 To 8
Color 255,255,255
Outline_Text(gwid, (g10th*4)+(i*15),instructionsArray(i),True,True,i*30,255,255-i*30)
Next
End Function
Function frontend()
gwid=GraphicsWidth()/2
ghie=GraphicsHeight()/2
g10th=GraphicsHeight()/10
Outline_Text gwid,g10th*3,"GAME OVER",True,True,255,0,0
t=MilliSecs() Mod 10000
If Sin(MilliSecs()/2)>0
Outline_Text gwid,g10th*8,"INSERT COIN",True,True
EndIf
If t<5000 Then displaycredits Else displayinstructions
SetFont bigfont
outline_text gwid,g10th*2,"Jump Around",True,True,100,255,100
SetFont regfont
End Function |
| ||
| Logo + Rainbow shading thingie for instructions :) http://www.frecle.net/misc/JumpAround.zip Someone should add GNet support... - 4 players - Players should be able to push each other. - weapons (use the angle to adjust shot, press space to fire) - 'Treasure' mode, who collects the most loot. - 'Survival' mode - 'King of the platform' mode - etc. :) Oh, and I don't think there is any reason to do it in 3D with sprites. It's nice that it is so basic. Gives everyone a chance of contributing, regardless which Blitz version they have! |
| ||
| i really like this! will convert all sounds to ogg and fix the mistake in the bg sound. also start with GNET-Function, if noone already on it... something like: CreateGame() GetGames() JoinGame() DeleteGame() |
| ||
| Something for the multiplayer stuff (works better if you grey scale the character graphic first): Incedentally it's a pain there isn't a createanimimage function... So the usage of this would have to be something like SaveImage(createcharacter(255,200,100),"temp.bmp") loadanimimage("temp.bmp", 16,16,0,11*5) Which is a bit of a bugger... but hey!
Graphics 640,480,0,2
DrawBlock createcharacter(255,100,255),0,0
DrawBlock createcharacter(100,255,255),300,0
DrawBlock createcharacter(100,255,100),0,80
DrawBlock createcharacter(100,100,255),300,80
DrawBlock createcharacter(255,255,255),0,160
DrawBlock createcharacter(255,200,100),300,160
WaitKey
Function createcharacter(r#,g#,b#)
temp=LoadImage("character00.png")
char=CreateImage(ImageWidth(temp),ImageHeight(temp))
r=r/255
g=g/255
b=b/255
LockBuffer ImageBuffer(temp)
LockBuffer ImageBuffer(char)
For x=0 To ImageWidth(temp)
For y=0 To ImageHeight(temp)
val#=getr(ImageBuffer(temp),x,y)
If val>0
If val>250
writergb(char,x,y,val,val,val)
Else
writergb(char,x,y,r*val,g*val,b*val)
EndIf
EndIf
Next
Next
UnlockBuffer ImageBuffer(temp)
UnlockBuffer ImageBuffer(char)
FreeImage temp
Return char
End Function
Function getr(buffer,x,y)
argb=ReadPixelFast(x,y,buffer)
Return (ARGB Shr 16) And $ff
End Function
Function writergb(image_name,x,y,red,green,blue)
argb=(blue Or (green Shl 8) Or (red Shl 16) Or ($ff000000))
WritePixelFast x,y,argb,ImageBuffer(image_name) |
| ||
| And I think there should be a multiplayer mode of 'huddled round the keyboard' |
| ||
| This game is getting better and better all the time, keep up the good work :) |
| ||
| added compressed sounds (save 200kb for more fun) - and corrected my Name in credits :oP you upload the new one, Fredborg? thanks :) will start the multiplayerthing in the evening :) www.malice.at/JumpAround.zip |
| ||
| Just improved the createcharater functions Now it automatically creates the animimage by saving off the temp... Include this then change the global charater line to: Global character = createcharacter(100,255,100) Function createcharacter(r#,g#,b#)
temp=LoadImage("characterbw.png")
char=CreateImage(ImageWidth(temp),ImageHeight(temp))
r=r/255
g=g/255
b=b/255
LockBuffer ImageBuffer(temp)
LockBuffer ImageBuffer(char)
For x=0 To ImageWidth(temp)
For y=0 To ImageHeight(temp)
val#=getr(ImageBuffer(temp),x,y)
If val>0
If val>240
writergb(char,x,y,val,val,val)
Else
writergb(char,x,y,r*val,g*val,b*val)
EndIf
EndIf
Next
Next
UnlockBuffer ImageBuffer(temp)
UnlockBuffer ImageBuffer(char)
FreeImage temp
SaveImage(char,"temp.bmp")
char=LoadAnimImage("temp.bmp",16,16,0,11*5)
Return char
End Function
Function getr(buffer,x,y)
argb=ReadPixelFast(x,y,buffer)
Return (ARGB Shr 16) And $ff
End Function
Function writergb(image_name,x,y,red,green,blue)
argb=(blue Or (green Shl 8) Or (red Shl 16) Or ($ff000000))
WritePixelFast x,y,argb,ImageBuffer(image_name)
End Function |
| ||
| Oh, and found a bugette if someone wants to fix it for the next upload... The backscroll doesn't reset in the reset function. |
| ||
| need the characterbw.png image as well :) |
| ||
| I think I've just realised the power of a CVS system... |
| ||
Doh, that's just the character grey scaled in psp. |
| ||
| Latest version: http://www.frecle.net/misc/JumpAround.zip With new sounds from Marcus, and a few tweaks. *EDIT* And the character color function is included as well! |
| ||
| Maybe on the next upload you should put the media in folders to tidy up the directory a touch?! Edit: And I think you could be right with the CVS! Edit2: I think this has been the most sucessful community project so far! |
| ||
Added another monster:![]() EDIT: It should now be the latest source:
Type box
Field x#,y#,w,h
End Type
Type coin
Field x#,y#,frame#
End Type
Type Player
Field x#,y#,frame#
Field xd#,yd#,angle#
Field Width, Height
Field lives
Field Thrust#
Field Thrusting
Field ThrustFrame
Field ThrustFrameDir
Field shieldtime
End Type
Type Message
Field x,y#,life,txt$
End Type
Type rock
Field x#,y#
Field speed#
End Type
Type poof
Field x#,y#,sx#,sy#
Field count
End Type
Type dust
Field x#,y#,sx#,sy#
End Type
Type monster
Field t
Field x#,y#,frame#
Field xd#,yd#
Field box.box
Field dead
End Type
Type bird
Field x#,y#,frame#
Field vx#,vy#
End Type
Graphics 640,480,0,2
HidePointer
power#=0
Dim CreditsArray$(8)
CreditsArray(0) = "A BlitzBasic Community Project"
CreditsArray(1) = "Created by the following people"
CreditsArray(2) = "In order they appeared in the thread:"
CreditsArray(3) = "Rob Farley (original codebase)"
CreditsArray(4) = "Perturbatio"
CreditsArray(5) = "Mikkel Fredborg"
CreditsArray(6) = "RetroBooster"
CreditsArray(7) = "Marcus Matt"
CreditsArray(8) = "Jeppe Nielsen"
Dim instructionsArray$(8)
instructionsArray(0) = "Jump from platform to platform"
instructionsArray(1) = "Blah blah blah blah"
instructionsArray(2) = ""
instructionsArray(3) = "Keys:"
instructionsArray(4) = "Left: Angle left"
instructionsArray(5) = "Right: Angle right"
instructionsArray(6) = "Down: Jump (hold to increase power)"
instructionsArray(7) = "Up: Thrust (if you have any thurst)"
instructionsArray(8) = "Shift: Fine tune angle"
Const keyleft=203
Const keyright=205
Const keyjump=208
Const keyUp = 200
Const keyFineAngle = 54
Const THRUST_MAX = 50
Global gotr=0
Global gotg=0
Global gotb=0
Global angleMod = 5
Global Player.Player = New Player
Global jump
Global Score
Global Scrollspeed#
Global highscore
Global oldtime, newtime
highfile=OpenFile("HighScore")
If highfile
highscore=ReadLine(highfile)
CloseFile highfile
Else
highscore=200
highfile=WriteFile("HighScore")
WriteLine highfile,highscore
CloseFile highfile
EndIf
Global gameover = True
SetBuffer BackBuffer()
Reset()
; Load Sounds
Global getcoin = LoadSound("coin.ogg")
Global die = LoadSound("die.ogg")
Global dieplayed = False
Global bg = LoadSound("bg.ogg")
LoopSound bg
Global bgchannel = PlaySound(bg)
Global boom = LoadSound("boom.ogg")
; Load images
Global backdrop = LoadImage("Background00.png")
Global arrow = LoadImage("arrow00.png")
Global rockimage = LoadImage("Fall00.png")
Global poofimage = LoadImage("poof00.png")
Global tiles = LoadAnimImage("Tiles00.png",32,32,0,3)
Global coins = LoadAnimImage("Coins00.png",16,16,0,8)
Global character = createcharacter(100,255,100)
HandleImage character, Player\Width/2,Player\Height-2
Global thruster = LoadAnimImage("thrust00.png", 16,16,0,3)
HandleImage thruster, 8, 0
Dim monsters(1)
For n=0 To 1
monsters(n) = LoadAnimImage("Monster0"+Str(n)+".png",16,16,0,4)
Next
Global birds = LoadAnimImage("Bird00.png",16,16,0,4)
Global logo = LoadImage("Logo00.png")
MidHandle logo
backscroll# = GraphicsHeight()-ImageHeight(backdrop)
ClsColor 154,198,237
SetFont LoadFont("tahoma",15,True)
Repeat
Cls
backscroll = backscroll + (scrollspeed*0.025)
DrawImage backdrop,0,backscroll
If jump = False
If KeyDown(keyFineAngle) Then angleMod = 1 Else angleMod = 5
If KeyDown(keyright) And Player\angle<270 Then Player\angle=Player\angle+angleMod
If KeyDown(keyleft) And Player\angle>90 Then Player\angle=Player\angle-angleMod
Else
If KeyDown(keyright) Then player\xd = player\xd+0.05
If KeyDown(keyleft) Then player\xd = player\xd-0.05
End If
If KeyDown(keyUp) And Player\Thrust > 0 Then
Player\yd = Player\yd-0.2
Player\Thrust = Player\Thrust - 0.1
Player\Thrusting = True
jump = True
DebugLog Player\Thrust
Else
Player\Thrusting = False
EndIf
; Down grade shield time
If player\shieldtime>0
player\shieldtime = player\shieldtime - 1
End If
If KeyDown(keyjump) And jump=False And Int(xd+yd)=0 Then power=power+2
If power>100 Then power=100
; jump
If KeyDown(keyjump)=False And power>0
power=power/10
Player\xd=Sin(-Player\angle)*power
Player\yd=Cos(-Player\angle)*power
power=0
jump = True
deck=False
EndIf
If jump
Player\yd = Player\yd+.1
Player\xd = Player\xd*.99
Player\yd = Player\yd*.99
Else
player\yd = 0
player\xd = 0
End If
oldx#=Player\x
oldy#=Player\y
Player\x=Player\x+Player\xd
Player\y=Player\y+Player\yd+scrollspeed
For bird.bird=Each bird
DrawImage birds,bird\x,bird\y,bird\frame
bird\x=bird\x+bird\vx
bird\y=bird\y+bird\vy+ScrollSpeed
bird\frame = (bird\frame + 0.05) Mod 3
If bird\x<0
bird\x=GraphicsWidth()
EndIf
If bird\y<0
bird\y=GraphicsHeight()
EndIf
If bird\x>GraphicsWidth()
bird\x=0
EndIf
If bird\y>GraphicsHeight()
bird\y=0
EndIf
Next
; draw level
For box.box = Each box
For sx = 0 To box\w-32 Step 32
frame = 1
If sx = 0 Then frame = 0
If sx = box\w-32 Then frame = 2
DrawImage tiles,box\x+sx,box\y,frame
Next
box\y = box\y + ScrollSpeed
If box\y > GraphicsHeight()
box\x = Rand(0,(GraphicsWidth()-64)/32)*32
box\y = -32
box\w = Rand(2,5)*32
If box\x+box\w>GraphicsWidth()
box\w = 64
End If
If Rand(0,2) = 1
coin.coin = New coin
coin\x = Rand(box\x,box\x+box\w)
;prevent a coin appearing too far to the right where the player can't reach it
If coin\x > GraphicsWidth()-10 Then coin\x = GraphicsWidth()-10
coin\y = box\y-16
End If
If Rand(0,3)=1
monster.monster=New monster
monster\x=Rand(box\x,box\x+box\w)
monster\y=box\y-16
monster\box=box
monster\t=Rand(0,1)
If Rand(0,1)=0
monster\xd=-Rnd(0.1+0.2*monster\t,0.5+0.2*monster\t)
Else
monster\xd=Rnd(0.1+0.2*monster\t,0.5+0.2*monster\t)
EndIf
EndIf
End If
Next
For coin.coin = Each coin
DrawImage coins,coin\x,coin\y,coin\frame
coin\y = coin\y + ScrollSpeed
coin\frame = (coin\frame + 0.1) Mod 7
If RectsOverlap(Player\x-2,Player\y-2,5,5,coin\x,coin\y,16,16)
score = score + 100
If score>highscore
highscore=score
highfile=WriteFile("HighScore")
WriteLine highfile,highscore
CloseFile highfile
EndIf
m.message = New message
m\x = coin\x
m\y = coin\y-10
m\life = 100
m\txt = "100"
PlaySound(getcoin)
Delete coin
If (Score Mod 500) = 0
Player\Thrust=Player\Thrust+10
m\txt$ = "EXTRA THRUST"
End If
If Player\Thrust > THRUST_MAX Then Player\Thrust = THRUST_MAX
If (Score Mod 5000) = 0
Player\Lives = Player\Lives + 1
m\txt$ = "EXTRA LIFE"
End If
ElseIf coin\y > GraphicsHeight()
Delete coin
End If
Next
For monster.monster=Each monster
DrawImage monsters(monster\t),monster\x,monster\y,monster\frame
If monster\dead
monster\x = monster\x + monster\xd
monster\y = monster\y + monster\yd
monster\yd = monster\yd * 0.99 + 0.1
monster\xd = monster\xd * 0.99
Else
monster\y=monster\y+ScrollSpeed
monster\frame = (monster\frame + 0.1) Mod 3
monster\x=monster\x+monster\xd
If monster\x+16>monster\box\x+monster\box\w
monster\xd=-Rnd(0.1,0.5)
ElseIf monster\x<monster\box\x
monster\xd=Rnd(0.1,0.5)
EndIf
dx#=((monster\x+8)-player\x)
dy#=(monster\y+8-player\y)
If (dx*dx+dy*dy)<32*32
If Sin(MilliSecs())>0
Outline_text player\x,player\y-30,"Watch out!",1,1
EndIf
EndIf
If RectsOverlap(Player\x-2,Player\y-2,5,5,monster\x,monster\y,16,16)
If player\shieldtime = 0
LoseLife(player)
End If
ElseIf monster\y > GraphicsHeight()
Delete monster
End If
End If
Next
For rock.rock = Each rock
For monster.monster = Each monster
If monster\dead = False
If ImagesOverlap(monsters(monster\t),monster\x,monster\y,rockImage,rock\x,rock\y)
monster\dead = True
monster\xd = Rnd(-2.5,2.5)
monster\yd = Rnd(-5.0,-3.0)
End If
End If
Next
Next
; Player frame
temp = Abs(Int(player\yd))*11
If temp>22 Then temp = 22
Player\frame = 27 + (((player\angle-180)/90.0)*5) - (Int(power/50)*11) + temp
; check of hitting sides, anypixel with a green component counts as solid.
; Sides of screen
If Player\x<10 Or Player\x>GraphicsWidth()-10
Player\x = oldx
Player\xd = -Player\xd/2
End If
; Top of screen
If player\y<0
player\y = oldy
player\yd = 0
End If
; Bottom of screen
If Player\y>GraphicsHeight()+40
LoseLife(player)
End If
For box.box = Each box
; Y Collision
If Player\yd>0
collisionA = PointInBox(Player\x,Player\y+1,box)
collisionB = PointInBox(Player\x,Player\y-5,box)
If collisionA = True And collisionB = False
deck = True
Player\y = oldy
Player\xd=Player\xd*.9
Player\yd=-Player\yd/3
Player\Angle = 180
If Abs(player\xd)<0.2 And Abs(player\yd)<0.2
jump = False
End If
EndIf
EndIf
Next
; rocks!
If Rand(0,400) = 0
rock.rock = New rock
rock\x = Rand(16,GraphicsWidth()-16)
rock\y = -600
rock\speed = Rnd(2,4)
EndIf
For rock.Rock = Each rock
kill =False
rock\y = rock\y + rock\speed
If rock\y<-32
If Rand(-600,-100)<rock\y
DrawImage arrow,rock\x,0
End If
Else
DrawImage rockImage, rock\x,rock\y
End If
If rock\y > GraphicsHeight()
kill = True
EndIf
For box.box = Each box
If ImageRectCollide(rockimage,rock\x,rock\y,0,box\x,box\y,box\w,box\h)
For i = 0 To 10
poof.poof = New poof
poof\x = rock\x
poof\y = rock\y
a# = Rnd(0,360)
ms# = Rnd(1.5,5.0)
poof\sx = Sin(a)*ms
poof\sy = Cos(a)*ms
Next
Dustify(rock\x+16,rock\y,120,100,80)
kill = True
EndIf
Next
If ImagesOverlap(character,player\x,player\y,rockImage,rock\x,rock\y)
For i = 0 To 10
poof.poof = New poof
poof\x = rock\x
poof\y = rock\y
a# = Rnd(0,360)
ms# = Rnd(1.5,5.0)
poof\sx = Sin(a)*ms
poof\sy = Cos(a)*ms
Next
Dustify(rock\x+16,rock\y,120,180,140)
kill = True
If player\shieldtime = 0
LoseLife(player)
End If
EndIf
If kill
SoundVolume boom,.1
PlaySound(boom)
Delete rock
End If
Next
; Poof clouds
drawpoof = Not drawpoof
If drawpoof
For poof.poof = Each poof
poof\x = poof\x + poof\sx
poof\y = poof\y + poof\sy
poof\sx = poof\sx * 0.9
poof\sy = poof\sy * 0.9
If Rand(10,20)>poof\count
DrawImage poofImage, poof\x,poof\y
End If
poof\count = poof\count + 1
If poof\count > 20 Then Delete poof
Next
End If
; dust/rubble
Color 120,100,80
For dust.dust = Each dust
dust\x = dust\x + dust\sx
dust\y = dust\y + dust\sy
dust\sx = dust\sx * Rnd(0.95,0.999)
dust\sy = (dust\sy * Rnd(0.95,0.999)) + 0.1
Rect dust\x,dust\y,2,2
If dust\y > GraphicsHeight() Then Delete dust
Next
If gameover
player\x = -100
player\y = -100
player\xd = 0
player\yd = 0
frontend()
If KeyDown(57)
gameover=False
backscroll# = GraphicsHeight()-ImageHeight(backdrop)
Reset()
EndIf
Else
; draw player
If jump = False
Color 255,0,0
Line Player\x+(Sin(-Player\angle)*16),Player\y-4+(Cos(-Player\angle)*16),Player\x+(Sin(-Player\angle)*32),Player\y-4+(Cos(-Player\angle)*32)
End If
DrawImage character, Player\X,Player\Y,Player\frame
If Player\Thrusting Then
DrawImage thruster, Player\X,Player\Y+2,Player\ThrustFrame
If Player\ThrustFrame = 0 Then Player\ThrustFrameDir = 1 ElseIf Player\ThrustFrame = 2 Then Player\ThrustFrameDir = -1
Player\ThrustFrame = Player\ThrustFrame + Player\ThrustFrameDir
EndIf
If player\shieldtime>0
If Rand(0,100)<player\shieldtime
Color 255,255,255
Oval player\x-10,player\y-14,20,20,False
End If
End If
End If
; Draw Power bar
DrawBar(8,GraphicsHeight(),power,100,"POWER")
; Draw Thrust bar
DrawBar(GraphicsWidth()-24,GraphicsHeight(),player\thrust,THRUST_MAX,"THRUST",True)
Outline_Text GraphicsWidth()-120,10,"SCORE "+Replace(RSet(score,8)," ","0")
Outline_Text GraphicsWidth()/2,10,"HIGHSCORE "+Replace(RSet(highscore,8)," ","0"),True
For i = 1 To player\lives
DrawImage character,((i-1)*16)+16,16,27
Next
For m.message = Each message
m\y = m\y - 0.5
m\life = m\life - 1
If Rand(0,50)<m\life
Outline_Text m\x,m\y,m\txt,True,True
End If
If m\life <= 0
Delete m
End If
Next
Flip
ScrollSpeed = ScrollSpeed + 0.00001
Until KeyHit(1)
End
Function Reset(seed=1014)
Delete Each box
Delete Each coin
Delete Each monster
Delete Each Message
Delete Each rock
Delete Each poof
Delete Each dust
Delete Each bird
Player\x#=GraphicsWidth()/2
Player\y#=GraphicsHeight()/2
Player\frame = 5
Player\xd# = 0
Player\yd# = 0
Player\angle# = 180
Player\Width = 16
Player\Height = 16
Player\lives=3
player\shieldtime = 500
SeedRnd seed
box.box=New box
box\x=0
box\y=GraphicsHeight()-128
box\w=GraphicsWidth()
box\h=32
For n=1 To 20
box.box = New box
box\x = Rand(0,(GraphicsWidth()-64)/32)*32
box\y = Rand(0,(GraphicsHeight()-160)/32)*32
box\w = Rand(2,5)*32
If box\x+box\w>GraphicsWidth()
box\w = 64
End If
box\h = 32
Next
For box.box = Each box
If Rand(0,2) = 1
coin.coin = New coin
coin\x = Rand(box\x,box\x+box\w)
coin\y = box\y-16
End If
If Rand(0,3)=1
monster.monster=New monster
monster\x=Rand(box\x,box\x+box\w)
monster\y=box\y-16
monster\box=box
monster\t=Rand(0,1)
If Rand(0,1)=0
monster\xd=-Rnd(0.1+0.2*monster\t,0.5+0.2*monster\t)
Else
monster\xd=Rnd(0.1+0.2*monster\t,0.5+0.2*monster\t)
EndIf
EndIf
Next
For n=1 To 20
bird.bird=New bird
bird\x = Rand(0,GraphicsWidth())
bird\y = Rand(0,GraphicsHeight())
If Rand(0,1)=0
bird\vx=Rnd(0.1,1)
Else
bird\vx=-Rnd(0.1,1)
EndIf
If Rand(0,1)=0
bird\vy=Rnd(0.01,0.5)
Else
bird\vy=-Rnd(0.1,1)
EndIf
Next
jump = True
scrollspeed# = 0.1
Score = 0
End Function
Function DrawBar(x,y,val#,max#,txt$,lf=False)
val = val/(max/100.0)
Color val*2.55,255-(val*1.28),0
Rect x,y-val-24,12,val
Color 0,0,0
Rect x ,y-100-24,14,100,False
Rect x+2,y-100-22,10,96,False
Color 255,255,255
Rect x+1,y-100-23,12,98,False
If lf
Outline_Text x+14-StringWidth(txt),y-18,txt$
Else
Outline_Text x,y-18,txt$
End If
End Function
Function Dustify(x,y,r,g,b)
For i = 0 To 30
d.dust = New dust
d\x = x
d\y = y
d\sx = Rnd(-2.0,2.0)
d\sy = Rnd(-5.0,2.0)
Next
End Function
Function LoseLife(player.player)
player\lives = player\lives-1
player\thrust = 10
player\angle = 180
player\shieldtime = 500
If player\lives < 0
gameover = True
player\x=-100
Return
Else
; reposition player
For box.box = Each box
If box\y<GraphicsHeight()-100 And box\y>100
If box\x>0 And box\x+box\w<GraphicsWidth()
player\y = box\y-32
player\x = Rand(box\x,box\x+box\w)
player\xd = 0
player\yd = 0
Exit
End If
End If
Next
End If
channel = PlaySound(die)
End Function
Function Outline_Text(x,y,t$,cx=False,cy=False,r=255,g=255,b=255)
Color 0,0,0
For i = -1 To 1
For j = -1 To 1
Text x+i,y+j,t,cx,cy
Next
Next
If r<0 Then r = 0
If g<0 Then g = 0
If b<0 Then b = 0
If r>255 Then r = 255
If g>255 Then g = 255
If b>255 Then b = 255
Color r,g,b
Text x,y,t,cx,cy
End Function
Function PointInBox(x,y,box.box)
If x=>box\x And x<=box\x+box\w
If y=>box\y And y<=box\y+box\h
Return True
End If
End If
Return False
End Function
Function DisplayCredits(t#,period#)
gwid=GraphicsWidth()/2
g10th=GraphicsHeight()/10
If t<(period/10)
x = t-(period/10)
ElseIf t>period-(period/10)
x = t-(period-(period/10))
End If
For i = 0 To 8
j = ((i Mod 2)*2)-1
shiftA = Sin((MilliSecs()/5)+i*20)*64
shiftB = Cos((MilliSecs()/8)+i*20)*64
shiftC = Sin((MilliSecs()/10)+i*20)*64
Outline_Text(gwid-x*j, (g10th*4.5)+(i*15),CreditsArray(i),True,True,192+shiftA,192+shiftB,192+shiftC)
Next
End Function
Function displayinstructions(t#,period#)
gwid=GraphicsWidth()/2
g10th=GraphicsHeight()/10
If t<(period/10)
x = t-(period/10)
ElseIf t>period-(period/10)
x = t-(period-(period/10))
End If
For i = 0 To 8
j = ((i Mod 2)*2)-1
shiftA = Sin((MilliSecs()/5)+i*20)*64
shiftB = Cos((MilliSecs()/8)+i*20)*64
shiftC = Sin((MilliSecs()/10)+i*20)*64
Outline_Text(gwid-x*j, (g10th*4.5)+(i*15),instructionsArray(i),True,True,192+shiftA,192+shiftB,192+shiftC)
Next
End Function
Function frontend()
DrawImage logo,GraphicsWidth()/2,(GraphicsHeight()/2)-100+(Sin(MilliSecs()/5)*20)
gwid=GraphicsWidth()/2
ghie=GraphicsHeight()/2
g10th=GraphicsHeight()/10
t=MilliSecs() Mod 10000
If Sin(MilliSecs()/2)>0
Outline_Text gwid,g10th*8,"INSERT COIN",True,True
EndIf
If t<5000
displaycredits(t,5000)
Else
displayinstructions(t-5000,5000)
End If
End Function
Function createcharacter(r#,g#,b#)
temp=LoadImage("characterbw.png")
char=CreateImage(ImageWidth(temp),ImageHeight(temp))
r=r/255
g=g/255
b=b/255
LockBuffer ImageBuffer(temp)
LockBuffer ImageBuffer(char)
For x=0 To ImageWidth(temp)
For y=0 To ImageHeight(temp)
val#=getr(ImageBuffer(temp),x,y)
If val>0
If val>240
writergb(char,x,y,val,val,val)
Else
writergb(char,x,y,r*val,g*val,b*val)
EndIf
EndIf
Next
Next
UnlockBuffer ImageBuffer(temp)
UnlockBuffer ImageBuffer(char)
FreeImage temp
SaveImage(char,"temp.bmp")
char=LoadAnimImage("temp.bmp",16,16,0,11*5)
Return char
End Function
Function getr(buffer,x,y)
argb=ReadPixelFast(x,y,buffer)
Return (ARGB Shr 16) And $ff
End Function
Function writergb(image_name,x,y,red,green,blue)
argb=(blue Or (green Shl 8) Or (red Shl 16) Or ($ff000000))
WritePixelFast x,y,argb,ImageBuffer(image_name)
End Function
|
| ||
| Gotta be careful here, Jeppe's version hasn't got the Fredborg mods. |
| ||
| Cool! I like this game :) you should put it on Blitzcoder |
| ||
| http://www.corstorphineonline.com/files/JumpAround.zip graphics and sounds in folders, changed my name in the credits to the real thing. |
| ||
| I think it might need a frame limiter... |
| ||
| I have fixed my above post, to have the latest source version. |
| ||
| Ok, guys! Hang on, I will put a fully updated version together! |
| ||
| I think it needs to stay on one thread cermit! It's already getting fragmented. I'd like to nominate Fredborg to be the keeper of the code and distribute the zips otherwise we're going to get out of control very quickly. For the future... Can we post the original code we've changed and the replacement code (or something like that) so it's easy to locate and update the master code. Fredborg, are you happy with this? |
| ||
| i think we should only update the code/resources, after fredborg have uploaded the code and gave his okey :) IF Fredborg is happy with this :) Fredborg, the code-keeper (sound good) :) |
| ||
| Hi, I don't really have time to do it, but what the heck :) Here is the latest version: http://www.frecle.net/misc/JumpAround.zip Includes Perturbatio's changes and Jeppe's new monster. I changed the CharacterCreate function, so it doesn't save a temporary image. |
| ||
Just created a diamond thingie, this could be added to give more points than the coins: |
| ||
| for levels, I was thinking that there could be a prerequisite number of coins to pick up, then it changes to another level (level details can be stored in a data statement i.e. Data 1014,15 (level seed, number of coins). This way, if playing multiplayer, the first person to achieve the goal wins that level. |
| ||
| We could also do it like this: Whenever someone wants to add something, they post a note to tell everyone to wait adding stuff until they have added their thingie. I will then try to keep a fully updated zip available! Rob, you should add a link to this in the top most thread, with a few instructions for people dropping in! What do you think? |
| ||
| I think each level should have a number of coins available and you just have to get to a certain height. Also, each level needs a graphics set too, personally I'd store each level in an external file, but that's just me. Things to create the level: level seed coins available diamonds available inital speed of scrolling speed up of scrolling height to reach cls colour red cls colour green cls colour blue graphic set (would all have the same names but held in different folders to make for easy loading) Just my thoughts. |
| ||
| and a link to www.frecle.net/misc/JumpAround.zip since this will be always the actuell archive :) |
| ||
| Also... This would make the folder stucture: \JumpAround\ Jumparound.exe \JumpAround\Sounds blah.ogg \JumpAround\Images common graphics \JumpAround\Images\1 Level 1 images \JumpAround\Images\2 Level 2 images etc The level specific images I forsee would be: Background00.png Bird00.png Fall00.png Monster00.png Monster01.png Tiles00.png Also maybe an additional level setting would be max height of birds as the birds could be balloons, bats, anything!? Not only but also... If we have a set height to reach we could have the inital cls colour r,g,b and the end cls colour r,g,b and it fades from one colour to the other over the course of height after the background image has scrolled off the screen. |
| ||
| Wowsa, this is definitely getting to commercial quality. Hm, this could be an interesting approach to developing shareware games collectively, seeding lots of ideas via a pass-the-baton approach and then formalizing development of the most promising ideas. Perhaps this thread needs to be deleted and moved to a private forum... I think this game has developed long enough without a storyline. Here's an initial suggestion, tell me what you guys think (eg. "That story sucks, write a new one.") ***** For many eons the lowly Blips crawled around the ground, scavenging the scraps of food which fell to them from the sky. Every day the Blips looked skyward, dreaming of the riches above. Eventually one Blip, named Bop, learned a marvelous new ability, the ability to jump! With this new ability, Bop was able to finally end his crawling and explore skyward. Above the ground Bop discovered riches were indeed waiting. Besides food, he found coins, gems, and other treasures. However, Bop also discovered creatures living in the sky, and these denizens of the sky were not happy to see a Blip invading their domain. Help Bop explore the sky and collect treasure, but avoid the monsters and other hazards along the way. ***** Already I can see one problem with this story, that there's no ultimate goal. It might be better to set things up so that there is some ultimate goal, like rescuing some other character or defeating a villain or something. |
| ||
| These all sounds like great ideas :) |
| ||
| The final goal coud be the legendary gold horde of the sky people. |
| ||
| Good idea, although to keep things from being morally ambiguous I'll add something about what bad guys the sky people are (so that the player won't feel bad about stealing from them.) |
| ||
| How about the sky people taking all the blips stuff :P now we're into silly storylines, kinda robin hood style story... The lowly blips are forced to pay taxes to the sky people who rain down rocks from the sky if they don't get their way. So your brave blob steps up to to take back what belongs to the blips and beat the sky people. ;) |
| ||
| Well I'm off home soon so I won't be seeing this thread until tomorrow! Can't wait to see where this is when I next see it! :) |
| ||
In the meantime...Hacked in dodgey death sequence thingy ;o)In ZIPYAN |
| ||
| Taxes, I like that angle. New story coming up! ADDITION: How's this? *** For many eons the lowly Blips crawled around the ground, scavenging what they could find. Although the ground was full of treasures, like gold and gems, the Blips existed in poverty. Every time they found any treasure, the Sky Devils would come and take it away. The poor Blips were powerless to fight back, for they were trapped on the ground while the Sky Devils lived in the clouds above them. The Sky Devils mocked the helpless Blips, shouting down taunts and dropping rocks from the sky. Every day the Blips looked skyward, dreaming of the riches above, but never able to reach those heights because they were stuck to the ground. Eventually one Blip, named Bop, learned a marvelous new ability, the ability to jump! With this new ability, Bop was able to finally end his crawling and move skyward. Now Bop intends to confront the Sky Devils and find their legendary horde of stolen gold. Help brave Bop reclaim the Blips' treasures, but avoid the monsters and other hazards along the way. |
| ||
| The zip has been updated with Yan's contributions! Jhocking, it's as silly as any old platform game story :) But more inventive than 'A has invaded B, you are the only C who can save D from certain doom' :) |
| ||
| Some new night graphics: Dark background ![]() A bat: ![]() A new monster: ![]() Jhocking, the story sounds good to me, nice and silly :) |
| ||
| I'll try adding the story later, possibly as scrolling text which appears if you wait before starting a new game, or possibly the first thing you see when you start a new game. I can't get around to it for a while however, so if someone else wants to add the story to the game that would be great. The new monsters, while pretty cool, don't really fit in. It looks like some sort of undead themed monster game, like Ghosts and Goblins. |
| ||
I better post before anyone else doesType box
Field x#,y#,w,h
End Type
Type coin
Field x#,y#,frame#
End Type
Type Player
Field x#,y#,frame#
Field xd#,yd#,angle#
Field Width, Height
Field lives
Field Thrust#
Field Thrusting
Field ThrustFrame
Field ThrustFrameDir
Field shieldtime
Field dying
End Type
Type Message
Field x,y#,life,txt$
End Type
Type rock
Field x#,y#
Field speed#
End Type
Type poof
Field x#,y#,sx#,sy#
Field count
End Type
Type dust
Field x#,y#,sx#,sy#
End Type
Type monster
Field t
Field x#,y#,frame#
Field xd#,yd#
Field box.box
Field dead
End Type
Type bird
Field x#,y#,frame#
Field vx#,vy#
End Type
Graphics 640,480,0,2
HidePointer
power#=0
Dim CreditsArray$(10)
CreditsArray(0) = "A BlitzBasic Community Project"
CreditsArray(1) = "Created by the following people"
CreditsArray(2) = "In order they appeared in the thread:"
CreditsArray(3) = "Rob Farley (original codebase)"
CreditsArray(4) = "Kris Kelly"
CreditsArray(5) = "Mikkel Fredborg"
CreditsArray(6) = "RetroBooster"
CreditsArray(7) = "Marcus Matt"
CreditsArray(8) = "Jeppe Nielsen"
CreditsArray(9) = "Yan"
CreditsArray(10)= "eBusiness"
Dim instructionsArray$(8)
instructionsArray(0) = "Jump from platform to platform"
instructionsArray(1) = "Blah blah blah blah"
instructionsArray(2) = ""
instructionsArray(3) = "Keys:"
instructionsArray(4) = "Left: Angle left"
instructionsArray(5) = "Right: Angle right"
instructionsArray(6) = "Down: Jump (hold to increase power)"
instructionsArray(7) = "Up: Thrust (if you have any thurst)"
instructionsArray(8) = "Shift: Fine tune angle"
Const keyleft=203
Const keyright=205
Const keyjump=200
Const keyUp = 57
;Const keyFineAngle = 54
Const THRUST_MAX = 50
Const keySkip=208
Const angleMod=2
Global gotr=0
Global gotg=0
Global gotb=0
;Global angleMod = 5
Global Player.Player = New Player
Global jump
Global Score
Global Scrollspeed#
Global highscore
Global oldtime, newtime
highfile=OpenFile("HighScore")
If highfile
highscore=ReadLine(highfile)
CloseFile highfile
Else
highscore=200
highfile=WriteFile("HighScore")
WriteLine highfile,highscore
CloseFile highfile
EndIf
Global gameover = True
SetBuffer BackBuffer()
Reset()
; Load Sounds
Global getcoin = LoadSound("sounds/coin.ogg")
Global die = LoadSound("sounds/die.ogg")
Global dieplayed = False
Global bg = LoadSound("sounds/bg.ogg")
LoopSound bg
Global bgchannel = PlaySound(bg)
Global boom = LoadSound("sounds/boom.ogg")
; Load images
Global backdrop = LoadImage("images/Background00.png")
Global arrow = LoadImage("images/arrow00.png")
Global rockimage = LoadImage("images/Fall00.png")
Global poofimage = LoadImage("images/poof00.png")
Global tiles = LoadAnimImage("images/Tiles00.png",32,32,0,3)
Global coins = LoadAnimImage("images/Coins00.png",16,16,0,8)
Global character = createcharacter("images/CharacterBW.png",100,255,100)
HandleImage character, Player\Width/2,Player\Height-2
Global thruster = LoadAnimImage("images/thrust00.png", 16,16,0,3)
HandleImage thruster, 8, 0
Global birds = LoadAnimImage("images/Bird00.png",16,16,0,4)
Global logo = LoadImage("images/Logo00.png")
MidHandle logo
Dim monsters(1)
For n=0 To 1
monsters(n) = LoadAnimImage("images/Monster0"+Str(n)+".png",16,16,0,4)
Next
backscroll# = GraphicsHeight()-ImageHeight(backdrop)
ClsColor 154,198,237
SetFont LoadFont("tahoma",15,True)
Repeat
Cls
backscroll = backscroll + (scrollspeed*0.025)
DrawImage backdrop,0,backscroll
If player\dying = 0
If jump = False
; If KeyDown(keyFineAngle) Then angleMod = 1 Else angleMod = 1
If KeyDown(keyright) And Player\angle<270 Then Player\angle=Player\angle+angleMod
If KeyDown(keyleft) And Player\angle>90 Then Player\angle=Player\angle-angleMod
If KeyDown(keyright) And Player\angle=270 Then Player\x=Player\x+.4
If KeyDown(keyleft) And Player\angle=90 Then Player\x=Player\x-.4
If KeyDown(keySkip) Then
Player\y=Player\y+5
jump = True
End If
Else
If KeyDown(keyright) Then player\xd = player\xd+0.05
If KeyDown(keyleft) Then player\xd = player\xd-0.05
End If
If KeyDown(keyUp) And Player\Thrust > 0 Then
Player\yd = Player\yd-0.2
Player\Thrust = Player\Thrust - 0.1
Player\Thrusting = True
jump = True
DebugLog Player\Thrust
Else
Player\Thrusting = False
EndIf
; Down grade shield time
If player\shieldtime>0
player\shieldtime = player\shieldtime - 1
End If
If KeyDown(keyjump) And jump=False And Int(xd+yd)=0 Then power=power+20
If power>1000 Then power=1000
; jump
If KeyDown(keyjump)=False And power>0
power=power/10
Player\xd=Sin(-Player\angle)*Sqr(power)
Player\yd=Cos(-Player\angle)*Sqr(power)
power=0
jump = True
deck=False
EndIf
If jump
Player\yd = Player\yd+.1
Player\xd = Player\xd*.99
Player\yd = Player\yd*.99
Else
player\yd = 0
player\xd = 0
End If
oldx#=Player\x
oldy#=Player\y
Else
player\yd = player\yd + 0.1
player\frame = Int(player\frame + 1) Mod 55
EndIf
Player\x=Player\x+Player\xd
Player\y=Player\y+Player\yd+scrollspeed
For bird.bird=Each bird
DrawImage birds,bird\x,bird\y,bird\frame
bird\x=bird\x+bird\vx
bird\y=bird\y+bird\vy+ScrollSpeed
bird\frame = (bird\frame + 0.05) Mod 3
If bird\x<0
bird\x=GraphicsWidth()
EndIf
If bird\y<0
bird\y=GraphicsHeight()
EndIf
If bird\x>GraphicsWidth()
bird\x=0
EndIf
If bird\y>GraphicsHeight()
bird\y=0
EndIf
Next
; draw level
For box.box = Each box
For sx = 0 To box\w-32 Step 32
frame = 1
If sx = 0 Then frame = 0
If sx = box\w-32 Then frame = 2
DrawImage tiles,box\x+sx,box\y,frame
Next
box\y = box\y + ScrollSpeed
If box\y > GraphicsHeight()
box\x = Rand(0,(GraphicsWidth()-64)/32)*32
box\y = -32
box\w = Rand(2,5)*32
If box\x+box\w>GraphicsWidth()
box\w = 64
End If
If Rand(0,2) = 1
coin.coin = New coin
coin\x = Rand(box\x,box\x+box\w)
;prevent a coin appearing too far to the right where the player can't reach it
If coin\x > GraphicsWidth()-10 Then coin\x = GraphicsWidth()-10
coin\y = box\y-16
End If
If Rand(0,3)=1
monster.monster=New monster
monster\x=Rand(box\x,box\x+box\w)
monster\y=box\y-16
monster\box=box
monster\t=Rand(0,1)
If Rand(0,1)=0
monster\xd=-Rnd(0.1+0.2*monster\t,0.5+0.2*monster\t)
Else
monster\xd=Rnd(0.1+0.2*monster\t,0.5+0.2*monster\t)
EndIf
EndIf
End If
Next
For coin.coin = Each coin
DrawImage coins,coin\x,coin\y,coin\frame
coin\y = coin\y + ScrollSpeed
coin\frame = (coin\frame + 0.1) Mod 7
If player\dying = 0
If RectsOverlap(Player\x-2,Player\y-2,5,5,coin\x,coin\y,16,16)
score = score + 100
If score>highscore
highscore=score
highfile=WriteFile("HighScore")
WriteLine highfile,highscore
CloseFile highfile
EndIf
m.message = New message
m\x = coin\x
m\y = coin\y-10
m\life = 100
m\txt = "100"
PlaySound(getcoin)
Delete coin
If (Score Mod 500) = 0
Player\Thrust=Player\Thrust+10
m\txt$ = "EXTRA THRUST"
End If
If Player\Thrust > THRUST_MAX Then Player\Thrust = THRUST_MAX
If (Score Mod 5000) = 0
Player\Lives = Player\Lives + 1
m\txt$ = "EXTRA LIFE"
End If
ElseIf coin\y > GraphicsHeight()
Delete coin
End If
EndIf
Next
For monster.monster=Each monster
DrawImage monsters(monster\t),monster\x,monster\y,monster\frame
If monster\dead
monster\x = monster\x + monster\xd
monster\y = monster\y + monster\yd
monster\yd = monster\yd * 0.99 + 0.1
monster\xd = monster\xd * 0.99
Else
monster\y=monster\y+ScrollSpeed
monster\frame = (monster\frame + 0.1) Mod 3
monster\x=monster\x+monster\xd
If monster\x+16>monster\box\x+monster\box\w
monster\xd=-Rnd(0.1,0.5)
ElseIf monster\x<monster\box\x
monster\xd=Rnd(0.1,0.5)
EndIf
If player\dying = 0
dx#=((monster\x+8)-player\x)
dy#=(monster\y+8-player\y)
If (dx*dx+dy*dy)<32*32
If Sin(MilliSecs())>0
Outline_text player\x,player\y-30,"Watch out!",1,1
EndIf
EndIf
If RectsOverlap(Player\x-2,Player\y-2,5,5,monster\x,monster\y,16,16)
If player\shieldtime = 0
;LoseLife(player)
player\dying = 1
player\yd = -3
player\xd = 0
m.message = New message
m\x = player\x
m\y = player\y
m\life = 100
m\txt = "EEK!"
End If
ElseIf monster\y > GraphicsHeight()
Delete monster
End If
EndIf
End If
Next
For rock.rock = Each rock
For monster.monster = Each monster
If monster\dead = False
If ImagesOverlap(monsters(monster\t),monster\x,monster\y,rockImage,rock\x,rock\y)
monster\dead = True
monster\xd = Rnd(-2.5,2.5)
monster\yd = Rnd(-5.0,-3.0)
End If
End If
Next
Next
If player\dying = 0
; Player frame
temp = Abs(Int(player\yd))*11
If temp>22 Then temp = 22
Player\frame = 27 + (((player\angle-180)/90.0)*5) - (Int(power/500)*11) + temp
; Sides of screen
If Player\x<10 Or Player\x>GraphicsWidth()-10
Player\x = oldx
Player\xd = -Player\xd/2
End If
; Top of screen
If player\y<0
player\y = oldy
player\yd = 0
End If
For box.box = Each box
; Y Collision
If Player\yd>0
collisionA = PointInBox(Player\x,Player\y+1,box)
collisionB = PointInBox(Player\x,Player\y-5,box)
If collisionA = True And collisionB = False
deck = True
Player\y = oldy
Player\xd=Player\xd*.9
Player\yd=-Player\yd/3
Player\Angle = 180
If Abs(player\xd)<0.2 And Abs(player\yd)<0.2
jump = False
End If
EndIf
EndIf
Next
EndIf
; Bottom of screen
If Player\y>GraphicsHeight()+40
LoseLife(player)
End If
; rocks!
If Rand(0,400) = 0
rock.rock = New rock
rock\x = Rand(16,GraphicsWidth()-16)
rock\y = -600
rock\speed = Rnd(2,4)
EndIf
For rock.Rock = Each rock
kill =False
rock\y = rock\y + rock\speed
If rock\y<-32
If Rand(-600,-100)<rock\y
DrawImage arrow,rock\x,0
End If
Else
DrawImage rockImage, rock\x,rock\y
End If
If rock\y > GraphicsHeight()
kill = True
EndIf
For box.box = Each box
If ImageRectCollide(rockimage,rock\x,rock\y,0,box\x,box\y,box\w,box\h)
For i = 0 To 10
poof.poof = New poof
poof\x = rock\x
poof\y = rock\y
a# = Rnd(0,360)
ms# = Rnd(1.5,5.0)
poof\sx = Sin(a)*ms
poof\sy = Cos(a)*ms
Next
Dustify(rock\x+16,rock\y,120,100,80)
kill = True
EndIf
Next
If player\dying = 0
If ImagesOverlap(character,player\x,player\y,rockImage,rock\x,rock\y)
For i = 0 To 10
poof.poof = New poof
poof\x = rock\x
poof\y = rock\y
a# = Rnd(0,360)
ms# = Rnd(1.5,5.0)
poof\sx = Sin(a)*ms
poof\sy = Cos(a)*ms
Next
Dustify(rock\x+16,rock\y,120,180,140)
kill = True
If player\shieldtime = 0
;LoseLife(player)
player\dying = 1
player\yd = -3
player\xd = 0
m.message = New message
m\x = player\x
m\y = player\y
m\life = 100
m\txt = "SQUISH!"
End If
EndIf
EndIf
If kill
SoundVolume boom,.1
PlaySound(boom)
Delete rock
End If
Next
; Poof clouds
drawpoof = Not drawpoof
If drawpoof
For poof.poof = Each poof
poof\x = poof\x + poof\sx
poof\y = poof\y + poof\sy
poof\sx = poof\sx * 0.9
poof\sy = poof\sy * 0.9
If Rand(10,20)>poof\count
DrawImage poofImage, poof\x,poof\y
End If
poof\count = poof\count + 1
If poof\count > 20 Then Delete poof
Next
End If
; dust/rubble
Color 120,100,80
For dust.dust = Each dust
dust\x = dust\x + dust\sx
dust\y = dust\y + dust\sy
dust\sx = dust\sx * Rnd(0.95,0.999)
dust\sy = (dust\sy * Rnd(0.95,0.999)) + 0.1
Rect dust\x,dust\y,2,2
If dust\y > GraphicsHeight() Then Delete dust
Next
If gameover
player\x = -100
player\y = -100
player\xd = 0
player\yd = 0
frontend()
If KeyDown(57)
gameover=False
backscroll# = GraphicsHeight()-ImageHeight(backdrop)
Reset()
EndIf
Else
; draw player
If player\dying
If (MilliSecs() And 1)
DrawImage character, Player\X,Player\Y,Player\frame
EndIf
Else
If jump = False
Color 255,0,0
Line Player\x+(Sin(-Player\angle)*16),Player\y-4+(Cos(-Player\angle)*16),Player\x+(Sin(-Player\angle)*32),Player\y-4+(Cos(-Player\angle)*32)
Line Player\x+(Sin(-Player\angle+5)*27),Player\y-4+(Cos(-Player\angle+5)*27),Player\x+(Sin(-Player\angle)*32),Player\y-4+(Cos(-Player\angle)*32)
Line Player\x+(Sin(-Player\angle-5)*27),Player\y-4+(Cos(-Player\angle-5)*27),Player\x+(Sin(-Player\angle)*32),Player\y-4+(Cos(-Player\angle)*32)
End If
DrawImage character, Player\X,Player\Y,Player\frame
EndIf
If Player\Thrusting Then
DrawImage thruster, Player\X,Player\Y+2,Player\ThrustFrame
If Player\ThrustFrame = 0 Then Player\ThrustFrameDir = 1 ElseIf Player\ThrustFrame = 2 Then Player\ThrustFrameDir = -1
Player\ThrustFrame = Player\ThrustFrame + Player\ThrustFrameDir
EndIf
If player\shieldtime>0
If Rand(0,100)<player\shieldtime
Color 255,255,255
Oval player\x-10,player\y-14,20,20,False
End If
End If
End If
; Draw Power bar
DrawBar(8,GraphicsHeight(),power,100,"POWER")
; Draw Thrust bar
DrawBar(GraphicsWidth()-24,GraphicsHeight(),player\thrust,THRUST_MAX,"THRUST",True)
Outline_Text GraphicsWidth()-120,10,"SCORE "+Replace(RSet(score,8)," ","0")
Outline_Text GraphicsWidth()/2,10,"HIGHSCORE "+Replace(RSet(highscore,8)," ","0"),True
For i = 1 To player\lives
DrawImage character,((i-1)*16)+16,20,27
Next
For m.message = Each message
m\y = m\y - 0.5
m\life = m\life - 1
If Rand(0,50)<m\life
Outline_Text m\x,m\y,m\txt,True,True
End If
If m\life <= 0
Delete m
End If
Next
Flip
ScrollSpeed = ScrollSpeed + 0.00001
Until KeyHit(1)
End
Function Reset(seed=1014)
Delete Each box
Delete Each coin
Delete Each monster
Delete Each Message
Delete Each rock
Delete Each poof
Delete Each dust
Delete Each bird
Player\x#=GraphicsWidth()/2
Player\y#=GraphicsHeight()/2
Player\frame = 5
Player\xd# = 0
Player\yd# = 0
Player\angle# = 180
Player\Width = 16
Player\Height = 16
Player\lives=3
player\shieldtime = 500
player\dying = 0
SeedRnd seed
box.box=New box
box\x=0
box\y=GraphicsHeight()-128
box\w=GraphicsWidth()
box\h=32
For n=1 To 20
box.box = New box
box\x = Rand(0,(GraphicsWidth()-64)/32)*32
box\y = Rand(0,(GraphicsHeight()-160)/32)*32
box\w = Rand(2,5)*32
If box\x+box\w>GraphicsWidth()
box\w = 64
End If
box\h = 32
Next
For box.box = Each box
If Rand(0,2) = 1
coin.coin = New coin
coin\x = Rand(box\x,box\x+box\w)
coin\y = box\y-16
End If
If Rand(0,3)=1
monster.monster=New monster
monster\x=Rand(box\x,box\x+box\w)
monster\y=box\y-16
monster\box=box
monster\t=Rand(0,1)
If Rand(0,1)=0
monster\xd=-Rnd(0.1+0.2*monster\t,0.5+0.2*monster\t)
Else
monster\xd=Rnd(0.1+0.2*monster\t,0.5+0.2*monster\t)
EndIf
EndIf
Next
For n=1 To 20
bird.bird=New bird
bird\x = Rand(0,GraphicsWidth())
bird\y = Rand(0,GraphicsHeight())
If Rand(0,1)=0
bird\vx=Rnd(0.1,1)
Else
bird\vx=-Rnd(0.1,1)
EndIf
If Rand(0,1)=0
bird\vy=Rnd(0.01,0.5)
Else
bird\vy=-Rnd(0.1,1)
EndIf
Next
jump = True
scrollspeed# = 0.1
Score = 0
End Function
Function DrawBar(x,y,val#,max#,txt$,lf=False)
val = val/(max/100.0)/10
Color val*2.55,255-(val*1.28),0
Rect x,y-val-24,12,val
Color 0,0,0
Rect x ,y-100-24,14,100,False
Rect x+2,y-100-22,10,96,False
Color 255,255,255
Rect x+1,y-100-23,12,98,False
If lf
Outline_Text x+14-StringWidth(txt),y-18,txt$
Else
Outline_Text x,y-18,txt$
End If
End Function
Function Dustify(x,y,r,g,b)
For i = 0 To 30
d.dust = New dust
d\x = x
d\y = y
d\sx = Rnd(-2.0,2.0)
d\sy = Rnd(-5.0,2.0)
Next
End Function
Function LoseLife(player.player)
player\lives = player\lives-1
player\thrust = 10
player\angle = 180
player\shieldtime = 500
player\dying = 0
If player\lives < 0
gameover = True
player\x=-100
;Return
Else
; reposition player
For box.box = Each box
If box\y<GraphicsHeight()-100 And box\y>100
If box\x>0 And box\x+box\w<GraphicsWidth()
player\y = box\y-32
player\x = Rand(box\x,box\x+box\w)
player\xd = 0
player\yd = 0
Exit
End If
End If
Next
End If
channel = PlaySound(die)
End Function
Function Outline_Text(x,y,t$,cx=False,cy=False,r=255,g=255,b=255)
Color 0,0,0
For i = -1 To 1
For j = -1 To 1
Text x+i,y+j,t,cx,cy
Next
Next
If r<0 Then r = 0
If g<0 Then g = 0
If b<0 Then b = 0
If r>255 Then r = 255
If g>255 Then g = 255
If b>255 Then b = 255
Color r,g,b
Text x,y,t,cx,cy
End Function
Function PointInBox(x,y,box.box)
If x=>box\x And x<=box\x+box\w
If y=>box\y And y<=box\y+box\h
Return True
End If
End If
Return False
End Function
Function DisplayCredits(t#,period#)
gwid=GraphicsWidth()/2
g10th=GraphicsHeight()/10
If t<(period/10)
x = t-(period/10)
ElseIf t>period-(period/10)
x = t-(period-(period/10))
End If
For i = 0 To 10
j = ((i Mod 2)*2)-1
shiftA = Sin((MilliSecs()/5)+i*20)*64
shiftB = Cos((MilliSecs()/8)+i*20)*64
shiftC = Sin((MilliSecs()/10)+i*20)*64
Outline_Text(gwid-x*j, (g10th*4.5)+(i*15),CreditsArray(i),True,True,192+shiftA,192+shiftB,192+shiftC)
Next
End Function
Function displayinstructions(t#,period#)
gwid=GraphicsWidth()/2
g10th=GraphicsHeight()/10
If t<(period/10)
x = t-(period/10)
ElseIf t>period-(period/10)
x = t-(period-(period/10))
End If
For i = 0 To 8
j = ((i Mod 2)*2)-1
shiftA = Sin((MilliSecs()/5)+i*20)*64
shiftB = Cos((MilliSecs()/8)+i*20)*64
shiftC = Sin((MilliSecs()/10)+i*20)*64
Outline_Text(gwid-x*j, (g10th*4.5)+(i*15),instructionsArray(i),True,True,192+shiftA,192+shiftB,192+shiftC)
Next
End Function
Function frontend()
DrawImage logo,GraphicsWidth()/2,(GraphicsHeight()/2)-100+(Sin(MilliSecs()/5)*20)
gwid=GraphicsWidth()/2
ghie=GraphicsHeight()/2
g10th=GraphicsHeight()/10
t=MilliSecs() Mod 10000
If Sin(MilliSecs()/2)>0
Outline_Text gwid,GraphicsHeight()-12,"INSERT COIN",True,True
EndIf
If t<5000
displaycredits(t,5000)
Else
displayinstructions(t-5000,5000)
End If
End Function
Function createcharacter(file$,r#,g#,b#)
temp=LoadAnimImage(file$,16,16,0,11*5)
char=CreateImage(16,16,11*5)
r=r/255
g=g/255
b=b/255
For frame = 0 To (11*5)-1
LockBuffer ImageBuffer(temp,frame)
LockBuffer ImageBuffer(char,frame)
For x=0 To ImageWidth(temp)
For y=0 To ImageHeight(temp)
val#=getr(ImageBuffer(temp,frame),x,y)
If val>0
If val>240
writergb(ImageBuffer(char,frame),x,y,val,val,val)
Else
writergb(ImageBuffer(char,frame),x,y,r*val,g*val,b*val)
EndIf
EndIf
Next
Next
UnlockBuffer ImageBuffer(temp,frame)
UnlockBuffer ImageBuffer(char,frame)
Next
FreeImage temp
Return char
End Function
Function getr(buffer,x,y)
argb=ReadPixelFast(x,y,buffer)
Return (ARGB Shr 16) And $ff
End Function
Function writergb(buffer,x,y,red,green,blue)
argb=(blue Or (green Shl 8) Or (red Shl 16) Or ($ff000000))
WritePixelFast x,y,argb,buffer
End FunctionAtered the keys and stuff |
| ||
| Updated the zip! Includes eBusiness's stuff (I'm not sure I like the drop down thingy) but changed the keys a bit. Added Shooting (which still needs some work) Added ScorePoints function, to ease the inclusion of new point giving features :) http://www.frecle.net/misc/JumpAround.zip Keep it up! |
| ||
| I think the bigger this gets it might be a good idea to start shoving a lot of that code into functions. It would make it a hell of a lot easier to work with and code for. Its only gona get worse as the project grows. |
| ||
| Yes, very true! Do you volunteer? :) UpdateMonsters() UpdatePlayer() etc. Would be great! I have modded the zipped version slightly! |
| ||
| I think this thread is a modem killer by now, we better get a new one. |
| ||
| do you think we should go back and remove the source from our posts so this thread isn't so long? *Edit* except the first post |











