Archived

This topic is now archived and is closed to further replies.

Koobazaur

Just finished a PONG game and so I have some GDI Quiestions...

Recommended Posts

Koobazaur    1264
OK, first of all this isn''t another whine thread asking for help with my game as I finished it and it works OK! Well first I''ll describe to you how it works (instead of pasting a code which has almost none info): There are 2 main classes: ball and pad; and 3 main objects: 1 ball and 2 pads (one controlled by the program, the other by the user, using a mouse). EAch one has 2 important functions: Display - displays the object(ball using Ellipse and pads using Rectengle). Erase - works just like display but it uses white brushes (so it seems that the object is erased). So basically it works like this: Ball.erase(hwnd); Ball.move(); Ball.display(hwnd); simple, no? Also I use timeGeTime() to calculate elapsed time to move the ball and pad (with each bounce off a pad this time is shortened and so the ball moves faster)... Now first thing I''ve noticed is that sometimes I can see white lines going through my objects or when the ball is next to pad, you can see that a bit of the pad get erased after that; I can see these things for a short time (1/10 of a second?) which leads me to a conclusion that the program doesn''t display the objects fast enough... Is it because my code is too big? Or is it the GDI? after all instead of refreshing the whole window I ONLY erase the objects! Second thing is about full screen... this is the code I use for it:
void FullScreen(int width,int height)
{
		DEVMODE devmode = {0};

		devmode.dmSize = sizeof(DEVMODE);
		devmode.dmPelsWidth	= width;
		devmode.dmPelsHeight = height;
		devmode.dmBitsPerPel = 16; // Bits per pixel

		devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;

		if(ChangeDisplaySettings(&devmode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
		{
			// Display the error message and quit the program

			MessageBox(NULL, "Display Mode Not Compatible", "Error", MB_OK);
			PostQuitMessage(0);
		}

}
When I go full screen, the sides of my screen are bent like this:
______
\..../
|....|
/____\
 
You get the point... is it the fullscreen mode I am using? or a stupid monitor? Last question well... how bad is 600 lines of code for a simple PONG game???

Share this post


Link to post
Share on other sites
Wildfire    154
Your monitor. It has not been properly set up for the resulution/refresh rate you''re using.

Good monitors offer a ton of buttons (or an OSD) that allows you to compensate most of it... check your monitor''s manual.

Share this post


Link to post
Share on other sites
Chacha    138
quote:
Original post by Koobazaur
Last question well... how bad is 600 lines of code for a simple PONG game???


The number of lines doesn''t matter, it''s the quality of the code that counts.


------------------------------------

If the universe is just a simulation in some unbelievably advanced computer, then God is one heck of a programmer!

Share this post


Link to post
Share on other sites
Koobazaur    1264
And how do I know my code is good quality ...


Well one more thing I encountered when making this game;
At first instead of using the global whute brushes for erasing, I made the erase functions create a white brush and pen, select them, erase the pad/ball, select the old (global) brushes again and then delete the white brush... after playing for a while my erase function would STOP working and the brush the program uses to fill the pads/ball would be white. After closing the program my compiler would give me this message: GDI failure...

I fixed it by making global white brush and pen... but why did it happen in first place? Can''t the program handle creating/deleting brushes and pens over and over (when I tried to print screen this I got windows error saying it doesn''t have enough memory!) ?



Also as I mentioned before, sometimes I''ll see white lines go through my pad/ball which means that the whole erase/display thing isn''t working quite properly (is it too slow?) ... any idea what could be causing this?

Share this post


Link to post
Share on other sites
smart_idiot    1298
You probably forgot to free something you got while erasing, and every time you went to erase something it kept creating more and more until it ran out of memory.

Or if you didn''t forget, maybe you assigned it to something else before you freed it, and you freed the wrong one.

Share this post


Link to post
Share on other sites