Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / 2D timing issue

Author
Message
badkneecap
12
Years of Service
User Offline
Joined: 21st Jun 2010
Location:
Posted: 12th Apr 2011 23:20
I just started working with DBPro and I thought I would start with 2D. I decided to write a "breakout" game. Simple graphics, movement, etc. I found an old post that had a simple "framework" that developers could use when starting something new. What I liked about it was that it used a "movetimer". However, if I set the logic so that it is anything above 0, it runs really slow. If I comment out the "if then" statement that checks this value, it runs much faster. I would really like to be able to use this logic so I can increase the speed after each level.

Does anyone see the logic error?

Jimmy
19
Years of Service
User Offline
Joined: 20th Aug 2003
Location: Back in the USA
Posted: 13th Apr 2011 16:37
I don't think there's anything wrong with your timer code. The reason it's going slow might simply be because of your ball speed. What I would do, if I were you, is set movetimerset# to an unchanging value like 1000.0/60.0 (for 60 fps) then use another variable to store the current ball speed that you can increase as the game goes on.

NaGaFailMo.
badkneecap
12
Years of Service
User Offline
Joined: 21st Jun 2010
Location:
Posted: 18th Apr 2011 19:28
I tried chaning the frame rate to 60 fps, but then it ran really slow (as expected). I 2 variables for ball movement, moveX# and MoveY#. I keep their values under the number 1 so I can check integer values when there are collisions. When there is a collision, I check the difference in X and Y values and can determine if ball and brick collision (or paddle) is hitting on the top, bottom, left or right side of the sprite.

So, this brings up another problem. I'm having trouble determining a better collision between the ball and bricks. The ball is 20x20, and the bricks are 40x20. It is very common that the ball collides with 2 bricks at once, since the bricks are side by side, but in reality, the ball is only hitting 1 sprite. Is there a better way to determe if the ball sprite is hitting a specific brick by the rounded ball and not the 20x20 sprite size?

I attached the entire project if someone wants to jump in and offer some suggestions.

Attachments

Login to view attachments
badkneecap
12
Years of Service
User Offline
Joined: 21st Jun 2010
Location:
Posted: 18th Apr 2011 20:26
I was looking around the other 2D threads and came across some nice graphics to use for my game. They are all in 1 image (.png). How do I load this into my game and separate the individual images without having to create separate image files? Do I load as images or sprites?

Login to post a reply

Server time is: 2022-12-09 10:08:29
Your offset time is: 2022-12-09 10:08:29