Hi all. I'm new at RGSS scripting and am trying to make a meter that constantly loops and will go "up" for every second the player does not move. This meter is created by drawing part or all of a meter image file loaded into a dummy variable (@@bar).
The value in $game_variables[3] determines how high to draw the meter. It is called through Script: RLS_Meter.new. I want it so that it will increase ($game_variables[3] increases) while the player does nothing, and reset to 1 if the player moves. As you'll notice, I haven't yet set up what happens when it reaches the top, so you can leave that blank for now.
Thanks for any help in advance.
Code:
class RLS_Meter < Sprite
def initialize
super
@@bar = Sprite.new
@@bar.bitmap = RPG::Cache.picture("meter.png")
self.bitmap = Bitmap.new(22, 125)
self.x = 600
self.y = 25
self.z = 9999
@@bar.visible = false
self.visible = false
@upper_bound = @@bar.bitmap.height
update
end
def main
update
end
def dispose
self.bitmap.dispose
@@bar.bitmap.dispose
super
end
def update
super
self.visible = true
@upper_bound = $game_variables[3]
@pointer = @@bar.bitmap.height
if $game_variables[3] != 0
# Loops through bitmap vertically until cutoff
while @pointer >= @upper_bound
# Loops through bitmap horizontally setting pixels
@py = @pointer
for @px in 0...21
@color = @@bar.bitmap.get_pixel(@px, @py)
self.bitmap.set_pixel(@px, @py, @color)
end
@pointer -= 1
end
else
self.bitmap.clear
end
end
end
The value in $game_variables[3] determines how high to draw the meter. It is called through Script: RLS_Meter.new. I want it so that it will increase ($game_variables[3] increases) while the player does nothing, and reset to 1 if the player moves. As you'll notice, I haven't yet set up what happens when it reaches the top, so you can leave that blank for now.
Thanks for any help in advance.