Author Topic: Displaying the Game Clock in the Status Bar  (Read 5444 times)

0 Members and 1 Guest are viewing this topic.

Offline MusicallyInspired

Displaying the Game Clock in the Status Bar
« on: September 20, 2011, 02:17:37 PM »
A la KQ3. I know it's possible. I've tried it before by adding variables pointing to gTimeSeconds, gTimeMinutes, and gTimeHours but I can't figure out how to get the status bar to update each time the clock is updated. Any ideas? Perhaps this involves altering the clock updating code a bit and examining how the changescore method updates the status bar for the score and copy that somehow.


Brass Lantern Prop Competition

Offline MusicallyInspired

Re: Displaying the Game Clock in the Status Bar
« Reply #1 on: September 20, 2011, 02:35:49 PM »
Ok, actually I'm part way here already. All that's needed is a status line draw update. So I changed the status line code in Main to read:

Code: [Select]
(instance statusCode  of Code
(properties)
  (method (doit param1)
   Format(param1 " Score: %d of %-3d   %02d:%02d:%02d      Template Game " gScore gMaxScore gTimeHours gTimeMinutes gTimeSeconds)
  )
)

(actually, I recommend putting the clock at the end of the status line because when it updates some font characters are different widths than others and this moves anything to the right of it around based on the size. Unless you're using a unicode font where all the characters are the same width, then you wouldn't have this problem)

...and added the line (SL:doit()) to the clock updating code in Main:

Code: [Select]
(if(<> gCurrentTime (= gCurrentTime GetTime(gtTIME_OF_DAY)))
   (if(>= ++gTimeSeconds 60)
    = gTimeSeconds 0
    ++ gTimeMinutes
    (SL:doit())
    (if(>= gTimeMinutes 60)
    = gTimeMinutes 0
    ++ gTimeHours
    (SL:doit())
    )
)
)

The only problem is that it only updates for the minutes and hours and doesn't update for each second. I'm not sure how to go about accomplishing that since the seconds are updated within the if statement condition:

Code: [Select]
(if(>= ++gTimeSeconds 60)

Working on a workaround for this...
« Last Edit: September 20, 2011, 02:39:34 PM by MusicallyInspired »
Brass Lantern Prop Competition

Offline MusicallyInspired

Re: Displaying the Game Clock in the Status Bar
« Reply #2 on: September 20, 2011, 02:45:37 PM »
Eureka! I've solved the problem and I'll now post a how-to in the tutorial section and on the wiki.

http://sciprogramming.com/community/index.php/topic,525.msg2913.html#new
« Last Edit: September 20, 2011, 03:02:57 PM by MusicallyInspired »
Brass Lantern Prop Competition


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.066 seconds with 17 queries.