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.

2D All the way! / DBPro - I can't get Create Animated Sprite to work....... Does it?

Author
Message
Bartman
19
Years of Service
User Offline
Joined: 26th May 2005
Location: A rural village in NSW Australia.
Posted: 26th May 2005 20:56
2D sprite animation in DBPro.
Hi,
Assume I have a bitmap containing the 6 frames of an explosion arranged horizontally. (Each frame is 60x60 pixels so the bitmap is an image 360x60 pixels and is called "explosion.bmp").
Now, how do I get the Create Animated Sprite Command and Play Sprite command to display the animation after a collision?
It should only be 5 or 6 lines of code but I can't get the damn thing to work!
I just get the stupid blue screen with nothing on it! - I can remove the Create Animated Sprite and Play Sprite commands and do the animation manually with a do... Loop and then use the sprite command while incrementing the image number for each frame but why can't I do it with Create Animated Sprite command?
Is there a program out there that successfully uses the Create Animated Sprite command that I can download and learn from? (or copy from?)
Please help me before my head explodes instead.
Thank you for averting a messy disaster.
ObiWan...... Dunnobi -- Really thank you for your help.
zenassem
22
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 27th May 2005 23:38
I had a similar problem a long time ago with play sprite and finally gave up. To get around the issue I wrote my own code to update the sprite image. I'll try to see if i can revisit play sprite and see what I can come up with.

It takes a lot more code to keep track of the animation frames on your own, but I think you will get better results. I'll post the basics of what I did. Keep in mind that It would be easier to have the character and animation frames in a user-defined-type. I wrote some of this code while experimenting with DBC.



the anim variable keeps track of the current animation frame. I increment the animation frame in my movement code. If anim equals the last frame I reset it to the first frame.

Hope that helps...

~zen


Bartman
19
Years of Service
User Offline
Joined: 26th May 2005
Location: A rural village in NSW Australia.
Posted: 28th May 2005 10:44
Thank's for the speedy repy, zenassem.

I do agree that you get much better results using your own tracking of the animation frames, especially when the animated sprite can change direction or stop moving.

I think that my problem is more a matter of not accepting that I can't get the Create Animated Sprite (CAS) and Play Sprite (PS) commands to do what they claim they can do. Plus for something as simple as an explosion animation it would be nice to use the easiest tool for the job. This should be CAS and PS!

If you get anywhere with your revisitation to the CAS & PS commands please don't hesitate to let me know back here.

Thank's for your interest, and for the code snippet. (Your code is somewhat similar to mine but will be very useful in this thread for anyone trying to animate a sprite).

ObiWan.
Zone Chicken
21
Years of Service
User Offline
Joined: 25th Jan 2004
Location: `~-..-~`~-..-~`
Posted: 28th May 2005 12:49
I think that create sprite may have broke in 5.8 i just tried it and i found that if you have 1 a backdrop on the sprite will not show up, 2 that even though the sprites frames are counted when play sprite is ran in a loop the image doesn't change.

It might be something dumb im overlooking though as i haven't used the commands for awhile i posted in the bugs anyway.
http://forum.thegamecreators.com/?m=forum_view&t=54744&b=15

Your signature has been erased by a mod -- please resize to under 600x120...
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 28th May 2005 15:23 Edited at: 28th May 2005 15:24
I don't have any troubles with it... although it did take me a while of trial and error to get this to work...



The media is attached...

Team EOD :: All-Round Nice Guy
Want Better dbHelp Files?

Attachments

Login to view attachments
Baggers
20
Years of Service
User Offline
Joined: 31st May 2004
Location: Yonder over dem dere hills
Posted: 28th May 2005 15:49
Aye it is a fiddly one but it does indeed work as Jess showed (on 5.8)

Bartman
19
Years of Service
User Offline
Joined: 26th May 2005
Location: A rural village in NSW Australia.
Posted: 30th May 2005 11:32
Hi all,
Well here's the gen on the create Animated Sprite fiasco.

Create Animated Sprite.
I have no hesitation in praising the creators of DarkBasic for the quality of their wonderful software, however the quality of their documentation makes me wonder if English is their second language.
So, let me just add one word to the syntax for the Create Animated Sprite Command that will miraculously clear up so many issues for anyone inexperienced in the command.
"FRAMES" - CREATE ANIMATED SPRITE Sprite Number, Filename, FRAMES Across, FRAMES Down, Image Number
(i.e. it's not PIXELS Across per frame, PIXELS Down per Frame,)

Play Sprite.
Who else thought that the animation should play after the Play Sprite command is executed? Me too, but it's just not so. Essentially all Play Sprite does is keep track of the frame number for you and then each iteration of the Play Sprite command the sprite is drawn with the next frame. If play sprite isn't inside some kind of loop then it will only play the first frame and then the program will continue along, probably without anybody even noticing that the sprite was displayed at all. The documentation for this command mentions nothing of this - in fact the words.... "This command will play an animated sprite" are downright misleading! - what were they thinking? I seriously doubt that the doc writer had ever used this command.

So anyway, this brings us all back to square one, where you are just better off managing the animation yourself.

Thus-henceforth-hereunto.
If you created an animation bitmap that looked like this --> \|/- and called it "rotating_lines.bmp" then your Create Animated Sprite Command would be --> Create Animated Sprite 1,"rotating_lines.bmp",4,1,2

This creates sprite number 1 from the bitmap "rotating_lines.bmp" which is 4 frames across by 1 frame down and stores the full image in image number 2. Use the Sprite command a-la, Sprite 1,x,y,1 to put sprite 1 on the screen at the x,y coordinates using image 1. Lastly if you must use Play Sprite, use the Play Sprite command inside a loop to cycle through the frames of the animation a-la, Play Sprite 1,1,4,100 which means Put sprite 1 back on the screen using frames 1 through 4 with a 100 millisecond delay between displaying each new frame. See the code snippet.

However rather than using Play Sprite it is better to use the Sprite command inside the loop and then increment the image number to make the animation happen. You will then also have control over the number of times the lines rotate as well as the x,y position of the rotating lines. Create Animated Sprite can still be used to initially create sprite 1 with a four frame animation. See Zenassem's and JessTicular’s excellent code examples above to see how this would be done without the Play Sprite command!
Demo
21
Years of Service
User Offline
Joined: 3rd May 2004
Location: australia
Posted: 19th Jun 2005 17:09
I hope im not to late in my post, but iv just started designing my game again and also just started using the 'Create Animated Sprite' command. Is it buggy because everything works except this one thing...

If i have this code just to play a simple sprite animation

it works, but as soon as i press left again, the animations sequence starts from frame 1 all over again. from frame 1 to frame 36, then after that it works(looping 36 to 38).

I know by setting the frame number(set sprite frame) i can work around this problem, but are there any updates or patches that fix this problem?

~demolicious

sEriously..
Bartman
19
Years of Service
User Offline
Joined: 26th May 2005
Location: A rural village in NSW Australia.
Posted: 21st Jun 2005 10:06
G'Day,
I don't think that your problem is a buggy Create Animated Sprite command, it's probably your usage of it. (As it was for me)!

However, I can't see a problem with your code as far as playing an animation from frames 36 to 38 when the leftkey is held down.

I suspect that the animation playing from the first frame is a result of another instance of the play sprite command in your program.
--- What is your program doing BEFORE the leftkey is pressed AGAIN?
--- In what instance should the animation play from frames 1 to 36?

Sorry I can't be more help.
ObiWan.

Login to post a reply

Server time is: 2025-05-17 19:45:36
Your offset time is: 2025-05-17 19:45:36