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.

Author
Message
Eponick
23
Years of Service
User Offline
Joined: 18th Mar 2003
Location:
Posted: 15th May 2003 17:51
Im making an rpg and ive already done the engine, map editor with saving/loading/collision, and working on npcs. But my problem is with moving. See, when the player moves it moves by 32 pixels in whatever direction. As you could see that would mean jumping all over the screen. I was wondering if theres an easy way to make it move slower by scrolling from tile to tile. Ive put in the source for direction controlls if you need it.
Sephnroth
23
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 15th May 2003 18:33
at last, an area i know and can help with
you seem to be litrally putting the player into the tile map? I only ever did that once, and that was for an over and under engine where i had to take care of the z-ordering myself..
usually, your player would hover above the map as a seperate thing and you would simply calculate anything to do with it using its tile co-ordinates (tilex = (player_pixel_cord_x / tile_width) + scroll_offset_x : tiley = (player_pixel_cord_y / tile_width) + scroll_offset_y) - but i wont question you you obviously know what your doing.
To smoothly move your player across like that you need a player offset. If the player litrally jumps from tile to tile i presume you are drawing it using the calculation x = player_tile_x * tile_width? (take into account any scroll of course) keeping that in mind.. you want something like this:



Then, when you go to draw your players sprite, draw it using these calculations for the x/y co-ordinate:
(just replace tile_x/tile_y with the players x and y tile co-ordinate)
X = (tile_x * tile_width) + pox
Y = (tile_y * tile_height) + poy

of course if you have a scrolling map add the scroll offset into the calculation too..

X = ((Tile_X + ScrollXOffset) * Tile_Width) + Pox
Y = ((Tile_Y + ScrollYOffset) * Tile_Height) + Poy

There.. that should do it.. just play with it and feel free to ask any questions you dont understand. I apologise for any silly mistakes i might of made, its quite possiable, i had NO sleep last night and im quite the zombie atm :-s

Eponick
23
Years of Service
User Offline
Joined: 18th Mar 2003
Location:
Posted: 15th May 2003 21:20
Thanks, but because i have a strange wya of programming that didnt work very well. So I had to do it like this:


Thanks again

Login to post a reply

Server time is: 2026-07-11 07:06:00
Your offset time is: 2026-07-11 07:06:00