3
\$\begingroup\$

I am new to GameMaker's coding language or GML. I have learned and done a lot so far, but now i am having a problem. I have a countdown timer starting at 5 minutes counting down and I want the player to receive points based on how much time is left kind of like in Super Mario Bros. along with the points accumulated for performing other tasks. How do I go about doing this with the coding language? Thanks in advance!

\$\endgroup\$
3
  • \$\begingroup\$ Why wouldn't it be the case of a simple loop that, at every millisecond, decreases X from the counter that has saved the time left when player finished the level - and then increases the score counter by X*Y? Then, if X=1, you just have to choose a value for Y that you think is reasonable as a value to give as a score gift per millisecond, depending on your score scale. \$\endgroup\$ – MAnd Nov 25 '15 at 1:14
  • \$\begingroup\$ @MAnd Didn't even think of that at all. XD I will try that and get back as soon as possible. \$\endgroup\$ – Pixels_ Nov 25 '15 at 1:21
  • \$\begingroup\$ I will make it an answer with more details \$\endgroup\$ – MAnd Nov 25 '15 at 1:29
2
\$\begingroup\$

My suggestion may sound obvious, but why don't you try the following.

1) Save in a counter the time left when a player finishes the current level. Let's call it "time_left".

2) Set a loop that runs, for instance, every millisecond. At each iteration of that loop, you decrease X from "time_left".

3) At the same time, at each iteration you increase X*Y your score counter.

The trick here is only the values you will use for X and Y. The simplest way is to chose X=1, because then Y becomes merely the value you give as a score-give per each millisecond, depending on your score scale. Of course, if the loop at step 2 runs for every each millisecond, then Y probably should probably be a small float number.

I never worked with GameMaker, so I don't know its language. In C#, you could easily accomplish that with a Couroutine that at the end, yields a "wait for seconds". But if you have a problem making a loop run every given time (e.g. each millisecond or second or whatever) in your language and also wants the counting to be slower so the player can see it, you can also try just decreasing X from the "time_left" counter and increasing X times Y to the score counter, every frame*delta.Time.

It's a simple solution, but that can work pretty well depending on what you want.

PS: in case you don't know what I mean by delta.Time, it is a measure of how much time has elapsed since the last frame was ended and the current began.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.