🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

woot pixel movment works!

Published January 02, 2006
Advertisement
Well, I have been wrestling with the code and looking at alot of source code trying to figure out how pixel movment works in a tile engine. Well I finally figured out how it really works.

First you check if the player has pressed the move button, then check the tile you want to move to weather you can go there or not, then you increment the tile X/Y position and THEN you add or subtract how many pixels the character is to an "OFFSET".

You use that offset later when you draw the character. When you draw the character you basicly start with the tile X and Y. Then you add the "offset" wich then as you move you subtract from wich makes the character look like its moving twards the tile. Anyways im really happy how this works. Thank you Joe Farell for writing such a great tutorial series here on gamedev.net without your source code I dont think I would have figured out how this works unless I asked the gamedev.net community.

Without further delay, heres a screen of the current state of the engine. I still need to add sprites for N S E W movment, but it looks very good so far :D.

DOWNLOAD

Next Entry been a while
0 likes 1 comments

Comments

........................................
I think its the best way to first add (newposition-oldposition)/100*animationstate and when animationstate is at 50 thats done move the coordinates and then sub with (oldposition-newposition)/100*animationstate.
well what I mean is wait until its at the line between the 2 tiles and then change from adding to subtracting.
This could help for example for collosion detection in a fight (if you would make it based on the coordinates without adding the pixels, it would allways calculate with the coordinates the character is moving to not the nearest ones)

btw: using my pseudo code for diagonal moves would make diagonal moves sqrt(2) times to fast in comparison to normal moves ;)
January 02, 2006 01:01 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement

Latest Entries

Jonk, Inc

5399 views

13 Years later

2817 views

shadowers

1150 views

screwing around

1138 views

minimalistic cpu

1275 views

been a while

1124 views

ridin on bumps

1527 views

ms3dness

955 views
Advertisement