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 / RTS animation problem.

Author
Message
DWR
21
Years of Service
User Offline
Joined: 2nd Dec 2003
Location: No-where to be seen
Posted: 15th Mar 2004 15:43
I am making an RTS game with little animated people. The funtion for the animation dpeneds on the sprites getting an image from a value (which is regulated by a function.) This is how it works:

sprite 1,100,50,Animation_frame

The problem is, the function works like this:

do
animation_set()
loop

Function Animation_set()
if animation_frame=9
animation_frame=2
endif
sprite 1,100,50,animation_frame
rem Reappends sprite
endfunction

The problems are:

How can I get multiple unit working? (At current, they flash, and I cannot get them to work with different amounts - because the function doesn't know whcih sprites exist and where)

Can any1 suggest a way to improve my pogramming (Im rubbish)???

Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 15th Mar 2004 17:09 Edited at: 15th Mar 2004 17:10
You need to manually track your sprites frame, like with an array. Say you had 256 characters, I'd dimension an array like : DIM Dude_frame(256).

Then, inside your function you can check the frame number array, add one to it, change it however you like, then assign the currect frame to the sprite.

However...

Using a function to do that is pretty strange (and slow), you'd be better off using a subroutine to handle your sprites animation and positioning, like:

Update_Dudes:

For n=0 to 256
dude_frame(n)=dude_frame(n)+1
if dude_frame(n)=9 then dude_frame(n)=2
sprite n+100,dude_x(n),dude_y(n),dude_frame(n)
Next n

Return

Note the dude_x and dude_y arrays, basically these make life easier, always try to keep track of positions through arrays or types, especially with an RTS which relies on this data heavily for the AI.

Also - Telling you this for your own good, drop the sprites idea and go 3D. A while ago I was experimenting with a 2D engine, and was able to go from 40 characters on screen to about 300 by replacing the paste image/sprites with 3D plains, which you texture with the relevant image. This method is packed with benefits, like not having to worry so much about z-depth problems, being able to ghost objects to make cool particle effects, and you'd be able to run your game at whatever resolution you liked without having to code around user resolution problems.


Van-B


The nature of Monkey was irrepressible!.
zircher
22
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 15th Mar 2004 17:42
Aye, Van B has a solid point. Using 3D for a 2D game has some nice perks such camera zooming and rotation.

DWR
21
Years of Service
User Offline
Joined: 2nd Dec 2003
Location: No-where to be seen
Posted: 15th Mar 2004 21:10
Thank you very much for the suggestion, but the problem is that I'm no good at 3d stuff, and I need a decent modelling program (and animator) that will save my animation+texture in an X file (Because I suck at manual texturing) If you have any ideas, plaese reply (Although I'll still have a go at 3d though, because only with around 20 sprites on screen, stuff began to go slow!!)

zircher
22
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 15th Mar 2004 21:23 Edited at: 15th Mar 2004 21:24
No, no, you're missing the point. We are taking about 2D objects in 3D space. Instead of texturing a sprite, texture a plane. You can rotate, scale, and position that plane like a sprite as well as other special effects.

Code Ninja
21
Years of Service
User Offline
Joined: 17th Dec 2003
Location: AZ, U.S.
Posted: 15th Mar 2004 21:36
nice thinking...

DragnBreth
of
Dragael Software
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 16th Mar 2004 11:27
Yeah, Zirchers got the idea - you can even use a matrix as a tile engine for your game as if it was in 2D, you just stick the sprite plains over the top and move the camera around while facing straight down onto the matrix.

I'm actually making a 2D level editor for someone - I plan to make some different handling examples, one 2D example for easy code migration, and another that uses 3D to mimic the 2D map. I don't think it'll take too long to finish (probably by the weekend) because I'm taking a simple approach - but my editor should be plenty powerful.


Van-B


The nature of Monkey was irrepressible!.

Login to post a reply

Server time is: 2025-05-24 19:18:38
Your offset time is: 2025-05-24 19:18:38