Code: Alles auswählen
speed = 7
gravity = 15
If InitMouse() = 0 Or InitSound() = 0 Or InitSprite() = 0 Or InitKeyboard() = 0 Or InitMovie() = 0 ;Or sceenid = 0
MessageRequester("Error", "Please check your computer settings and update your software", 0) : End : EndIf
screenid = OpenScreen(640, 480, 32, "DER SPRINGENDE BALL")
CreateSprite(1, 60, 60)
StartDrawing(SpriteOutput(1)) : Circle(20, 20, 20, #Blue)
StopDrawing()
CreateSprite(2, 20, 20)
StartDrawing(SpriteOutput(2)) : Circle(10, 10, 10, #Green)
StopDrawing()
Repeat
If MouseButton(1) : speed+1 : EndIf
If MouseButton(2) And speed > 0 : speed-1 : EndIf
If y > 430 : back = 1 : EndIf
If y < 30 : back = 0 : EndIf
If x > 590 : colision = 1 : EndIf
If x <= 1 : colision = 0 : EndIf
If back = 0 : y+speed : Else : y-speed : EndIf
If colision = 1 : x-speed : Else : x+speed : EndIf
StartDrawing(ScreenOutput()) : Locate (5,5)
DrawText("ALPHA 0.2 - MouseX: "+Str(MouseX())+" - MouseY: "+Str(MouseY())+" - BallX: "+Str(x)+" - BallY: "+Str(y))
StopDrawing()
DisplaySprite(1,x,y)
TransparentSpriteColor(2,255, 255, 255)
DisplayTransparentSprite(2, MouseX(), MouseY())
ExamineKeyboard() : ExamineMouse() : FlipBuffers() : ClearScreen(0, 0, 0)
If KeyboardPushed(#PB_Key_A)
StartDrawing(ScreenOutput())
LineXY(MouseX(), MouseY(), x+15, y+15, #Green)
StopDrawing()
If MouseX() > x : x + gravity : Else : x - gravity : EndIf
If MouseY() > y : y + gravity : Else : y - gravity : EndIf
EndIf
Until KeyboardPushed(#PB_Key_Escape) > 0 : End
