I am a dumbass

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
Stupidnoob
Posts: 5
Joined: May 1st, 2012, 3:12 pm

I am a dumbass

Post by Stupidnoob » May 1st, 2012, 3:25 pm

Ok, I don't understand what the hell went wrong. I got past the installation (Chili's directX Framework ran fine when I installed, etc)

I typed some code into Notepad upon seeing Chili's tutorial (part 4). It goes as follows:

Code: Select all

void Game::ComposeFrame()
{
int x;
int y;
int x2;
int y2;
x = 400;
y = 300;

if( kbd.RightIsPressed() )
{
x2 = x + 100;
}

if( kbd.LeftIsPressed() )
{
x2 = x - 100;
}

if( kbd.UpIsPressed() )
{
y2 = y + 100;
}

if( kbd.DownIsPressed() )
{
y2 = y - 100;
}
gfx.PutPixel( x2, y2, 233, 233, 233);
}
So uhh I went ahead and copypasta'd it into C++. Saved, built, debugged. Upon running it I was met by this friendly error:
Unhandled exception at 0x013313d4 in Chili DirectX Framework.exe: 0xC0000005: Access violation writing location 0xb89f23f0.
And now the program refuses to run. I broke, exited and restarted C++, replaced my pertinent code with:

Code: Select all

void Game::ComposeFrame()
{
int x;
int y;
x = 300;
y = 300;
gfx.PutPixel( x, y, 233, 233, 233);
}
Friendly error (above) pops up again. I'm like wtf, I must have broke Chili's framework somehow. So I exited entirely, re-extracted to a new folder and attempted this code in the new folder:

Code: Select all

void Game::ComposeFrame()
{
int x;
int y;
x = 300;
y = 300;
gfx.PutPixel( x, y, 233, 233, 233);
}
again and now it works. I have no clue how I broke Chili's framework with my first code block, what did I do wrong? Every time the error shows up it directs me to this section:

Code: Select all

 MSG msg;
    ZeroMemory( &msg,sizeof( msg ) );
    while( msg.message != WM_QUIT )
    {
        if( PeekMessage( &msg,NULL,0,0,PM_REMOVE ) )
        {
            TranslateMessage( &msg );
            DispatchMessage( &msg );
        }
        else
		{
			theGame.Go();
		}
    }

    UnregisterClass( L"Chili DirectX Framework Window",wc.hInstance );
    return 0;
of Windows.cpp. Help?

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: I am a dumbass

Post by chili » May 1st, 2012, 3:38 pm

That is strange for a number of reasons. First, I don't see anthing wrong with your code there.

Read the thread 'READ THIS FIRST' and then post your solution folder (the one that is all fubar'd). I will take a look at it and see of I can't reproduce your problem on my system.
Chili

Stupidnoob
Posts: 5
Joined: May 1st, 2012, 3:12 pm

Re: I am a dumbass

Post by Stupidnoob » May 1st, 2012, 4:12 pm

Uhh here it is. There weren't any 'debug' folders to delete so I only deleted the two 'release' ones and the 'ipch' one. And the sdf file.
Attachments
Chili DirectX Framework.zip
(34.24 KiB) Downloaded 189 times

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: I am a dumbass

Post by chili » May 1st, 2012, 4:49 pm

Got your problem bro. Funny how I didn't notice it until I ran the progam. ;)
Think about it this way, if none of the keys are being pressed, what values will x2 and y2 take on? Answer that question and you will have your answer as to why your program is imploding. :)
Chili

Stupidnoob
Posts: 5
Joined: May 1st, 2012, 3:12 pm

Re: I am a dumbass

Post by Stupidnoob » May 1st, 2012, 5:15 pm

I thought about that, but after I replaced the code with the non-implodey bit, namely this:

void Game::ComposeFrame()
{
int x;
int y;
x = 300;
y = 300;
gfx.PutPixel( x, y, 233, 233, 233);
}

it still wouldn't work. I had to re-extract the file and re-code again entirely. So the implosion did not simply stop a build/debug attempt, it also permanently messed up something within the framework. Which it shouldn't. Basically, I don't understand why the error persists even after the offending code is obliterated.

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: I am a dumbass

Post by LuX » May 1st, 2012, 5:25 pm

Didn't see your new post.
But gotta say you have a weird problem going on.
ʕ •ᴥ•ʔ

Stupidnoob
Posts: 5
Joined: May 1st, 2012, 3:12 pm

Re: I am a dumbass

Post by Stupidnoob » May 1st, 2012, 5:32 pm

LuX, I get that part. The problem is that when I replace the entire bunch of code (read: I delete x2 and y2 entirely) and rebuild using this instead

void Game::ComposeFrame()
{
int x;
int y;
x = 300;
y = 300;
gfx.PutPixel( x, y, 233, 233, 233);
}

The same error pops up. It persists even after quitting and restarting C++. HOWEVER, upon using a NEW copy of the chili framework (extract to different folder, yada yada yada) the above code works (of course, the initial asplodey one with x2 and y2 still kills the entire framework's ability to function if I put it in again afterward).

I've done minor coding and phailed at it before but I know for sure that if you delete an offending line of code, both it and its effects and accompanying bugs are gone forever on the next build/debug. No idea why this error stays even after the lines have been removed.
Last edited by Stupidnoob on May 1st, 2012, 5:37 pm, edited 1 time in total.

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: I am a dumbass

Post by LuX » May 1st, 2012, 5:35 pm

Hmm... Did you make copies of the original folder?
If you read my post "Annoying bug?" I had some weird shit going on with copied folders of a project.
ʕ •ᴥ•ʔ

Stupidnoob
Posts: 5
Joined: May 1st, 2012, 3:12 pm

Re: I am a dumbass

Post by Stupidnoob » May 1st, 2012, 5:37 pm

Nope, didn't copy. It was the original folder.

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: I am a dumbass

Post by chili » May 2nd, 2012, 12:34 am

I haven't been able to reproduce your error (after the substitution). The only thing I can think of is that the editor isn't recognizing that you have changed the code and so it isn't rebuilding the project. One solution for that is to save the source file after you have edited it and then manually delete the release and debug folders so that it is forced to do a rebuild. Even though your program brings you to windows.cpp when it fails, the problem lies in game.cpp. If you set the configuration to Debug and then run it again you will see what I mean.
Chili

Post Reply