dcsimg
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: time & points system

  1. #1
    Senior Member dudeqwerty's Avatar
    Join Date
    Mar 2005
    Location
    Bosnia
    Posts
    1,626

    time & points system

    hi there.
    i am making a game, there is going to be a timer that counts down, when you complete the level the time left on the counter is multiplied by 10 then added to the points.
    the problem is that i have no idea on how to do this, can someone please help?
    your a legend if you can.
    New sig soon

  2. #2
    Secret Agent
    Join Date
    Sep 2000
    Location
    San Francisco, CA
    Posts
    169
    Assuming you know what a variable is, and you know some basic actionscript, here's an attempt at explaining a solution:

    When the player enters the starting point of the game you need to do a getTimer(), which counts the milliseconds from the point that the movie was started.

    PHP Code:
    start_time getTimer(); 
    so each time you want to see how long the game has been played you compare getTimer() to start_time.

    (1 second = 1000 milliseconds.)

    PHP Code:
    play_sec Math.floor((getTimer() - start_time)/1000); 
    The above would give us the amount of seconds played so far (rounded down).

    If you're making a counter, you'll want to make a count-down this way:

    PHP Code:
    counter_sec 120 play_sec
    Assuming you want to allow the player 120 seconds (two minutes) play time you'll be able to count down like this.

    Then when the player has successfully ended the level, you just take the counter_sec variable, multiply it by 10, then add it to the score that you're keeping track of:

    PHP Code:
    score_total counter_sec 10 score_temp
    Anyway, something like that. Hope this helps.

    Peace,
    Allan

  3. #3
    Senior Member dudeqwerty's Avatar
    Join Date
    Mar 2005
    Location
    Bosnia
    Posts
    1,626
    cheers for that.
    ill try it tomorrow, im well to tired at the mo,
    will let u no if it works.
    New sig soon

  4. #4
    Senior Member dudeqwerty's Avatar
    Join Date
    Mar 2005
    Location
    Bosnia
    Posts
    1,626
    hi there. i didnt know about the getTimer function.
    im guess im just being stupid but i put all the cide into the frame and made 2 d_textboxes called counter_sec and play_sec and it does nothing, have i done it right?
    New sig soon

  5. #5
    Secret Agent
    Join Date
    Sep 2000
    Location
    San Francisco, CA
    Posts
    169
    counter_sec and stuff are only variables.
    In order to get them to display in a textfield you need to do a little more work.

    Give your textfield (must be dynamic) a variable name: counter_txt
    You can do this in the little properties pallette when the text field is selected.

    Then add this code to your script:
    PHP Code:
    counter_txt.text counter_sec
    That will make the counter show up in the text field.
    Then you need to make sure it updates the counter_txt.text often enough. So you may want to put that action on a mc that plays in a loop. Then it will happen over and over again.

    Got it?

    aldorr

  6. #6
    Senior Member dudeqwerty's Avatar
    Join Date
    Mar 2005
    Location
    Bosnia
    Posts
    1,626
    ah silly me, thanks for that it works now
    New sig soon

  7. #7
    Secret Agent
    Join Date
    Sep 2000
    Location
    San Francisco, CA
    Posts
    169
    No prob.

    Enjoy... And don't stay up too late!

    aldorr.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center