   Ba-Bounce! My first game [PONG clone]
  So I've got it to a point where it is pretty functional. I'm still going to improve on it but one thing I'm confused on is the processor usage. How can pong possibly use 80% of my Athlon 64 3200+? Is something funky in the code? I'd be very thankful to anyone who would look over my code and see if they could find anything. Or just have any other suggestions at all. Thanks everyone!-StephenTutorius.com has all the source code and the beta version of the game available on the front page (well, only page, sorry I just started on the site).[Edited by - Lempface on June 3, 2006 10:31:34 AM]
  I gues your program loop uses it. Sometimes I've been trying to solve that by putting little sleep, from one to ten milliseconds, to the end of each main loop iteration.   ;  I was already using a rest(10), I dunno, the game just looks really choppy and I'm missing out on why.   ;  Hi, congrats with making a game! Two problems:- it seems to need alleg42.dll and you provided it with alleg40.dll so it's not playable.[sad]- your linky needs fixing.   ;  Silly me, should be fixed now, both of them :)   ;  Nice work, I like it!A little comment on the code:You seem to be misusing header files.Header files:- templated function definitions- templated class definitions- functions declarations- inline function definitions- #defines- extern'ed variablesSource files:- the function's declared in the header file should be defined here- externed variables in the header should be declared hereBasically, you have this:// Draw.h#ifndef DRAW_H#define DRAW_Hvoid draw();#endif// Draw.cpp#include "Draw.h"void draw() {    ...}// main.cpp#include "Draw.h"int main() {    draw();}Basically for every header file that declares stuff you have a .cpp which defines it.The way you have it right now might (I think WILL) break if you included these headers from multiple places.Anyways, good work!   ;  1) I suggest you get rid of the rest() that is probably causing the choppiness.2) how often do you have the game check for mouse/keyboard input or attempt file access (of any kind).  How often do you output to the screen? All these things pass through the processor before they are executed.  Too much inefficiency in this would cause poor performance   ;Quote:Original post by medevilenemy1) I suggest you get rid of the rest() that is probably causing the choppiness.2) how often do you have the game check for mouse/keyboard input or attempt file access (of any kind).  How often do you output to the screen? All these things pass through the processor before they are executed.  Too much inefficiency in this would cause poor performanceSorry if I don't understand this fully but I am erasing, moving, and drawing once per loop while also polling for input once per loop. Is this inefficient? If so what would you suggest?   ;  I had a ball got stuck in a paddle, something with your collision code I guess. It wasn't choppy at all on my machine (amd64 3200). Just get rid of the rest, or change it to a rest(0) if you do want to save some cpu time. (Actually, the only good reason i can think of for this is that people with a laptop will save some energie).I like your title screen btw.   ;  Yea, I still need to implement collision for the side of the paddle so it won't get stuck in it. I should implement a timer I guess and remove the rest(10). Thanks for all the help and compliments.I didn't realize I was using headers wrong, I feel kinda bone headed now, although I just started toying with c/c++   