Understanding Bresenham's Algorithm

Started by
13 comments, last by Brian Jones 22 years ago
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.
--Muzlack
Advertisement
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.
Yeah, why not!
I know that I don't know nothing... Operation Ivy
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
--Muzlack
I understand this way, but what is DeltaT?
--Muzlack

This topic is closed to new replies.

Advertisement