Rate my first game anyone (DX8 Pong)?

Started by
18 comments, last by jrmiller84 18 years, 7 months ago
I'm not sure what is wrong then. I ran the game on my machine (2.2 ghz), my gf's machine (1.4 Ghz) and my work computer (2.5 Ghz) and it worked perfect on all three. I guess I don't completely understand the concept of the timer based on that article you sent. It seemed to me that it was saying to determine the frame time and use a value derived from that to slow the movement of the objects to compensate for the speed of faster computers. If anyone has any input or a better tutorial I'd like to look into timers some more since it seems to be such an important subject.
I will forever be a student.
Advertisement
Can't seem to use the resolution you built it in either... any chance of a 1024x768 version? Or the option for us to control it? :P
- Trust no one -
Oh good shot, forgot about that. I reuploaded a copy that is in 1024x768. Also, if you want to adjust the resolution, it is set in the first few lines of main.cpp. The new zip is at http://www.p0wn3d.net/DXP.zip
Thanks for pointing that out for me. My home computer has a pretty high res.
I will forever be a student.
Although I haven't downloaded the game (I am at work, heh), I'd like to follow up Slaru on the Timer discussion.

What you can do is calculate the time delta of each frame and multiply that by your movement.

Here's some psuedo code:

Update
{
timer->update();
game->update( timer->getDelta() );
game->render();
}

Game::update( float fFrameTime );
{
ball.pos.x += (xVel * fFrameTime);
ball.pos.y += (yVel * fFrameTime);
}

Hope this helps!
Hmm, that seems to be what I'm doing in my code. Maybe it's not, here's the code from within my game loop:

f_start = ftime();do {          CGame::Render();          f_end = ftime();} while(f_end==f_start);f_time = f_end - f_start;


Here is the ftime() method:

float CGame::ftime() {   return (float) timeGetTime()/20;}


Then in my render statement I do what you said and multiply each movement by f_time. It does indeed slow down the movement of all of the objects in the game but I guess I may be doing something wrong? I implemented the code from that article above so maybe Im not understanding something. I did note that in the ftime method of the article you are supposed to divide your clock by it's rate, well I tried doing it just using the timegettime and not dividing it by anything and of course it ran too fast, so I tried dividing it by 1000 since there are 1000 ms in a second and then it was way too slow so I had to narrow it down to 20 to get a decent speed. I guess that could be the problem? Im not sure. I'm at work too, heh, we shoud be fired, lol.
I will forever be a student.
Try it like this:

f_start = ftime();CGame::Render();f_time = ftime() - f_start;float CGame::ftime() {   return (float) timeGetTime()/1000;}


This should be good enough for now. You may have to change your velocity increments to a different value to speed up/slow down things but you should leave the division by 1000 or use the macro TICKS_PER_SECOND (don't quote me on the actual name). But what you get should be consistent on all machines (or close enough anyway).
I went ahead and tried that and it seems to make a little more sense to me now. I reuploaded the source for anyone who wants to look through it. I had to move the values up pretty high to get everything to move faster, but Im guess that should be fine as long as it's moving at a constant frame rate. Thanks for that revised code nomonkey, that helped quite a bit. Man this has gone on quite a bit, thanks for everyones help on this.

http://www.p0wn3d.net/DXP.zip

[Edited by - jrmiller84 on September 6, 2005 11:11:43 PM]
I will forever be a student.
Anyone had it work yet?
I will forever be a student.
No problem! Glad I could help you out.

I tested out the game and it worked great. You should look at getting a GDNet+ Subscription and putting it in the showcase. You'll get some constructive criticism on it as well as helpful ideas.

Keep up the good work.

Rate++
Thanks! I didnt even know there was a subscription service offered here. After reading it, it sounds like a good idea. I'll def. sign up once I get some extra $. Thanks for the review. Took me a while but I'm glad to put this one to rest and move on to the next project. I hope others find it helpful!
I will forever be a student.

This topic is closed to new replies.

Advertisement