Re: Graphics Problem

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Mon, 10 Mar 1997, ROGER wrote:

>     My problem is this:  I have a 2-D shape, moving over a complex
> background, and am having trouble cleaning up after the shape has moved.
> I have thought of using get_pixel but am sure that this would slow down
> the the speed of the 2-D shape moving.

I make the sprite size bigger than the actual object, and "draw" to a
virtual screen to mask it with the background before drawing it to the
real screen.  If you have a 3 pixel black border around the object, you
can move it 6 pixels in any direction without trails.

In the OidZone Programmer's Reference guide I explain the theory in gross
detail and go line by line through my spirte engine code.  Everyone who
wants to do heavy duty graphics work needs my book and source code.

>         I also have another question that is slightly related to the last
> one.  I have coded the shape to move a certain number of pixels each
> turn in a loop.  But the speed is dictated by how fast the computer can
> run the instructions, is there any other way to determine (to set), the
> speed at which the a shape moves, because at the moment the speed the
> shape is moving at is machine depandant.
> Now for the question, is there anyway to code it so that the shape moves
> at a set speed, and is does not change speed, (to much), on different
> range of systems.
To set the rate, use the time() function.  Before you draw anything, do a
frameclock=time(), then do your drawing fuctions and screen update stuff,
then do this:

while frameclock2-frameclock<.05  --.05 seconds
end while

It will sit and wait for the time to go by before moving on.  This makes
your code go the same speed on all machines.  You probably want to set the
tick_rate() to 100 frames per second to make time() more accurate, it's
default is 18-20 frames per second.

Michael Packard
Lord Generic Productions
lgp at
A Crash Course in Game Design and Production

new topic     » goto parent     » topic index » view thread      » older message » newer message


Quick Links

User menu

Not signed in.

Misc Menu