Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Im new... how to animate a sprite?

Author
Message
andrew clifton
19
Years of Service
User Offline
Joined: 26th Feb 2007
Location:
Posted: 27th Feb 2007 04:53
Hi im new to darkbasic... and im looking for some help... can anyone tell me how I animate sprites?? (looping)
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 27th Feb 2007 13:53
Use the Sprite command. From the help files:

SPRITE
This command will set the position and image number of the specified sprite. Providing you are using a valid image number from a previous call to the GET IMAGE command, and the position of the sprite is in the screen area, you will see your sprite displayed. You can move your sprite by calling the sprite command with new position coordinates. You can animate your sprite by calling this command with different image numbers to create the effect of animation. You are able to have over sixty thousand sprites on the screen at any one time, but it is advisable to restrict yourself to a few hundred sprites for speed critical programs. The parameters should be specified using integer values.

SYNTAX
SPRITE Sprite Number, X, Y, Image Number

In the help files, go to the Commands Menu and you'll see section 8 which is all about Sprites. There are example programs for each command so you can see how they work.

TDK_Man

Area 51
20
Years of Service
User Offline
Joined: 3rd Feb 2006
Location: UNKNOWN
Posted: 3rd Mar 2007 17:16
Can you use a GIF file to animate it? Or else it's just a plain old picture that can be moved.

Are we alone?
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 11th Mar 2007 19:15
Yes, a sprite is essentially a plain old picture that can be moved - just like Paste Image.

But, using Paste Image you don't get collision and you have to restore the background behind the image yourself as it moves around.

It would be nice to have Prepare Sprite Texture and Animate Sprite commands, but for now all we can do is call the Sprite command in a loop with a series of image numbers.

TDK_Man

Login to post a reply

Server time is: 2026-07-06 03:59:17
Your offset time is: 2026-07-06 03:59:17