[RM2K3] METER GAUGE?

Posts

Pages: 1
Greetings RMN, I want to have my character run, but however I want to place a limit on how long they can run for, I'm wondering if it's possible to add a gauge/meter to show how much stamina a character have behind getting tired and go back to walking speed.
-First make a variable called Stamina set it to 100 at start
-When pressing down on the key make it so it that it subtracts by 1 or however much you want
-If Stamina is 0 the speed decreases (Might need to make a switch so the character speed isn't constantly decreasing) and it stops subtracting by 1
-If key isn't being pressed (else case) add 1 to it and stops if it reaches 100 (This is for recovering stamina)

That'll basically work on its own without any visual to speak of. But for a visual for that...

-You'll need to use the Show Picture command to show the actual meter
-Make 10 different images that show the meter decresing from 100% to 0% in 10% increments (actually 1 extra for the 0%)
-If you have the official rm2k3, there's a handy pic pointer variable setting you can use to determine which of the images get shown with the Replace last x characters with value of variable to make it easier. (There are other dirty methods to accomplish it if you don't have official rm2k3 though. So basically make sure the file names are named something like StaminaMeter00... to StaminaMeter10 and set the replace last with 2 in the show picture command. Set a variable called StaminaMeter
-Make a seperate parralel process common event with a single show picture command. Have a series of conditional branches going If Stamina is lower or equal to 100 then set StaminaMeter to 10, If Stamina is lower or equal to 90 then set StaminaMeter to 9... etc. There's a way to automate this but it involves loops and additional variables that's hard to explain, but for now 10 or so copy pasted condtional branches ain't too bad.
-You might want a StaminaMax variable if you don't always want it to be at 100 or want to upgrade it later on in the game.

Let me know if you need anything elaborated.
There are two ways to do this.

If you have the most recent English version of rm2k3, you can show images by variable reference. So make images of every level of the gauge (say 20 of them) and then show the appropriate image. Something like the following (not exact code):

TempVariable = CurrentStamina
TempVariable * 20 <-- use however many images you have here
TempVariable / MaximumStamina
Show Image StaminaMeter_0000 using TempVariable as the variable reference

The other option is to place your stamina meter on a screen edge and then as your stamina drops, have it move off screen. We create the TempVariable similarly, except because we only need a single image for this (the image of the full bar), we can have it move pixel by pixel.

TempVariable = CurrentStamina
TempVariable * 20 <-- use the width of the full StaminaMeter, in pixels
TempVariable / MaximumStamina
Show Image FullStaminaMeter where x = TempVariable and y = whatever you want

Place which ever code you use in a common event, and then call that event when needed. I would not call it on parallel process, but you could call it at the end of the parallel process event which slowly refills the stamina gauge when you're not running (assuming you have such a mechanic).
Yeah Hedge1's method is better, I got mixed up with the old methods realizing both the math and the show picture doesn't need to go through manual branching.
author=Darken
if you don't have official rm2k3 though.

I don't :[

author=hedge1
There are two ways to do this.

If you have the most recent English version of rm2k3, you can show images by variable reference. So make images of every level of the gauge (say 20 of them) and then show the appropriate image. Something like the following (not exact code):

TempVariable = CurrentStamina
TempVariable * 20 <-- use however many images you have here
TempVariable / MaximumStamina
Show Image StaminaMeter_0000 using TempVariable as the variable reference

The other option is to place your stamina meter on a screen edge and then as your stamina drops, have it move off screen. We create the TempVariable similarly, except because we only need a single image for this (the image of the full bar), we can have it move pixel by pixel.

TempVariable = CurrentStamina
TempVariable * 20 <-- use the width of the full StaminaMeter, in pixels
TempVariable / MaximumStamina
Show Image FullStaminaMeter where x = TempVariable and y = whatever you want

Place which ever code you use in a common event, and then call that event when needed. I would not call it on parallel process, but you could call it at the end of the parallel process event which slowly refills the stamina gauge when you're not running (assuming you have such a mechanic).

Sadly I am a god damn cheapskate and I only downloaded the non-official product (Mods forgive me)

Hopefully It'll will work, thanks for the advice guys.
It's really not that bad without picPointer (lord help you if you're doing digits). But basically you need to make multiple show picture commands for each conditional branch checking each increment, somewhat like the method I described. Use hedge1's math to convert a raw value into a 1-100 percentage though.

author=Quadroline
Sadly I am a god damn cheapskate and I only downloaded the non-official product (Mods forgive me)

Do not worry, all of us are infected with this sin.
author=Darken
lord help you if you're doing digits


...I barely passed Pre-Algebra... >_>'
Pages: 1