From: George Foot Newsgroups: comp.os.msdos.djgpp Subject: Re: Smooth moving Date: 6 Feb 1998 07:30:10 GMT Organization: Oxford University, England Lines: 38 Message-ID: <6bee62$9al$2@news.ox.ac.uk> References: <34D746D4 DOT 84EF3964 AT mail DOT htk DOT fi> NNTP-Posting-Host: sable.ox.ac.uk To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk On Tue, 03 Feb 1998 18:33:25 +0200 in comp.os.msdos.djgpp Henri Ossi wrote: : But again, one thing, that has always annoyed me is, : that when the ball moves around the screen : (I'd like to move it with float-numbers and use sin and cos : to get the dx, dy variables counted) Try making the game resolution much higher than the screen resolution. For example, make one pixel on the screen correspond to a lot (e.g. 1 << 16) of units in the game. Then you can get the angle and speed very accurate, without having to add and subtract floating point numbers (which should be slow). You hinted, though, that you don't like one artifact of this system -- that the movement is effectively rounded to the screen resolution when drawing the graphics. There is no simple way to remove this :(; antialiasing is one partial solution. If you want to restrict yourself to 45 degree angles then you need to scale down the increase in X and Y when travelling diagonally. The scale factor is of course sqrt(2), which is around 1.4; if you could make your normal speed 2.8, when travelling diagonally you would want to increase/decrease the coordinates by about 2 each time. This means that using 3 and 2 works fairly well. To clarify, to move left/right or up/down you would decrement/increment the X or Y coordinate by 3; when moving diagonally you would alter both coordinates by 2. I find, though, that generally it's better to use the fixed-point system I mentioned first, and live with the (slight) jumpiness. When more is happening in the game it's not really very noticeable, especially if the scenery is moving; players only really notice how their character is moving with respect to the other characters. -- george DOT foot AT merton DOT oxford DOT ac DOT uk Remember what happened to the dinosaur.