DnD simple number counter?

I

id07

Guest
I was working on a really small game where I have multiple functions activate when you click on a specific object with a mouse. And I wanted to have 2 separate objects that when you click on one of them, it shows (draws) integers/numbers count upwards on screen.
I managed to do this with the "set score" and "draw" event, but I can't seem to do it a second time using that same route, as you can't separate the score function 2 be two score functions.

So essentially, two number counters that when you push on an object, it visibly counts upward.

is there way to do what I stated using DnD?

Any help would be appreciated! Thanks!
 
K

Kuro

Guest
Which version of Gamemaker are you using? My DnD is rusty, but here goes.

  • In the create event of your object create a variable called "MyCounter" value 0 (or 1, or whatever value you want your counter to start at).
  • In the create event of your object create a variable called "CountDown" and set it to false. (this will act as a trigger)
  • In the left pressed mouse event of your object set the variable called "CountDown" to true. (this is like pulling trigger)
  • In the step event use the If statement to check if CountDown is true, and if so set the "MyCounter" variable to 1 and check the relative box. The result of this is that:
    • "My counter" is going up by 1 every step, so if your room speed is set to 30 it will increase by 30 every second. If your room speed is 60 it will increase by 60 every second.
  • There's a draw variable DnD thingy, so now that you have a variable counting up you can use it in much the same way as you are already using set score. Just ensure you do your drawing in the draw event.

If ever you want it to stop, set "CountDown" to false again. (you'll have to manually reset MyCounter to 0 though.) If you need more specifics, let me know which version of gamemaker you're using.
 
I

id07

Guest
Thank you for the reply! I am using game maker 8 (is it different from game maker studio the free version with the drag and drop? Would it be easier in the free version?)

I've been attempting to figure out several ways to do what I was trying to do this whole time, but have come to the conclusion that i dont know what im doing :p

So I have two objects, one is a button you click (the trigger to count upwards) and the other is the number counter (the drawing number counter on screen). Coming back to see what you said, I don't know where to place these variables and creations under between these two objects. I tried doing like the score object/draw score object, but I'm clearly getting it wrong.

When you say false, is that the "NOT" box?

I'll keep trying to figure this out - any further explanation of what im doing wrong would be greatly appreciated :D
 
Top