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 / rotate sprite...

Author
Message
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 23rd Sep 2008 10:07
Is it possible in DBC? I tried using memblocks to write copy the image but rotated, and it just didn't seem to work. The image is 40x40, so it is a perfect square, I just need to rotate it 90 degrees somehow.

Any ideas?

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?
Robert The Robot
18
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 23rd Sep 2008 11:11
There's a hidden command called "Rotate Image". Call it like this:


The Angle can only be a multiple of 90 (so you can use 90, 180, 270, 0).

Off topic, could I just ask if you read my edit on the last post in the DBC Community Functions Library thread? I had to edit my Particle system again after one or two minor goofs, and I'd just like to make sure you got it.

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 23rd Sep 2008 14:34
You can fake a sprite by texturing a plain and rotating that, it runs more smoothly than a sprite, but that would be hard to do. Otherwise there isn`t a way...

Suicide is away of telling God, You can’t fire me I quit !!!!!
Irojo
17
Years of Service
User Offline
Joined: 21st May 2008
Location: Eating toast.
Posted: 23rd Sep 2008 16:53 Edited at: 23rd Sep 2008 23:38
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 23rd Sep 2008 19:20
Quote: "Off topic, could I just ask if you read my edit on the last post in the DBC Community Functions Library thread? I had to edit my Particle system again after one or two minor goofs, and I'd just like to make sure you got it."


Yeah, I haven't been working on that one recently, though. Got busy doing the darkNOOBS project and such. Once we are done, I will go back to compiling libraries.

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 23rd Sep 2008 19:40 Edited at: 23rd Sep 2008 19:45
Interesting with the rotate image command. You can paste it, but you can't make a sprite from it. I guess the only way to do it will involve pasting it on a separate bitmap and then use get image.

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 23rd Sep 2008 22:09
Check out Irojo's link.

And it is possible to do with memblocks as well - though a bit slow unless you use a DLL for real time rotation. Part of the trick is to use a matting in the image rotation. If you rotate the image say 45 degrees, the corners will point N S W E and there will be "spaces" where the image was. If you fill these spaces with zeros (black) you can set them to transparent. Also, the size of the image can change with rotation. In your rotation algorithm, you can squish it as it rotates, you can crop it - chop off the parts that are rotated out of the size of the original image, or you can expand it (in which case you'd need a second memblock to write the new data to.

Once you have the rotation done, make an image from the memblock and use this new image for the sprite.

Another way is to capture the rotations using a 3d object ahead of time as images - similar to the link to the code snippets:



Enjoy your day.
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 24th Sep 2008 00:38
Very clever Latch!

I used a similar method for making a 3d game on a matrix with 2d towers, and man, they looked real!

Only, it takes up a lot of images, it`s slow(because you have to update all of the images every loop. Pretty hard if you have 100 sprites), and it takes a long time to render...

Suicide is away of telling God, You can’t fire me I quit !!!!!
Irojo
17
Years of Service
User Offline
Joined: 21st May 2008
Location: Eating toast.
Posted: 24th Sep 2008 00:53 Edited at: 24th Sep 2008 05:47
...and you have to sync it on screen.

[EDIT]

DBC GLITCH!?!?!??!

Treats the image like a sprite. GET'S RID OF THE IMAGE AND PUTS A NEW ONE DOWN.

Not idealistic for me.




I download memory.

Login to post a reply

Server time is: 2025-06-07 08:02:37
Your offset time is: 2025-06-07 08:02:37