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! / Sprite Rotation

Author
Message
Rabid Spatula
21
Years of Service
User Offline
Joined: 5th Mar 2003
Location:
Posted: 8th Mar 2003 20:59
Hi, I am VERY new to DarkBasic and I am fiddling around with sprites. The one I am working on now needs to rotate to the right and left, but I've tried the code bits suggested by several people in an earlier post and they don't work. The sprite loads fine, but when I try to get the rotate commands in there it crashes. Here is what I have for movement:

IF UPKEY()=1 THEN ypos = ypos - speed
IF DOWNKEY()=1 THEN ypos = ypos + speed
IF RIGHTKEY()=1 THEN Rotate Sprite 1,90
IF LEFTKEY()=1 THEN Rotate Sprite 1,-90

What am I doing wrong?

Thanks
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 8th Mar 2003 21:22
I've put your code into a program



I'm unsure what you are try to get, but your commands don't crash for me - unless you haven't set up the sprite before you try rotating it.
Rabid Spatula
21
Years of Service
User Offline
Joined: 5th Mar 2003
Location:
Posted: 8th Mar 2003 23:49
Thanks What I was trying to do was get the Sprite to rotate from the top either left or right. That way it would turn to face any direction of the screen.

Rabid Spatula
21
Years of Service
User Offline
Joined: 5th Mar 2003
Location:
Posted: 8th Mar 2003 23:55
Update: I tried the new code and it still doesn't work. It says that
IF RIGHTKEY()=1 THEN Rotate Sprite 1,90

is an unknown command. Any ideas why it would do that?

Just so you know, I have the original DarkBASIC and use DarkEdit.

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 9th Mar 2003 00:18
Aha, sprite rotation is in DBPro only.

Have a look at www.underwaredesign.com under Products/Snippets/Darkbasic code libraries and look at the psprites library. You may be able to build something from that.
Rabid Spatula
21
Years of Service
User Offline
Joined: 5th Mar 2003
Location:
Posted: 9th Mar 2003 00:48
Thanks for your help I'll do my best. There is absolutely no sprite rotation in DB Classic? If I was able to name the Sprite as an object would it be able to rotate?

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 9th Mar 2003 01:36
If you look at the library I've pointed you to and check the code, you'll see that it uses textured plane objects to display images. That's pretty much how DBPro does it.
Rabid Spatula
21
Years of Service
User Offline
Joined: 5th Mar 2003
Location:
Posted: 9th Mar 2003 06:50
Is it possible to make a sprite a texture? If the question is a dumb one chalk it up to newbie inexperience

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 9th Mar 2003 21:13
The images that you use for sprites are also textures.
trager
21
Years of Service
User Offline
Joined: 5th Feb 2003
Location: United Kingdom
Posted: 28th Mar 2003 14:25
The standard way to rotate sprites is not to use sprites but 2D plains in a 3D environment.

Then you can rotate the plain. You can use the sprite image as the plain texture. This works for me

There is no answer only more questions.
Andy Igoe
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 28th Mar 2003 22:05
In my (now rather dated game) Space Corps I made a 2D game entirely using 3D. The 'sprites' where infact just object plains with the sprite texture on them. I did this to allow the camera view to zoom in and out even though the game was specifically an overhead shoot-em-up.

It's downloadable from my webpage if you want to see it working, but that's pretty much all the effect is, a 3D plain with a texture. The bullets and missiles in the game are done the same way too.

Pneumatic Dryll, Outrageous epic cleric of EQ/Xev
God made the world in 7 days, but we're still waiting for the patch.
PiratSS
21
Years of Service
User Offline
Joined: 18th Oct 2002
Location:
Posted: 28th Mar 2003 23:52
I would use 3D Plains, but then you could get into trouble with overlapping. It would be cool if DBC Could have Sprite Rotation.

Cheers.

1PH J00 C4|\| U|\|dER$T@|\||) +|-|I$, j00 |-|@\/3 4lR3Ady w0|\|! - p1r@T$$
Ishamael Sedai
20
Years of Service
User Offline
Joined: 1st Jul 2003
Location: France
Posted: 24th Jul 2003 22:17
memblock

I am the Betrayer of hope naebl'is by the will of
the Great Lord of the Dark. If you do not want to surrender, your soul will burn in the deepest hole of the Pit of doom.
CPU
20
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Carlsbad, CA
Posted: 25th Jul 2003 06:17
how would you use memblocks to rotate sprites?

Sparring - Loved by many, Pefected by few.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 25th Jul 2003 10:30
You could convert the image to a memblock to get the pixel colours, and use those to plot to the screen.

Also, I believe that GuyS at one time wrote a DLL to rotate images within a memblock.
Dr Dri
21
Years of Service
User Offline
Joined: 18th Mar 2003
Location: France
Posted: 25th Jul 2003 23:47
i posted a fonction that rotate images using memblocks, i'll try to write it in a dll but you can use it for now.

Dri

Pour des yeux déformés la vérité peut porter un visage grimaçant.
CPU
20
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Carlsbad, CA
Posted: 26th Jul 2003 00:08
where did you post that function, i have a slow interntet conection so its hard for me to go looking. CPU

Sparring - Loved by many, Pefected by few.
Dr Dri
21
Years of Service
User Offline
Joined: 18th Mar 2003
Location: France
Posted: 26th Jul 2003 00:43
http://www.darkbasicpro.com/apollo/view.php?t=12583&b=4

Dri

Pour des yeux déformés la vérité peut porter un visage grimaçant.
CPU
20
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Carlsbad, CA
Posted: 5th Aug 2003 01:12
Thanks dr dri, i'm pritty sure i'm going to be using that function

Sparring - Loved by many, Pefected by few.

Login to post a reply

Server time is: 2024-04-26 15:58:06
Your offset time is: 2024-04-26 15:58:06