Sign in to follow this  
khofez

please help with SDL

Recommended Posts

i'm reading SDL Game Development, I make all the stuff on the same way that book does, but, I have some errors and the book not say anything. I'm on page 76.I put some images here showing what happens , please someone takes a look and say to me why it happens

Share this post


Link to post
Share on other sites
Make sure you don't have any circular include dependencies.

SDLGameObject.h includes Game.h, so if Game.h includes Player.h (or Enemy.h) it will fail to work because Player.h need SDLGameObject but it has not yet been defined and the #pragma once prevents SDLGameObject.h from being included again. Edited by Wooh

Share this post


Link to post
Share on other sites

Ok now I include Game.h in the SDLGameObject.CPP, not in the header file, and I removed the SDLGameObject.h and GameObject.h from Game.h, because the Player and

the Enemy include SDLGameObject.h that include GameObject.h. Ok , so now i get this error

Edited by khofez

Share this post


Link to post
Share on other sites

You're trying to access an object which is stored at location 0x00000000 which probably means the you're accessing a null pointer somewhere, somehow. It looks like your Vector2D was never assigned a valid pointer and when you try to call setX the member function believes the object is located at 0x00000000 and m_x is offset 0 bytes from that location.

 

This is a good opportunity to learn how to use your debugger. You can see which function called which function and so on and in those functions you can see what the variables visible in that function are set to. You can step through code to line by line to see where things go wrong as well.

Share this post


Link to post
Share on other sites
Please note that text is the preferred communication mechanism between programmers. You can include or link to images to aid understanding, but usually just copying and pasting the error message(s) and any offending code as text is a better approach.

The problem with images is that even if I can see code it in, I cannot easily edit / compile / run. I would have to type it out again. Likewise, with error messages, I cannot easily throw them into Google, I would have to re-type them.

Generally, I'd recommend not including images unless you're having difficulty explaining the issue without it.

Share this post


Link to post
Share on other sites

Not sure how to say this without sounding like a douchebag, but you should really try to learn what the error messages mean. Try to google them.

How do I know you'll find all the answers to everything you will need for that book? That was literally the first book I read when I started in January. In that book, there are typos, as well as the author gradually (im assuming intentionally) leaves things out, and lets you figure out what's missing. Like I said I know it may sound like a douchebag move, but it'll help you a lot in the future.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this