Understanding Bresenham's Algorithm
I cannot have my character move one pixel at a time because at 800*600 resolution, it takes the character forever to walk across the screen! and if I speed up the whole game, it just doesn''t work right. The other sprites would go too fast because it''s sleeping less, and it would just be a big mess re organizing it.
Forget the sleeps. Locking framerate is a bad way to go. There''s a simple way to fix this though.
You''re currently moving v pixels per frame for a given unit. You sleep for t0 seconds each frame. Now, let''s fix this.
Don''t sleep at all. Instead, record the time since last frame deltaT. Then, change all your ... += v code to ... += (v/t0) * deltaT.
You''re currently moving v pixels per frame for a given unit. You sleep for t0 seconds each frame. Now, let''s fix this.
Don''t sleep at all. Instead, record the time since last frame deltaT. Then, change all your ... += v code to ... += (v/t0) * deltaT.
What if I were to do it this way: Lets say I did the line with xinc and yinc as 1. Then, I would find the point corresponding with the character on it. How would I achieve this?
Sponge Factory
--Muzlack
Sponge Factory
--Muzlack
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement