Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

woot pixel movment works!

Sign in to follow this  


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.


Sign in to follow this  

1 Comment

Recommended 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 ;)

Share this comment

Link to comment

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
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!