Advertisement

SDL surface noob question

Started by December 18, 2002 11:46 AM
1 comment, last by Strider81 21 years, 11 months ago
hello, i''m just starting to learn how to make games. I''m using SDL. let''s say i''m making a tile based game. for a tile object/structure would it be bad to have a surface object in every tile? ie. I have class tile{ private: SDL_Surface *tile; boolean walkable; } is this bad style? does declaring a surface take up a lot of memory? well if this question doesn''t make any sense, sorry but i''m still a super noob...thanks for any help
If that''s the the tile type, it''s fine.
But you don''t want to use that in an array, as a map.
like tile map[10][10];

Instead have the map store an index into the tile array.
like
tile tiletypes[20];
int map[10][10];

or something similar.
Advertisement
hope i understand you correctly, but if you are asking whether each tile should have its own SDL_Image, than yes, thats a bad idea. you should instead have each tile point to an SDL_Image - this way you save loads of memory (only one instance of an image in memory, instead of multiple copies for each tile that needs it)

hope this helps.

(editted for clarity and length)

- jeremiah

inlovewithGod.com

[edited by - keethrus on December 18, 2002 12:53:39 PM]

This topic is closed to new replies.

Advertisement