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 Professional Discussion / Set direction before the sprite moves

Author
Message
Eeyore
20
Years of Service
User Offline
Joined: 28th Mar 2006
Location: Netherlands
Posted: 8th Jan 2011 15:36
Searching through the forums I can't find the solution for my problem.
I have a sheet with 216 images of a dice. The dice in the sheet have a couple of directions.
How can I set the direction for the dice before I throw them?
E.G.
I want to set the direction to 95 degrees and play the animation:
Play Sprite 10,25,36,10

Thanks for your help....
bitJericho
23
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 8th Jan 2011 17:42
assign each direction a number.

north = 1
northeast = 2
etc...

create a type to store your animation numbers
type animations
anim_start
anim_end
endtype

create an array to store the specific animation numbers
dim dice(number_of_directions) as animations

assign the values to the array
dice(north).anim_start = 10
dice(north).anim_end = 20
etc...

Then, use these in the sprite command.

sprite x, dice(direction).anim_start, dice(direction).anim_end, x

[center]
Join the TGC Group!
http://tehcodez.groups.live.com
Eeyore
20
Years of Service
User Offline
Joined: 28th Mar 2006
Location: Netherlands
Posted: 8th Jan 2011 18:53
Thats not what I mean.
The problem is not to play the animation, thats no problem, but for that I need to know the direction.
As you can see in the sheet there are 18 directions.
Animation 1-12 = North 90 degrees
Animation 13-24 = South 270 degrees
Animation 25-36 = North-West between 90 and 95 degrees
Animation 37-48 = South-East between 270 and 275 degrees
etc.

When I throw the dice then I will randomly pick up an animation.
e.g. The animation is 37-48 South-East
How do I point and move the dice in a straight line of 275 degrees ?
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 8th Jan 2011 20:00
rotate sprite
and
move sprite?

My signature is NOT a moderator plaything! Stop changing it!
Eeyore
20
Years of Service
User Offline
Joined: 28th Mar 2006
Location: Netherlands
Posted: 8th Jan 2011 21:21 Edited at: 8th Jan 2011 21:41
No, I don't want to rotate the sprite.
I have solved the problem:


Atanfull give the direction back.
Thanks....

Login to post a reply

Server time is: 2026-07-17 17:04:56
Your offset time is: 2026-07-17 17:04:56