I try to create an simple block, they must be bounce from under to above, but it doesn't work perfect...
So This is my script, written in PB5.6.2, on Windows XP:
Code: Select all
Procedure Initialize2D()
If InitSprite() = 0
MessageRequester("Fatal Error", "Failed to Initialize Sprites", #PB_MessageRequester_Error)
End
EndIf
If InitKeyboard() = 0
MessageRequester("Fatal Error", "Failed to Initialize Keyboard", #PB_MessageRequester_Error)
End
EndIf
If OpenScreen(640, 480, 32, "") = 0
MessageRequester("Fatal Error", "Failed to Open Screen", #PB_MessageRequester_Error)
End
EndIf
EndProcedure
Initialize2D()
Global X.i = 64
Global Y.i = 480
Procedure Draw2D()
Repeat
Select Direction
Case 1
Y - 2
Case 2
Y + 2
EndSelect
StartDrawing(ScreenOutput())
Box(X, Y, 32, 32, RGB(255, 32, 100))
StopDrawing()
FlipBuffers()
ClearScreen(0)
ExamineKeyboard()
Direction = 1
If Y < 0
Direction = 2
EndIf
If Y > 480
Direction = 1
EndIf
If KeyboardPushed(#PB_Key_Escape)
End
EndIf
ForEver
EndProcedure
Draw2D()
Just run this script and you should see thad this isn't work perfect...
Here my problem:
- The Box starts from under (position Y > 480) to above...
- But if he bounced from position 'Y < 0', than he don't goes to under... He is and remains on the 'Y < 0' Position..
If you can see what the problem is, please correct my code so simple as possible, just i can learn about it...
Pleace, only correct my code so simple as possible, without dificult and complex example.... i am an noob with
programming, just pleace, try to correct my code so simple as possible...
Thanks for help, Jamie.