Code: Alles auswählen
OpenWindow(0, 50,50, 600, 400, "Box", #PB_Window_SystemMenu |#PB_Window_MaximizeGadget |#PB_Window_MinimizeGadget )
InitKeyboard()
InitSprite()
OpenWindowedScreen(WindowID(0), 0, 0,600,400, 1, 1, 20)
CreateSprite(0,25,25)
StartDrawing(SpriteOutput(0))
Box(0,0,25,25,RGB(0,0,250))
StopDrawing()
CopySprite(0,1,0)
score=0
CreateFile(0, "score.txt")
WriteInteger("score.txt",score)
Repeat
ExamineKeyboard()
FlipBuffers()
ClearScreen(0)
DisplaySprite(0,x,y)
DisplaySprite(1,100,100)
If SpriteCollision(0,x,y,1,100,100)=1
ClearScreen(0)
DisplaySprite(0,x,y)
score=score+1
EndIf
If KeyboardPushed(#PB_Key_Right)
x=x+10
If x>=600
x=0
EndIf
EndIf
If KeyboardPushed(#PB_Key_Left)
x=x-10
If x<=0
x=599
EndIf
EndIf
If KeyboardPushed(#PB_Key_Down)
y=y+10
If y>=400
y=0
EndIf
EndIf
If KeyboardPushed(#PB_Key_Up)
y=y-10
If y<=0
y=399
EndIf
EndIf
Until WaitWindowEvent() = #PB_Event_CloseWindow