Strange problem with movement code

BlitzMax Forums/BlitzMax Programming/Strange problem with movement code

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Exactly right. The variables x,y,dx,dy should all be floats. This is the natural approach for BlitzMax and Blitz3D.

The reason for the different behavior is the default "float to integer" conversion. BlitzMax chops while Blitz3D rounds.

For example, suppose integer x=5 is changed by +1.7 or -1.7.

In Biltz3D this will produce 6.7 or 3.3, which are rounded to 7 or 3. So x changes by 2.

But in BlitzMax 6.7 is chopped to 6 and 3.3 is chopped to 3.
So x increases by 1 ( speed to the right ) or decreases by 2 ( speed to the left ).