Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


A couple of basic 2d tile questions


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 drharv   Members   -  Reputation: 105

Like
0Likes
Like

Posted 15 June 2012 - 08:23 AM

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.

Posted Image

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.

Posted Image

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.

Posted Image


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, 15 June 2012 - 08:25 AM.


Sponsor:

#2 BugShan   Members   -  Reputation: 115

Like
0Likes
Like

Posted 19 June 2012 - 07:47 AM

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.

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS