Sign in to follow this  
drharv

A couple of basic 2d tile questions

Recommended Posts

I have programmed business software for a while and have decided to try making a game. I get stuck a lot because I worry that I may not be doing something the "best" way. After searching, I am still stumped on the best way to solve the following 2 problems.

1) I have a randomly generated map. After the map is generated, I generate 2 arrays to keep track of spots where sides and corners should blend from 1 tile to another. While painting, I paint the background and then paint any transitions. The arrays store an offset to determine which transition to paint.

[img]http://i.imgur.com/MjKze.png[/img]

This works, but I hit a problem when transitioning and collision detection. You can see here that my guy is "floating" in sand because the actual tile at that location is water.

[img]http://i.imgur.com/kBTyD.png[/img]

My only thought is to add padding to the collision detection when I am in a tile that has transitions. Is there some better way of handling the collision or even an easier way to handle the rounding/corners that I am missing?

2) Collision detection and paint depth on objects bigger than a single tile. I have trees that are 2 tiles high, and I'm sure I will have wider objects in the future. What is the best way to handle the paint depth and collision detection? Should I break it up into multiple tiles and only have part of them paint above the player paint depth and only part of them block in collision detection? This seems like the most straight forward answer, but it seems like a mess in the texture sheet. Right now I am using the second tree in the image shown here, but I am having a problem with painting above the player when he is behind the tree and below the player when he is in front of it.

[img]http://i.imgur.com/on62P.png[/img]


I think I could solve both of these problems, but I don't want a bad solution that creates messy code to come back and haunt me later. Any suggestions or insight would be very helpful. I am really new to all of these concepts.

Thanks!

P.S. These graphics are just temp stuff that I found online. Not trying to steal anyone's work, just need something while learning to code. Edited by drharv

Share this post


Link to post
Share on other sites
[indent=1]I am new here too as you,but I have something in my mind.What I think,maybe not good,is that you can have a array to store the data or information of the title,for example, 1 for sand and 2 for water.Then when your guy stand on the title which value is 1,it floats on the sand and in the other hand ,it pushes into the water.[/indent]
[indent=1]Then,besides that,we also have another data that stands for depth(we can use the high four bits of a byte for it and the low onse for sand or water).The depth of the titles that are more far away from screen is greater,And also your guy constains the depth information too.Well,When we render the screen,we draw the background first,then we draw the titles by the order(if you can understand ,my english is not natural language^_^).In my mind,you can treast your guy as a title,and store these titles within a container,it will be easier.I belive it should not be a best way and I will think again.Extually,what i am most intreasted in is you generated map.I want to you can give some help as you said to learning code,and my appreciates will come after your reply.[/indent]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this