Jump to content
Posted 23 September 2012 - 05:24 AM
Posted 23 September 2012 - 05:33 AM
Edited by wqking, 23 September 2012 - 05:37 AM.
cpgf library -- free C++ open source library for reflection, serialization, script binding, callbacks, and meta data for OpenGL Box2D, SFML and Irrlicht.
v1.5.5 was released. Now supports tween and timeline for ease animation.
Posted 23 September 2012 - 05:56 AM
Edited by Brother Bob, 23 September 2012 - 05:58 AM.
Posted 23 September 2012 - 08:00 AM
Look at the picture you posted and count the pixels, and think of how moving one of the points one or two steps to the left or right affects the outcome. There are 10 red squares, and there are 10 pixels difference in the Y-direction. Moving, say, the top point one or two points to the left or to the right will just change how the 10 points are distrubuted along the X-axis. It's only when the end point is 11 pixels or more away from the start point in the X-direction that you have to add more points in the X-direction, but then the X-direction has become dominant and that is taken care of by the max() function.
the number of tiles is max(abs(x2-x1), abs(y2-y1)).
How does that work? Wont that just get the number of tiles in one of the two directions? (only the change in X or only the change in Y)?
Edited by Brother Bob, 23 September 2012 - 08:01 AM.
Posted 23 September 2012 - 11:14 AM
Posted 23 September 2012 - 11:55 AM
Now, as others have said, if your really just wanting 'the number of solid tiles between two points' and your counting the tiles in red in the photo, then it is just the greater of the absolute of the difference in Y or X. (As defined by the outer loop in the algorithm.)
Posted 24 September 2012 - 06:09 AM
Edited by Xanather, 24 September 2012 - 06:14 AM.
Posted 24 September 2012 - 06:57 AM
Edited by Xanather, 24 September 2012 - 07:00 AM.