Page 3 of 4
Posted: Thu Feb 02, 2006 2:58 am
by Dark Mars Software
Hi Everyone!
I can't seem to get the ball to bounce off the sides of the screen. I have tried
Code: Select all
if ball_x_position > 432
ball_x_position = -ball_x_position
endif
And
Code: Select all
if ball_x_position > 432
ball_x_position = Abs(-ball_x_position)
endif
heres the code:
Code: Select all
fixed by changing the ball's velocity instead of the balls position
any ideas?
Posted: Thu Feb 02, 2006 12:56 pm
by dontmailme
You need to change the velocity when you detect the wall, not the position!
Try this....
Code: Select all
Removed due to request from author who doesn't want anyone to pirate his game!
To be honest with you, I don't think there will be many programmers in the world who has not written a pong/breakout game. Everytime I have learned a new language the first thig I usually do is code a Pong/Breakout game.
And believe me when I say that no programmer is going to pirate/purloin/copy your code unless they are an absolute beginner!
If you do manage to write an original piece of software which uses techniques that are currently unknown then you should not post it in a forum for everyone to see!
Good Luck with your game

Posted: Thu Feb 02, 2006 9:07 pm
by Dark Mars Software
Oh my god, Thank You. I'm now back on track.
Posted: Fri Feb 03, 2006 4:11 pm
by Dark Mars Software
Or maybe not
Code: Select all
PrintScores:Needed if StartDrawing()
CloseWindow:Still not fixed
Function PrintScores doesn't work and #PB_Event_CloseWindow in my main event loop doesn't work. Any ideas?
Posted: Sun Feb 05, 2006 11:07 pm
by Dark Mars Software
Anyone want to help me out?
Posted: Sun Feb 05, 2006 11:15 pm
by Pupil
You really should read up some more in the manual!! You need to check for the close window event in the little event loop that you have, the last event isn't necessary the close event! Also you probably need 'StartDrawing()'-'EndDrawing()' inside your printscore procedure.
Posted: Tue Feb 07, 2006 1:58 am
by Dark Mars Software
Problems Aarg
I created a function that Pauses and Unpauses my game when the P key is pressed. I managed to get it to pause but, for some reason it woun't unpause when the p key is pressed again. I coded my loop accordingly and have the examinekeyboard() event in the pause loop, so i don't quite understand what i'm doing wrong.
Any ideas?
Posted: Tue Feb 07, 2006 2:09 am
by Dare2
Without testing anything, just hazarding a guess. This line
uses ~ which is a Bitwise NOT.
Perhaps try something like:
Code: Select all
Repeat
delay(1)
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_P)
BTW, in version 4.00 we now have a NOT, so
If Not something works.
Hope that was it, if Not

, sorry!
Posted: Tue Feb 07, 2006 2:11 am
by Dark Mars Software
Well thats what i thought, i imagined that PB had a NOT operator like most programming languages do. Guess it does, atleast NOT yet.

As for 4.0, i will be using it once its stable enough.
Posted: Sun Feb 12, 2006 12:18 am
by Dark Mars Software
I have tried to fix this for awhile now and i coun't figure it out.
Problem 1: After a player wins its supposed to show a congrates message and delay a sec so the player can see the win message. The delay happens but, the scores don't switch to the win message. The game simply delays and the message don't get updated when a score reaches 15.
Problem 2:After the win message the game is supposed to reopen the title screen after the initial delay and closing of the game window. Instead it delays, closes the game window, and ends.
Code: Select all
1.Fixed by moving Flip() so that it is the last event that is executed in the game loop.
2.PB Bug. Will be fixed in Next PB 4 Beta.
Posted: Sun Feb 12, 2006 11:22 pm
by Dark Mars Software
No one has an answer to my problem?
Posted: Sun Feb 12, 2006 11:36 pm
by Pupil
Maybe you should flip the buffers before the delay..
BTW it's pretty hard to get a grip of what your code does when the posted code isn't indented properly. I have to consentrate really hard to see where a procedure starts, ends etc!!
Posted: Mon Feb 13, 2006 1:27 am
by Dark Mars Software
Thanks that worked. BTW 2 things:
1.I am planning on making this open-source
2.I'll find a way to beautify my code.
Posted: Mon Feb 13, 2006 4:09 pm
by Dark Mars Software
Any idea on a fix for the second problem? I still can't get it to work. I'm using PureBASIC 4.0 Beta 2.
Posted: Tue Feb 14, 2006 3:05 pm
by Dark Mars Software
Update:I rechecked the code and it looks fine. I guess this is a PB 4.0 Beta 2 bug.