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.

Dark GDK / Gradual rotation

Author
Message
Ca11um
13
Years of Service
User Offline
Joined: 3rd Jul 2010
Location:
Posted: 10th Aug 2010 23:52
I know perfectly well how to make a sprite rotate, but because it rotates from the top-left of the sprite, it has a side-effect of moving as well as rotating. Due to this, I want to make the rotation gradual. Below is my current code, but I want to make it like; if dbUpKey() then if the rotation isn't 0 set the rotation to the current rotation - 0, else if it's 0, leave it as it is. Any help with this?

JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 11th Aug 2010 16:50 Edited at: 11th Aug 2010 16:53
Change your rotation values themselves. Instead of rotating in 90-degree increments, make it say: 10, 15 or even 20 degree increments.

Also, I would attach some sort of timer mechanism to the call. As it is right now, an UP-KEY instantly places the sprite at 0-degrees (facing UP?). The Right key makes it facing right...

Here's a summary (with source) of my approach:

Here's my LoopGDK:


Here's my RotatingObject's Update() method:


Here's my code for ElapsedTime()...


Of course, you will have to add checks to make sure that you don't EXCEED the desired finished direction accordingly...

I hope this gives you some ideas to work with...

JTK

Edit: CODE tags are lower case? I never realized that before...
helpfull programmer
14
Years of Service
User Offline
Joined: 30th Jul 2009
Location:
Posted: 9th Sep 2010 19:22
To make it not rotate in the top left hand corner try offsetting it by half its width/height... E.G.

dbOffsetSprite(SpriteID,dbSpriteWidth(SpriteID) / 2,dbSpriteHeight(SpriteID) / 2);

Any good on that problem?
From helpfullprogrammer

Login to post a reply

Server time is: 2024-07-02 09:27:13
Your offset time is: 2024-07-02 09:27:13