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 / Clock-like timer, help?

Author
Message
FunnyGames
15
Years of Service
User Offline
Joined: 11th Feb 2011
Location:
Posted: 11th Feb 2011 10:55
Hello, first post here.

I want to create a timer, which will look like a clock-like timer, I don't know how to call it, but I manage to create it with lines:

However, I want to create it with sprites/images, is it possible?
If so, can you post the code for it?

Thanks in advance.
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 11th Feb 2011 12:09
Hello! Welcome to the forums!

It is entirely possible to do it with sprites, and actually a hell of a lot easier!

Well done on your first attempt. Using sprites, you would have images that represent the hands. When you create a sprite, the default rotation point is in the top-left of the sprite, but you can change that using the OFFSET SPRITE command. Change the rotation point of the sprite to be where the hand of the clock should rotate from and then use ROTATE SPRITE to rotate it to the angle it needs to be at for each second/minute/hour.

Hope this helps!

Malevolence: The Sword of Ahkranox
The infinite RPG
http://www.msoa-game.com
FunnyGames
15
Years of Service
User Offline
Joined: 11th Feb 2011
Location:
Posted: 11th Feb 2011 12:39
It's not exactly what I meant... Thanks for reply, but if you run the code I wrote, you'll see that the older line not cleared from the screen. (I didn't use cls just to keep the old line in the screen).
I know how to do what you said, but unfortunately it's not what I'm searching for...

(Just you to know, I'm not new to programming )
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 11th Feb 2011 14:37
Ah, well you can use the same suggestion as I made before, only use PNG files for the alpha channel, and use the PASTE SPRITE command, which will give you that non-cleared older line look you're after.

Malevolence: The Sword of Ahkranox
The infinite RPG
http://www.msoa-game.com
FunnyGames
15
Years of Service
User Offline
Joined: 11th Feb 2011
Location:
Posted: 11th Feb 2011 16:42
It didn't work
There's no difference between SPRITE command and PAST SPRITE, these commands lead to same result.

Maybe something is wrong with my code?
It rotates, but it doesn't keep the old image, like using CLS in lines code (in first post).
Any suggestions? Or an example code?
sadsack
22
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 11th Feb 2011 23:22
I found this, I don't know if this is what you want?





renny

Life is not fair, so deal with it.
http://www.gusroundtable.com/
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 12th Feb 2011 03:47
Hmm... Strange. It could be that the alpha channel in the PNG file is acting as a wiper for previous entries. Try using a BMP file instead with a block colour background (say RGB(0, 255, 0)) and then use the SET IMAGE COLORKEY command before you load the image. That might work...

Malevolence: The Sword of Ahkranox
The infinite RPG
http://www.msoa-game.com
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 12th Feb 2011 03:49
Actually... Scratch that... That won't work... Leave it with me. I'm experimenting :-P

Malevolence: The Sword of Ahkranox
The infinite RPG
http://www.msoa-game.com
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 12th Feb 2011 04:21
It is a bizarre problem. Generally, Sprite redraws only happen when you DONT WANT them to, but as soon as you TRY to get one to happen, it says "no soup for you" and gives you the finger...

I did come up with ONE solution, though it is admittedly kind of a kludge and probably isn't what you're looking for, but it DOES work... To an extent...



Hopefully this helps a little, or at least gives you the mental jolt you need to crack this one!

Malevolence: The Sword of Ahkranox
The infinite RPG
http://www.msoa-game.com
FunnyGames
15
Years of Service
User Offline
Joined: 11th Feb 2011
Location:
Posted: 12th Feb 2011 13:05
sadsack:
Thanks for the code, but that's not what I looked for...

CumQuaT:
Well, that's nice... But it's just touching the point...
I believe I have to make an animation for it.

Thanks for help.
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 12th Feb 2011 14:54
Not a problem. Sorry I couldn't work it better.

Malevolence: The Sword of Ahkranox
The infinite RPG
http://www.msoa-game.com
Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 12th Feb 2011 16:43 Edited at: 12th Feb 2011 16:46
If you have installed IanM's Matrix Utility Plug-In, then this code may give something close to what you want...



CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 12th Feb 2011 16:53
That won't give him what he wants at all, as it doesn't use sprites.

Malevolence: The Sword of Ahkranox
The infinite RPG
http://www.msoa-game.com
Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 12th Feb 2011 17:10 Edited at: 12th Feb 2011 17:12
True dat. With the code using lines, he could have the hands be sprites and rotate over the lines as they draw the colors.

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 12th Feb 2011 18:11
Here's my version:



It's fairly simple and doesn't track how long it runs but it'll give you the general idea of how to do a clock with PASTE IMAGE, and SPRITE.

Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 12th Feb 2011 20:17 Edited at: 12th Feb 2011 20:24
And a combination of GG's code and mine yields



Again, IanM's Matrix Utility is needed for my lines.

EDIT: Hmmm, it gets a little weird between 4 and 5, not sure why though.

Virtual Nomad
Moderator
20
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 13th Feb 2011 03:59
hard to understand exactly what you want but still fun to play with (for a few mins):



something's changed with sprite backsave setting vs backdrop being automatically on when using sprites... things didn't act as i expected but i think it's close to what you want(?)

Virtual Nomad @ California, USA . DBPro V7.5
AMD Phenomâ„¢ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 13th Feb 2011 04:22
As far as I can tell, what he wants is a clock-like timer that fills like a pie chart as the timer counts. Rather than hands as such, he wants it to fill a pac-man style chart more and more.

However, he wants to do this using SPRITES and not 2D graphical lines, etc.

Malevolence: The Sword of Ahkranox
The infinite RPG
http://www.msoa-game.com
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 13th Feb 2011 08:11
He can do it the hard way and make a pie chart sprite sheet and use CREATE ANIMATED SPRITE to load the animation.

This only uses 5 frames... I'm too lazy to make smaller increments.



FunnyGames
15
Years of Service
User Offline
Joined: 11th Feb 2011
Location:
Posted: 13th Feb 2011 15:13
Wow... So many replies in 1 day... O.O

Well, it's alright, I already make the animation...
And I figured out how to make it from 4 sprites.
Download images, and here's the code:

It's nice... I already animated it, so the animated looks much better, so that's the idea.
Thanks for sharing your ideas.
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 13th Feb 2011 16:53
We all love a challenge. Glad you got it working the way you want it.

Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 13th Feb 2011 18:39
Wow, yeah, good job! That's very clever, you should put it in the codebase.

FunnyGames
15
Years of Service
User Offline
Joined: 11th Feb 2011
Location:
Posted: 13th Feb 2011 23:57
Rich Dersheimer:
Thanks! As you advised, I put it in codebase:
[href]
http://www.thegamecreators.com/?m=codebase_view&i=99e9f42f5d23d0d6215cdc0275077c52[/href]

Login to post a reply

Server time is: 2026-07-16 01:44:32
Your offset time is: 2026-07-16 01:44:32