• Advertisement
Sign in to follow this  

2D Game Programming

This topic is 4685 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a 2D engine i've made, but for some reason, it freezes whenever i try to load a texture. I have 5 classes (so far): cGraphics cSprite cTexture cTextureSprite : cTexture cTextureAnimatedSprite : cTextureSprite I can send who ever wants to help my engine and they can see if they can et it to work. my contacts: AIM: o knuckles 666 o MSN: knuckles_666@msn.com yahoo: evilknuckles666

Share this post


Link to post
Share on other sites
Advertisement
I know this isn't exactly what you were asking for, but have you tried stepping through your code with the debugger to see what happens when you try to load a texture? In general, not many people are going to DL your engine to solve your problems (I learned that personally many years ago :) ), and if you haven't already, you definitely need to learn how to use a debugger. It only gets worse from here if you are going to develop an engine, game... . actually any software.

--Vic--

Share this post


Link to post
Share on other sites

Ensure you're using the right path when calling your texture filenames. If you're
launching your app from your Visual Studio debugger, then set the path within the IDE to properly pick up your resources..

Make sure there's no typos, etc.

Does the debug spew in the IDE reveal anything moments before the "freeze"??

Share this post


Link to post
Share on other sites
Depends on what IDE you are using. In Visual Studio 6, you start it by simply pressing F5.

If you are not using Visual Studio 6, tell us what you're using and I'm sure someone can help.

Matt Hughson

Share this post


Link to post
Share on other sites
Also I'd would like to know exactly what you mean by "it freezes". Is it an infinite loop kind of regular freeze or is it an access violation or other type of abrupt runtime termination? The nature of the error often tells a lot about where to look for it.

Share this post


Link to post
Share on other sites
i'm using .NET

it freezes completely.. nothing responds, i have to go to task manager to close out the program

Share this post


Link to post
Share on other sites
Check out the forum FAQ. There are code blocks you can use to cut and paste the offending code onto this forum. It will be difficult to solve your problem unless people can see what is going on.

Also, I'm not sure how much experience you have coding, but you should probably take some time to get familiar with your IDE before starting any kind of large project. Games really aren't the most stable things to debug through an IDE.

If you want to do 2d, then I would suggest looking into a library such as Allegro or SDL. They will make things much easier for you.

Share this post


Link to post
Share on other sites
i have lots of experience coding with C++ but not really that much in the .NET framework. i don't really want to spend time learning that, not really that important... and i'm not looking for the "easier" way to do things, i want to learn it all the way so i can use it on my own and use different things with it and whatnot.

actually, i just looked at my code again and after i initiate my sprite class, it freezes in the black fullscreen and i have to restart my computer.... it would really be easier for me to send someone my engine and them look at it, it's really big so i can't just take little bigs of it and put it here (not TOO big though to look at and understand)

Share this post


Link to post
Share on other sites
When I run into problems that force me to restart my computer I change the backbuffer width and height to about 500 and set the windowed to true in the presentation parameters. Then run the program and when the error comes up it stops the program and brings up the just in time debugger.

Share this post


Link to post
Share on other sites
If just in time debugging comes up then hit break (I believe that is the button). It will come up eventually with the line your program errored out at. If just in time debugging doesn't come up, then if you're using .net go to debug->start, or hit F5. I find the stack trace on the bottom right very useful.

Share this post


Link to post
Share on other sites
ok, i put it in windowed mode and it broke, these came up in the stack:

ntdll.dll!7c901230()
d3d9d.dll!010bd192()
d3d9d.dll!010dc91b()
d3d9d.dll!010e483b()
> Engine.exe!cGraphics::Display() Line 229 + 0x1a C++
Engine.exe!cApplication::Frame() Line 53 C++
Engine.exe!cApplication::Run() Line 35 C++
Engine.exe!WinMain(HINSTANCE__ * hInst=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00141f25, int nShowCmd=1) Line 20 + 0xb C++
Engine.exe!WinMainCRTStartup() Line 251 + 0x32 C
kernel32.dll!7c816d4f()

and the line it broke at was:

if (FAILED(m_pD3dDevice->Present(0, 0, 0, 0))) return Error("cGraphics::Display()");

what's all that mean???

Share this post


Link to post
Share on other sites
It basically means that cGraphics::Display() failed when called from cApplication::Frame(), which was called from ...

I'm assuming that Display() has your present call in it. Judging by the line it broke on, I'm assuming it was a null pointer. Wrap the statement up like this to see if that fixes the problem. Also, you probably shouldn't error out when Present fails. Present will fail if you alt-tab out of the application, so alt-tabbing right now will display an error.


if(m_pD3dDevice)
{
if (FAILED(m_pD3dDevice->Present(0, 0, 0, 0)))
return Error("cGraphics::Display()");
}

Share this post


Link to post
Share on other sites
heres the thing about that, here's that whole function

bool cGraphics::Display()
{
if (!m_pD3dDevice) return Error("cGraphics::Display()");
if (FAILED(m_pD3dDevice->Present(0, 0, 0, 0))) return Error("cGraphics::Display()");
return true;
}

it should return if the pointer was null... so i don't know what the problem is

Share this post


Link to post
Share on other sites
In these cases I just start commenting out portions of the code to see what broke. Start by commenting out portions of the code in the functions in the call stack. Alternativly can also try removing everything except the necessities. This means basically just do a call to clear, begin, end, then present and see if that works. Once that works start commenting pieces of the code back in. The important thing is to find what line caused it. Then you can usually determine how to fix it pretty easily.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement