Author Topic: Visible timers?  (Read 11690 times)

pigpenguin

  • Seedling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 37
Visible timers?
« on: January 01, 2011, 12:58:24 PM »
So currently I am working on a map were the losing condition is time. I saw a map called convergence which did some pretty cool things involving a timer, graphs, and over all adding new game play. I opened the .lua to try to find the timer code and was swapped in code. So I decided it might be a tad easier to ask you all, how would you code a count down timer or is that way out of scope for some one new to lua? Any way thank you guys for the help,
Pigpenguin

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Visible timers?
« Reply #1 on: January 01, 2011, 02:29:15 PM »
The way I generally do timers is to make the asteroid's name, the time.

Code: [Select]
While GameRunning() do
-- init the variable if this is the first cycle
if timer == nil then
timer = 0
end

-- increment Timer if it's more than a second behind the game time
if timer < GetGameTime() - 1 then
timer = timer + 1
end

-- rename asteroid 0 to whatever the value of Timer currently is
GetAsteroid(0).Name = timer

coroutine.yield()
end



I've also used the core energy for the same purpose but name works best I think.


Not sure if it's possible to write text to the screen.  I suppose you could do it with LineDraw but that would take forever :P


Maybe someone else can help with this more.  :>
« Last Edit: January 01, 2011, 02:32:30 PM by annikk.exe »

pigpenguin

  • Seedling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 37
Re: Visible timers?
« Reply #2 on: January 01, 2011, 04:48:29 PM »
Hmmm well I was looking for more of a count down timer :P but i guess i could just say when the asteroid hits x minutes you lose :P uh and also the one I saw was a bar that grew like a loading screen as time progressed but this is a very simple way of handling it thank you :D

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Visible timers?
« Reply #3 on: January 01, 2011, 05:26:50 PM »
Ohhhh...

That's (quite) easy. You want me to make a template for you, or just tell you what you need and let you find out for yourself?

AWS

  • Achiever
  • Arboreal Being
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 275
Re: Visible timers?
« Reply #4 on: January 01, 2011, 11:30:57 PM »
show us all on this page pilchard, in super brilliant detail, then i can see it too..
 ;D

pigpenguin

  • Seedling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 37
Re: Visible timers?
« Reply #5 on: January 02, 2011, 02:49:14 AM »
If you give me a template explanations would be nice :P that way i learn but yeah past there I really don't have a preference

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Visible timers?
« Reply #6 on: January 03, 2011, 01:10:12 AM »
Workin' on it.

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Visible timers?
« Reply #7 on: January 03, 2011, 03:46:23 AM »
Haha. I have the...amusing problem of there being two menu strips on my game screen. Its gone now, and doesn't seem related to the timer code, but only started after I started.

...

If that makes sense. That'll teach me to be cocky about my Lua skils.
« Last Edit: January 20, 2011, 02:02:19 AM by Pilchard123 »

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Visible timers?
« Reply #8 on: January 03, 2011, 04:19:44 AM »
Okay, attached.

I think it's bug-free, there are copious notes in it (a few are at the bottom of the file).

Have fun. If you want anything explained in more detail/more clearly, just ask. I'm back at college in a couple of days, so the answers might not be that quick.

pigpenguin

  • Seedling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 37
Re: Visible timers?
« Reply #9 on: January 03, 2011, 12:08:03 PM »
Thank you this is soooo cool and no you did a brilliant job of explaining every thing :D

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Visible timers?
« Reply #10 on: January 03, 2011, 06:14:31 PM »
Thanks! Glad you like it.

pigpenguin

  • Seedling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 37
Re: Visible timers?
« Reply #11 on: January 04, 2011, 03:56:42 PM »
Well looking back at it i have 1 question
Code: [Select]
DrawBox(0, 0, barleft, bartop, GetScreenWidth()-10, bartop+barheight, 0, 0, 0, 0.5) Its the numbers and variables in there I am a little confused what some of them mean :/
Other then that i got everything :D (and thats because you told me just to accept that code draws the back round and not to ask so of course i ask :P)

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Visible timers?
« Reply #12 on: January 05, 2011, 01:02:23 AM »
Sorry for the slow reply - I did tell you I wouldn't be around so much now. Basically...

Every time the screen is drawn, it draws a box with

TextureID of 0 (I don't know what this does)
A border 0 units wide
Its left edge BARLEFT screen units (pixels?) in from the left
Its top edge BARTOP screen units (pixels?) in from the top
Its right edge 10 screen units (pixels?) in from the right edge of the screen. GetScreenWidth() stops it breaking inf the screen is resized.
Its bottom edge BARHEIGHT units below the top edge
It has a 0,0,0 RGB value (meaning it's black)
Its alpha (how seethrough it is) is 0.5, so it is half-visible. It looks darker because it is on top of another translucent box.
« Last Edit: January 05, 2011, 02:26:58 AM by Pilchard123 »

Mihhaelo

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 67
Re: Visible timers?
« Reply #13 on: January 05, 2011, 03:00:57 AM »
TextureID is what it says it is, the texture. It's what it "fills" the box with. I can't remember precisely, but i think there are 14 sprites in eufloria, so numbers 0 - 13 are valid?

pigpenguin

  • Seedling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 37
Re: Visible timers?
« Reply #14 on: January 05, 2011, 08:38:52 AM »
Haha sweet thanks and as far as I am aware that is fast because now adays im on once maybe twice a day so if its faster then 24 hours i wouldn't even know :P


pigpenguin

  • Seedling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 37
Re: Visible timers?
« Reply #15 on: January 08, 2011, 02:31:33 PM »
Oh yeah the sprite numbers 0 - 13 are valid and they stand for this

Quote from: Alex
0            Point,
1            Spot,
2            Wing,
3            Background,
4            Noise,
5            CircleFill,
6            Ring,
7            ThickRing,
8            Atmosphere,
9            UIWindow,
10            UIButton,
11            UIButtonPressed,
12            UIButtonHighlight,
13            Pixel,