A few general game questions about tiles and text

Started by
0 comments, last by SunDog 17 years, 1 month ago
I've created my own 2d engine. It's important that you know that, because I don't want someone to recommend me to use another game engine. The main reason I made this engine was for my own use. However, I plan on releasing it for others to use as well. Right now, I've got sprites, sounds, objects, and fonts taken care of. However, I am used to having a built in handler for tiles, so I really don't know what to do with them. I want to know what the general take on tiles is. I figure I'll just use an array to store the tiles, but how often should I recreate the background? I think recreating the background every step would be pointless. I figure it would be more beneficial to create a surface a few times larger than the viewing area and just recreate it whenever needed be. Is that the general way this is done? I'm also wondering the same with drawing text. For me this isn't such a big issue, but since I want to make this a general purpose engine I think there is a problem. I need to know how often I should create the surface for text and how I should handle that. I want to make it so I can just call a function and it will render the text you pass to it to the screen. But you have to create a surface to render to the screen first. So, I'm really not sure how this could be done. For me, I could just create the surfaces and draw them myself but thats a little more involved than a simple function. Is it going to be very slow to create a surface to draw to the screen every time the function is called? I guess I really shouldn't worry that much about it, but I just wanted to know.
Advertisement
OK I'm not sure I quite understand your problem, but it sounds like you could benefit tremendously from the MVC paradigm (Model/View/Controller). http://en.wikipedia.org/wiki/Model-view-controller#Java_MVC_Frameworks

It sounds like your class would be 'View' class, so it shouldn't decide when it should be repainted, the controller (applcation) is the one that does that. Of course language patterns are not everything, and you may need to bend paradigms a little bit, (for example if you have a container class then the container class tells all its children to be repainted when it gets a repaint message), but try to follow that paradigm as much as possible and you can really save yourself alot of trouble.

This topic is closed to new replies.

Advertisement