Forum allemand
il y a aussi cette archive qui peut intéresser quelqu'un, c'est sur le même thème, saut, échelle, petit jeu de plateforme.
http://www.jumpingeyes.ch/download/jnr_ ... s_v1_4.zip
Code : Tout sélectionner
; scrolljump.pb
; von DenKle
; 23. November 2008
; einfaches scrollen mit jump funktion
;Init
InitSprite()
InitKeyboard()
;Fenster
OpenWindow(0, 0, 0, 640, 480, "scrolljump", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, 640, 480, 0, 0, 0)
; Variablen
Global Dim LevelDaten.l(15, 20)
Global scroll_x.l
Global scroll_y.l
Global player_x.l=300
Global player_y.l=320
Global jump.b
Global jump_height.f
; Prozeduren
Procedure LevelEinlesen()
Restore leveldata
For Y = 0 To 14
For X = 0 To 19
Read LevelDaten(Y,X)
Next
Next
EndProcedure
Procedure LevelAusgeben()
For Y = 0 To 14
For X = 0 To 19
If LevelDaten(Y,X) = 1
Box(X * 32 - scroll_x, Y * 32 - scroll_y,32,32,RGB(250,0,0))
EndIf
Next
Next
EndProcedure
Procedure DrawPlayer()
Box(player_x, player_y, 32, 64, RGB(0, 250, 0))
EndProcedure
Procedure MovePlayer(); scroll
If KeyboardPushed(#PB_Key_Left)
If LevelDaten(((player_y +16)+ scroll_y) /32,((player_x-4)+ scroll_x) /32)=0 And LevelDaten(((player_y +48)+ scroll_y) /32,((player_x-4)+ scroll_x) /32)=0
scroll_x-4
EndIf
ElseIf KeyboardPushed(#PB_Key_Right)
If LevelDaten(((player_y +16)+ scroll_y) /32,((player_x +32)+ scroll_x) /32)=0 And LevelDaten(((player_y +48)+ scroll_y) /32,((player_x +32)+ scroll_x) /32)=0
scroll_x+4
EndIf
EndIf
EndProcedure
Procedure PlayerJump()
If KeyboardPushed(#PB_Key_Space) And jump = 0
jump = 1
jump_height = 10;sprunghöhe
EndIf
;von der Decke abprallen
If LevelDaten(((player_y-4)+ scroll_y) /32,((player_x +16)+ scroll_x) /32)=1 And jump = 1
jump = 0
scroll_y+2
EndIf
;springen
If jump = 1
jump_height - 0.33
scroll_y - jump_height
;solange jump_height grösser als 0 ist, bewegt sich die figur hoch
If jump_height =< 0
If LevelDaten(((player_y +64)+ scroll_y) /32,((player_x +16)+ scroll_x) /32)=1
jump = 0
;genaue position setzen, falls die figur im tile steht
temp = (player_y + scroll_y) /32
scroll_y = (temp*32)-player_y
EndIf
EndIf
EndIf
;fallen
If jump = 0 And LevelDaten(((player_y +64)+ scroll_y) /32,((player_x +16)+ scroll_x) /32)=0
jump = 1
jump_height = 0
EndIf
EndProcedure
;Level Laden
LevelEinlesen()
;-Schleife
Repeat
EventID.l=WindowEvent()
ExamineKeyboard()
ClearScreen(RGB(0,0,50))
StartDrawing(ScreenOutput())
LevelAusgeben()
DrawPlayer()
MovePlayer()
PlayerJump()
StopDrawing()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or EventID=#PB_Event_CloseWindow
End
DataSection
leveldata:
Data.l 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
Data.l 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.l 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.l 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.l 1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1
Data.l 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.l 1,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1
Data.l 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.l 1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1
Data.l 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.l 1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.l 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.l 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.l 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.l 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
EndDataSection