ohne scrolling.
Code: Alles auswählen
EnableExplicit
Define w.l = 12 ; -- kartengoesse
Define h.l = 9 ; _/
Define playerIndexX.l ; -- player position (array-index)
Define playerIndexy.l ; _/
Define offX.l = 60 ; -- offset der gesamten darstellung (pixel)
Define offY.l = 40 ; _/
Define i.l,k.l
InitSprite()
InitKeyboard()
OpenScreen(1024,768,32,"fllscrn")
Enumeration
#sprPlayer
#sprDunkel
#sprHell
EndEnumeration
CreateSprite(#sprPlayer,64,64)
StartDrawing( SpriteOutput(#sprPlayer) )
Circle(32,32,16,$ff0000)
StopDrawing()
CreateSprite(#sprDunkel,64,64)
StartDrawing( SpriteOutput(#sprDunkel) )
Box(2,2,60,60,$aa3333)
StopDrawing()
CreateSprite(#sprHell,64,64)
StartDrawing( SpriteOutput(#sprHell) )
Box(2,2,60,60,$aa6666)
StopDrawing()
Dim map.l(w,h)
For i=0 To w
For k=0 To h
If Random(3)
map(i,k)=#sprHell
playerIndexX = i ; -- nur damit der spieler auch wirklich auf einem hellen feld steht
playerIndexy = k ; _/
Else
map(i,k)=#sprDunkel
EndIf
Next
Next
Procedure ERLAUBT(indexX.l, indexY.l)
Shared map(), w, h
If indexX>=0 And indexY>=0 And indexX<=w And indexY<=h And map(indexX,indexY)=#sprHell
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndProcedure
Repeat
ExamineKeyboard()
StartDrawing( ScreenOutput() )
;DrawText(100,100, Str(MouseDeltaX())+", "+Str(MouseDeltaY()) )
;Circle(MouseX(),MouseY(),5,$770000)
StopDrawing()
If KeyboardPushed(#PB_Key_Right) And ERLAUBT(playerIndexX+1, playerIndexY)
playerIndexX+1
EndIf
If KeyboardPushed(#PB_Key_Left) And ERLAUBT(playerIndexX-1, playerIndexY)
playerIndexX-1
EndIf
If KeyboardPushed(#PB_Key_Up) And ERLAUBT(playerIndexX, playerIndexY-1)
playerIndexY-1
EndIf
If KeyboardPushed(#PB_Key_Down) And ERLAUBT(playerIndexX, playerIndexY+1)
playerIndexY+1
EndIf
For i=0 To w
For k=0 To h
DisplaySprite( map(i,k), offX+ i*64, offY + k*64)
Next
Next
DisplayTransparentSprite(0, offX + playerIndexX*64, offY + playerIndexY*64)
FlipBuffers()
ClearScreen(0)
Delay(50)
Until KeyboardReleased(#PB_Key_Escape)