please help with SDL

Started by
7 comments, last by Jay Pascua 9 years ago
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
Advertisement
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.

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

You are missing the methods "clean" and "update" from the file SDLGameObject.cpp

YES! YOU ARE RIGHT SUNSHARIOR ! THANK YOU ! AND THANK YOU WOOH!

now I get this error, I don't understand what is going wrong, help

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.

C++: A Dialog | C++0x Features: Part1 (lambdas, auto, static_assert) , Part 2 (rvalue references) , Part 3 (decltype) | Write Games | Fix Your Timestep!

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.

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.

This topic is closed to new replies.

Advertisement