Pong Master - WIP Error Help?

Just starting out? Need help? Post your questions and find answers here.
Dark Mars Software
User
User
Posts: 68
Joined: Sat Jun 19, 2004 3:34 am
Location: USA
Contact:

Post 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?
Last edited by Dark Mars Software on Thu Feb 02, 2006 9:07 pm, edited 1 time in total.
dontmailme
Enthusiast
Enthusiast
Posts: 537
Joined: Wed Oct 29, 2003 10:35 am

Post 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 :D
Last edited by dontmailme on Sat Feb 04, 2006 10:21 pm, edited 1 time in total.
Paid up PB User !
Dark Mars Software
User
User
Posts: 68
Joined: Sat Jun 19, 2004 3:34 am
Location: USA
Contact:

Post by Dark Mars Software »

Oh my god, Thank You. I'm now back on track.
Dark Mars Software
User
User
Posts: 68
Joined: Sat Jun 19, 2004 3:34 am
Location: USA
Contact:

Post 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?
Last edited by Dark Mars Software on Sun Feb 12, 2006 11:25 pm, edited 2 times in total.
Dark Mars Software
User
User
Posts: 68
Joined: Sat Jun 19, 2004 3:34 am
Location: USA
Contact:

Post by Dark Mars Software »

Anyone want to help me out?
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post 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.
Dark Mars Software
User
User
Posts: 68
Joined: Sat Jun 19, 2004 3:34 am
Location: USA
Contact:

Post 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.

Code: Select all

fixed with code posted by Dare2
Any ideas?
Last edited by Dark Mars Software on Sun Feb 12, 2006 11:24 pm, edited 1 time in total.
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Without testing anything, just hazarding a guess. This line

Code: Select all

While ~ KeyboardPushed(#PB_Key_P)
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!
@}--`--,-- A rose by any other name ..
Dark Mars Software
User
User
Posts: 68
Joined: Sat Jun 19, 2004 3:34 am
Location: USA
Contact:

Post 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. :lol: As for 4.0, i will be using it once its stable enough.
Dark Mars Software
User
User
Posts: 68
Joined: Sat Jun 19, 2004 3:34 am
Location: USA
Contact:

Post 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.
Last edited by Dark Mars Software on Sat Feb 18, 2006 4:20 am, edited 1 time in total.
Dark Mars Software
User
User
Posts: 68
Joined: Sat Jun 19, 2004 3:34 am
Location: USA
Contact:

Post by Dark Mars Software »

No one has an answer to my problem?
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post 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!!
Dark Mars Software
User
User
Posts: 68
Joined: Sat Jun 19, 2004 3:34 am
Location: USA
Contact:

Post 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.
Dark Mars Software
User
User
Posts: 68
Joined: Sat Jun 19, 2004 3:34 am
Location: USA
Contact:

Post 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.
Dark Mars Software
User
User
Posts: 68
Joined: Sat Jun 19, 2004 3:34 am
Location: USA
Contact:

Post by Dark Mars Software »

Update:I rechecked the code and it looks fine. I guess this is a PB 4.0 Beta 2 bug.
Post Reply