Non tiled-bases maps in 2D games.

Started by
5 comments, last by KurtCPP 18 years, 8 months ago
Hi everyone. 1.According to you, how a "complex" map can be managed in a game such Digger (remember the old stuff on Amstrad computers). I'm actually currently trying to make a Digger clone and I have no clue as how to manage the maps and neither as how to describe them in a file. I think making it tile-based is not the right solution cuz the main character can dig at any location without taking in account the emeralds' positions. I'd like a map rather looking like those in Liero etc. I thought I could repeat a big pattern to draw the map, but afterwards, shall I just draw the black parts onto the map or shall I save "digged" rectangles so the background is not drawn uselessly? 2. One more thing : if I want my sprites to go in any direction (up, right and so on) but I don't wanna use Paint to create each position for the four directions, I know I can perform the rotation by myself in the code, but do you think using matrices is the best way, even for a mere 2D game. I've tried to program something with sines and cosines but it doesn't work anymore. Goddamn!! Could someone shed light on this for me please? Tutorials URL's and code snippets will both be greatly appreciated! Thanks to all in advance for your help. [edit]: I've just seen a Sprite'n'Tiles forum had been added. It seems this has been added especially for me but I hope there's nothing wrong in leaving this post here, unless the moderator want to move it to another place. |-)
Prog, Games & Rock'n'Roll :I don't like the Prog but the Prog likes me.
Advertisement
For a game like Digger I wouldn't use a 'map' at all really. First blit things under the dirt, then blit black holes on the dirt, and then blit the entire dirt image over everything else. Wherever your character digs you can blit a black spot in the 'hole' image.

As for differnt types of maps in 2D I've used a map format like this before ...
------------------ begin file ------------------
grass 0 0
grass 64 0
tree 12 2
path 16 2
------------------ end file ------------------
Before this file is loaded, all the required images are loaded. I then use a list of some object which is the base type of map objects in my game. To draw the map I just simply check if the object is on the screen, then draw the image if it is.

For rotating images, most API's have this functionality built in (which API are you using?). If all you need to do is to rotate each sprite in 4 directions, I think it would save a lot of time just to draw it once in paint, and the rotate it with paint and have 4 different images. If you are planning to rotate images with your own algorithims, then I can't help you there :S.
Hi.
First thank for your help.
Regarding the API, I'm using DirectGraphics (DX8). I think all I have for rotations is matrices. I've already thought of rotating the picture directly in Paint but this didn't really please me. But I may be wrong?

Regarding the remainder of your answer, I don't really think I got it all :
what do you call 'things under the dirt'? Are you talking about the characters and items? My question even seems stupid to me but if I draw the holes and other stuff before drawing the entire image of the dirt, will I really see something else than dirt? Or rather, when you say 'over everything else' you mean I'd need to slice the dirt picture into parts that would only cover the places I want?

I have the impression you're saying that I should use two big pictures, one keeping the same with the whole dirt representation and the second always getting blacker and blacker as the dirt is being digged. Is this what you mean or should I really give up programming? lol

Last thing, I suppose the numbers in your file format are not screen coordinates but then what??

Thanks in advance.
Prog, Games & Rock'n'Roll :I don't like the Prog but the Prog likes me.
I am not very familiar with DX, first are you using projection or an orthographic view? For Digger an orthographic view would be much eaiser to manage. For rotation in OpenGL for example you could rotate something 90 degrees with one command, is this not the case with DX? Do you have to perform matrix operations yourself?

Quote:
I have the impression you're saying that I should use two big pictures, one keeping the same with the whole dirt representation and the second always getting blacker and blacker as the dirt is being digged. Is this what you mean or should I really give up programming? lol


This is what I mean yes. It may not be the best way, but I think it's the easiest. However this may not be the best way in DX, I'm not sure how easy it is to draw images on top of other images with color key masking.

Actually now that I think about it, you don't need two large images. The dirt could be one large image, and the black spots could be drawn as transparent (or masked). So when your character digs away you put a sqaure of which ever your mask color is (usally RGB(255, 0, 255)). All the items would be drawn first, then the dirt. If the dirt has been dug away everything else underneath would be seen.

Quote:
Last thing, I suppose the numbers in your file format are not screen coordinates but then what??


They are meant to be screen coordinates, they just don't make a lot of sense in the example.
Hi again, AsOne.

Regarding the rotation, I've started working on it. I suppose I'm simply using a orthographic view ; I don't really see what it is but I just know I haven't done anything complicated for the graphics up to now.
Apart from this, with DirectGraphics, you have to call functions to retrieve the appropriate transformation matrices and I'm currently looking for the best way to perform the multiplication between the vertices coordinates and the matrix. Thus, there's no function to directly rotate a sprite of 90 degrees.
If someone could help me a bit about how I should better do...

Regarding the way you advise me to draw the dirt and the other items, I just didn't know I could do like this but I'm gonna have a look at it.

Thanks for your help.
Prog, Games & Rock'n'Roll :I don't like the Prog but the Prog likes me.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/html/pocketbots.asp

There's an article that describes doing something with terrain similar to what you want to do. It involves setting portions of the terrain texture to be transparent.
Hi!
Got it, I'll check this too.
Thanks for your advice!
Prog, Games & Rock'n'Roll :I don't like the Prog but the Prog likes me.

This topic is closed to new replies.

Advertisement