• C++ Games Programming, Fixing A Few Things!

    RenaldoL25 Member

    So I’m developing a game called PongBreakout in c++ using a game engine i got from uni (when i was there..)
    I’ve got a few problems with my game that i’m struggling to fix and need some help to figure out how to do so.

    the first bug is that the countdown is far to fast and i dont know how to slow it down – ive been told to use a scalar (not a clue what that is..) <- ball.cpp (Update())
    the second bug is that the ball sometimes gets stuck at the side of the screen if the paddle is there (play it and you’ll eventually notice it.) <- ball.ccp (ProcessCollisons())
    the third bug is that the rand() function doesnt seem to be working for getting a value between 8 and 5. <- ball.cpp
    And lastly the cpu paddle is very buggy movement wise, is there anyway to make it move a bit better instead of always juttering.. <- enemyboard.cpp
    http://www.microsoft.com/en-us/download/details.aspx?id=23549

  • Abhey Member

    Bug #1
    Do not cast a double to an integer. If your goal is to use an integer, you must convert the frame time to the unit you want (microseconds, milliseconds, etc.) and then update your numbers to reflect this change.
    Bug #2
    When the ball hits the bottom/top of the paddle and the lower/upper bounds, it doesn’t give a score, it just tries to go the other direction. Since it’s processing the collision twice, it will get stuck. The ball can also get stuck on the paddle if it hits the top or bottom of the paddle. Since the x direction changes and if the paddle goes fast enough, it can cause a collision to be detected. One fix can be moving the region for scoring and hit detection.
    Bug #3
    That will give you the range if you don’t put max where min is suppose to be (ex. 8 + (rand() % (5 – 8 + 1)). You’ll have to explain what you actually want to accomplish if it doesn’t “work” for you.
    Bug #4
    I can think of a few things
    1. Predict where the ball will go. The problem with this is that the AI will never lose. To fix this, you’ll have to introduce difficulty and base the accuracy on that.
    2. Don’t move unless you have to. If the ball is slow, there will still be a jitter, but it wouldn’t be as bad. You can make it better by giving a range of when to move in the x direction.
    3. Make the ball faster than the paddle.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.
en_USEnglish