Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Smooth movement w/ tilemap?

Author
Message
Mucky Muck Ninja
22
Years of Service
User Offline
Joined: 4th Sep 2003
Location: im not entirely sure
Posted: 7th Dec 2005 07:01 Edited at: 7th Dec 2005 07:01
Hi, in my game, you move smoothly, instead of jumping from tile to tile. Each tile is 50 pixels wide, so i have a bunch of code like this which tells me which tile he is in:


Then I use a variable from when I loaded the level which stores the kind of tile is at a position: TileType(x,y).
TileType 48 is ground that the char can walk on, so in my movement code I say this:


The problem is, the collision doesn't seem to work. Sometimes my char gets stopped, and sometimes he doesn't. A lot of the time he gets stopped where he shouldn't. I sorta feel like im going the wrong way about using tilemaps. Anyone wanna help me figure out either what I should be doing or how to make my code work with my tilemap setup?

Thanks in advance!

Im sick of Master Chief soo...ooga booga!!
Explain to me why some people pay money for 3d software? Its not 3d till its been blended. wwww.blender3d.org
Zergei
21
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 7th Dec 2005 13:04
Firstly...



if you by that you want to achieve in wich tile the player is, there is a better way of doing so, and it is using some what a formula...
such like this one i use on my tile set stuff --> tile_x=1+(player_x/50)

in that case if the player is between 0 and 49, it gives a 1, from 50 to 99, gives 2, and so on. Same goes for Y position. "Tile_x" is the tile in wich the player will be, "player_x" is the players x coordinate, "50" is because you said it was a 50x50 tile set. Mine is 40x40 and instead of a "50", goes a "40". The "1" is for that tile (0,0) will actually be tile (1,1), however, if you want it like (0,0), just remove the "1".

For now try this, try explaining a bit more about your collision problem. Mine works with a collision map. With this i mean, i have tiles and each tile has it's own collision tile, and so when i build the level on screen, i do the same, but with the collsion tile set, and in another bitmap (such as 1), and to check collision i use the point command, wich gives the color at a specific x,y position.
For know it is this way how i have it working, due to work on the kind of collision i want for the player, later on i won't be loading the collision map on a diferent bitmap, but in a memblock, so to speed up things.
Mucky Muck Ninja
22
Years of Service
User Offline
Joined: 4th Sep 2003
Location: im not entirely sure
Posted: 8th Dec 2005 00:25
Hey thanks that will clean my code up a bit! For the collision, right now i have two different tiles, which of course I will expand on later. But for now, I have tile # 48, and tile # 49. Tile 48 is open ground that the player can walk on. Tile 49 is a wall that stops the player. While I was loading the tiles, I stored the type of tile that is at each tile position into an array called tiletype. Then in my movement code, if for example I press up arrow, it checks to make sure that the tile one space above me is type 48, by subtracting 1 from the players Y tile pos. This doesn't really seem like the right way to do it to me, but the point is the collision doesnt' even work this way. Sometimes when the tile in front of my character is walkable( tile 48) i can't walk on it. So im asking either what system I should use, or how to fix my current system.

Thanks again!

Im sick of Master Chief soo...ooga booga!!
Explain to me why some people pay money for 3d software? Its not 3d till its been blended. wwww.blender3d.org
Zergei
21
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 8th Dec 2005 04:30
Could lend me your the code so to have a better look at it, and experiment with it....
Mucky Muck Ninja
22
Years of Service
User Offline
Joined: 4th Sep 2003
Location: im not entirely sure
Posted: 8th Dec 2005 06:14
Alright, im using media tho so you will have to replace those. Long code snippet here:



Thanks for your help!

Im sick of Master Chief soo...ooga booga!!
Explain to me why some people pay money for 3d software? Its not 3d till its been blended. wwww.blender3d.org
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 8th Dec 2005 09:36
Quote: "Alright, im using media tho so you will have to replace those. Long code snippet "


I counted about 87 different graphics... you want him to replace all that to help you?



Zergei
21
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 8th Dec 2005 16:56 Edited at: 8th Dec 2005 16:57
Yeah, it's har to replace 87 images, specially when one doesn't know what each one is for....

Btw, this DbC or DbPro?
Mucky Muck Ninja
22
Years of Service
User Offline
Joined: 4th Sep 2003
Location: im not entirely sure
Posted: 9th Dec 2005 05:35
Sorry, i didn't really mean for you to actually replace each one of them, they are frames of animation for the player, so they aren't really needed. I guess i sounded rather noobish there
Im using DBPro. I think instead im gonna have to rework my tile system, so dont' bother trying to fix it as it is now. Would you reccomend using a multi dimensional array that has a layer for the actual tiles that you see, a collision layer, and an effects layer? Or is there a better way to do this?

Your help is much appreciated

Im sick of Master Chief soo...ooga booga!!
Explain to me why some people pay money for 3d software? Its not 3d till its been blended. wwww.blender3d.org
Zergei
21
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 9th Dec 2005 14:32
Well, you could do that, and spend a life time to build each map (just joking...), or you could start by doing a tilemap builder, just as i did. Why?, well, it will help you understand some tile issueas and other stuff, plus you will have established your way of building your map, a way with which you feel confortable. I'll now explain what i did so far....

I started making this tile map builder of mine, so far it uses 3 tiles and the size of the map is fixed, but that will change later on. Basically, you just change each tile to the tile you want, and when done you save it in a .dat file, wich later on you will use in your games to load the maps tiles into a multidimensional array. Also, by pressing a key while building the map, you may see the how the collision map is being built. Remember, for each tile image, there is a collision tile to it. It's not that you do your map, an then have to do the collision map... they both build up together.

Hope this help a bit on something....

Login to post a reply

Server time is: 2026-07-07 06:43:38
Your offset time is: 2026-07-07 06:43:38