|
Post by OddChild on Jun 7, 2006 18:40:22 GMT -5
Which one of the attributes, is walk behind?
I mean on the mapmaker. I have been trying out the different attributes...
|
|
|
Post by Guilect on Jun 7, 2006 20:32:44 GMT -5
A tilemap is drawn onto the screen as one image. Typically you draw the tilemap to the screen and then your character. This would always put your character in front of everything on the map.
But you can be clever and set and detect attributes to achieve this and other effects.
The attributes are arbitrarily picked values that you assign to various tiles on your tilemap. You can then check the value of a map tile in your game and take whatever action you want. So if you want a map attribute that for you means walk-behind, then pick an attribute number, let's say 1. Then after constructing your map in the map editor, you assign the map attribute 1 to the tiles you want your character to walk behind. For example assume that every image of a sign post has its attribute set to 1 so that it is to look like the character walks behind it.
Now in the game your character is about to step onto a map location. You retrieve the location's attribute and see if it is 1. If it is you draw the map, the character, and now an image of the signpost lastly at the location. This handles special tiles on a case by case basis. This can be very powerful, but requires more work.
Another way, the way I would do it, would be to create another tilemap of just the items that you wish the character to walk-behind. In the game load in this map first. Then load in the background tilemap. Then draw to the screen the background tile map, the character, and lastly the walk-behind map. In this drawing order the character will walk on the background image but behind the walk-behind image. Various tilemaps can have different size tiles. (the overall map size should be the same if you plan on laying one over another). So you could have your background tilemap using 32x32 pixel tiles and your walk-behind tilemap using 128x128 tiles. In this way the walk-behind tilemap could have some really big trees for example that the character could walk behind.
|
|
|
Post by OddChild on Jun 8, 2006 14:25:12 GMT -5
Here is an example of what I am facing, by putting the lightpost as an image.. I imagine it would be the same if it was a tilemap. I want to make so that user cannot walkinto the base of the thing... so that it doesnt looklike he is behind, when he is actually in front... Also so that this does not happen. I will play more around with the attributes, and see what the best option is.
|
|
|
Post by Guilect on Jun 9, 2006 10:34:11 GMT -5
If you are putting the lightposts as images then you know their location and their width and height. You could check to see if the character is trying to walk on the base of the lightpost.
Another method to consider is to define a custom collision rectangle on the lightpost image down near the base. Then do a custom collision check (GetCollisionCustom) between the character and the lightpost.
|
|
|
Post by u9 on Jun 14, 2006 17:12:15 GMT -5
so that it doesnt looklike he is behind, when he is actually in front... I've been faced with a similar problem making a Dynoblaster clone. You could try to draw objects (man/light post/etc.) starting from the top of the screen (far back) and downward toward the bottom of the screen (near) so that anything that is closer is drawn last making them appear in front of other objects. This could be done by maintaining a list of all objects to be drawn sorted by their y coordinate ascending. When ever an object moves, you can check whether it should be swapped with it's neighboring object in the list (comparing the y coordinates). When drawing the objects you just go through the list one by one drawing them on screen Please note I haven't actually tried Brutus yet, so I don't know which possibilities there are with implementing this.
|
|
|
Post by OddChild on Jun 14, 2006 18:23:15 GMT -5
Okay, that totally confused me. I will try the idea, of putting an object at the bottom of the screen. That sounds easy enough. I guess you are saying to put the X,Y coordnates of certain areas as no walk zones. I am going to try that in a little bit. I haven't spoken much english today, so my mind is kinda warped.
|
|
|
Post by Guilect on Jun 14, 2006 20:14:23 GMT -5
Welcome u9. Thanks for the input. It was well described. Hope you try Brutus2D sometime. Would like your input and participation. oddchild: I did not realize that English might not be your primary language. You type it very well. But, while no walk zones is a way of doing what you want, what u9 was saying is a different method. I could not explain it any better. So maybe you can give u9's post another read sometime. Then decide what method you feel comfortable with going with. In programming there are almost always more than one way of achieving a result.
|
|
|
Post by OddChild on Jun 15, 2006 5:22:04 GMT -5
English is my first language, but when I am tired it is difficult to understand. I am from the states, but 11 out of 12 months or 10 out of 12 max, I am out of the states and in the middle east. When I speak or hear english over here, it is very broken.
If I have gone a day without english, without readinng, internet or anything it can be difficult for me to switch back into "english mode" of thought and reading.
One time, I lived in a villiage. After 6 months my parents called. I must have sounded very out of it. My thoughts were in arabic, and i was speaking english so the result was very broken english.... it is a wierd thing.
|
|
|
Post by u9 on Jun 15, 2006 10:51:19 GMT -5
I was only thinking about the visual effect. So my idea only avoids the light post being in front of the man when it is suppose to be drawn behind. I'll write more later. Working right now
|
|
|
Post by u9 on Jun 15, 2006 17:03:31 GMT -5
Welcome u9. Thanks for the input. It was well described. Hope you try Brutus2D sometime. Would like your input and participation. Thank you. I'll have a look at it OddChild: If the man is lower on the screen then the light post, he should be drawn after drawing the light post, right? If he is lower on the screen, means that he has a higher y-position than the light post's y-position (the y-axis of the screen points downward). So objects should be drawn lowest y-pos first and upward so that the object with highest y-position is drawn last. (Highest meaning highest value, not high up on the screen ). Of course you could always post some code; it might help to see what you are doing.
|
|
|
Post by u9 on Jun 16, 2006 11:54:47 GMT -5
www.wirednerd.com/development/brutus2d/occlusion_demo.zipEDIT: Updated link. Here's a quick example I made of my description. It's my first program so excuse the class definition. It's a bit confusing I think. Anyways, use the arrows to control one of the players, and notice when he gets drawn in front and when he is drawn behind the other player. I also did a simple collision detection around the two players feet so they cannot walk over each other. Check how this is done in the main loop.
|
|
|
Post by Guilect on Jun 16, 2006 12:56:17 GMT -5
Nicely demonstrated. The class is a fine example of member variables and methods. Let me summarize the technique you used here: - A point is defined on each character. (the hotspot)
- Then the distance is calculated between these two points.
- If the points are close enough then the character can not proceed in that direction. (the two characters are bumping into one another).
- Lastly, in the game loop, the vertical positions of each character is examined and the drawing order (who is in front of who) is determined.
Thanks for this example. I and fellow Brutus2D users are looking forward to more sharing of ideas and examples.
|
|
|
Post by OddChild on Jun 16, 2006 18:22:18 GMT -5
Thanks a ton for the example! That helps a lot!!!
|
|
|
Post by OddChild on Jun 17, 2006 10:11:53 GMT -5
I am still picking through it, to try and understand it all. . . Generally I have been avoiding public and private classes...
|
|
|
Post by u9 on Jun 17, 2006 15:37:22 GMT -5
I am still picking through it, to try and understand it all. . . Generally I have been avoiding public and private classes... Yeah, sorry about that. I find it much easier to use objects. For example it becomes very simple to add another player just by saying p3 = new Player But try not to think about the classes. It's just when I move the player forward I can write myPlayer.forward(). Normally that would be done calling some sort of procedure like forward( myPlayer ). You should be able to understand what I am doing just by looking at the main procedure (Sub). There are two things to notice: - Figure out which player is in front of which. This is done by checking the y value of the player. Draw the one that is behind first.
- Make sure the players cannot walk over each other. This is done by calculating the distance between the two, and if the player that has just moved has come too close to the other one, then move him backward again. I call myPlayer.back(), but in procedural languages you would have a procedure to do this like so: backward( myPlayer )
Please note also, it was my first program, so I wanted to try out the different things, especially the classes and public and private members/properties, functions etc. Don't focus too much on that poor class. Anyways, as I said before, I would love to see some code. It is fun to see how others are doing, and how others are solving problems Any help I might be able to give could be related to how you are writing.
|
|