Jump to content
  • Advertisement
Sign in to follow this  
gamesneverdie

Tilesheets and SDL

This topic is 2601 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'm having some problems with lazyfoo's tutorial again :/
Right now I'm at the Tiling tutorial and again the sample code from there works fine (tutorial 29).
But my code is not in just one, but more source files (as shown here).
These are the errors I get:
711053169errors.png
I guess, I forgot to include something, but I have no clue what it could be.

Thanks in advance for any answers :)

Share this post


Link to post
Share on other sites
Advertisement
In future, please post errors as text. This makes it easier to copy the errors or quote them.

This isn't an "Alternative Games Libraries" issue, its a basic C++ language problem.

The problem is that on classes.h on line 20 the compiler cannot see a declaration of "Tile". This isn't necessarily caused by not including something, it can be caused by the order of includes. Read this, it contains all the information you need to fix this problem.

Share this post


Link to post
Share on other sites
Looking at the error messages you are using Tile in your code in classes.h without declaring it before. The other error is that you send arguments of the wrong type to Man::move.

Share this post


Link to post
Share on other sites
Hidden

I'm having some problems with lazyfoo's tutorial again :/
Right now I'm at the Tiling tutorial and again the sample code from there works fine (tutorial 29).
But my code is not in just one, but more source files (as shown here).
These are the errors I get:
711053169errors.png
I guess, I forgot to include something, but I have no clue what it could be.

Thanks in advance for any answers :)


Since you've modified the code you could you post your code either enclosed source tags or attached as a zip. Otherwise we can only guess what the problem might be.

Share this post


Link to post
The second error is likely caused by the first, the compiler is using the "default int" fallback while compiling the Man class declaration. Later on the Tile class is declared and then the compiler is confused when a Tile is being passed to what it decided was an int.

Share this post


Link to post
Share on other sites
The only place I defined "Tile" was in main, but lazyfoo's tutorial does the same.
So far I have "Tile *tiles[TOTAL_TILES];" in main, but I dont know what to do. I've read the article you linked, rip-off, but I still don't know what to do.

If I change the including orders (functions.h before classes.h) I get these errors:
Compiling: game1.cpp
In file included from C:\game1\game1.cpp:9:
C:\game1\functions.h:33: error: 'Tile' was not declared in this scope
C:\game1\functions.h:33: error: 'tiles' was not declared in this scope
C:\game1\functions.h:33: error: expected primary-expression before ']' token
C:\game1\functions.h:35: error: 'Tile' has not been declared
In file included from C:\game1\game1.cpp:11:
C:\game1\classes.h:20: error: 'Tile' has not been declared
C:\game1\game1.cpp: In function 'int SDL_main(int, char**)':
C:\game1\game1.cpp:60: error: 'set_tiles' cannot be used as a function
C:\game1\game1.cpp:86: error: no matching function for call to 'Man::move(int, Tile* [192])'
C:\\game1\classes.h:20: note: candidates are: void Man::move(Uint32, int**)
Process terminated with status 1 (0 minutes, 8 seconds)
7 errors, 0 warnings[/quote]
If I include classes.h before functions.h I get the same errors as above.

Share this post


Link to post
Share on other sites
Consider splitting your program into more files. Instead of monolithic "classes.h" and "functions.h", separate into additional files such as "tile.h" and "man.h", with the associated source files.

Share this post


Link to post
Share on other sites
That would still not fix this error.
What I have now is this:
function prototype in class Man: void move(Uint32 deltaTicks, Tile *tiles[]);
To my understanding a function expects input of some sort like int etc. In this case one "Uint32" and one "Tile". My guess would be that "Tile" is defined in one of the SDL libraries, because when everything is in one file it works.
The only other declaration of "Tile" is in my main function, where I use the class to create every Tile-object with "Tile *tiles[TOTAL_TILES];"

Share this post


Link to post
Share on other sites
Tile is not a SDL type, SDL prefixes its types with "SDL_". Go back to the Lazy Foo tutorials, they probably introduced the Tile type.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!