MasterMind
Member
I am in the midst of making my custom movement system. I have a few more issues to deal with, so bear with me. I'll just post the code, and then explain.
I'm having a hard time understanding this part:
I was looking around at how to display a variable in-game, and came across a topic that said to do that. I was wondering how I could make that go away/make more efficient.
In here is my major dilemma. I'm trying to make it so that the system subtracts one point for every step taken. Right now, it takes away 1, then, 2, and then 3, and so on, even into the negatives.
If any could give me some pointers, thank you.
Code:
#==============================================================================
# ** Movement System
#------------------------------------------------------------------------------
#
#==============================================================================
MOVEMENT_POINTS = 10
POINTS_PER_MOVE = 1
class Game_Party
alias mvment_initialize initialize
def initialize
$movement_points = MOVEMENT_POINTS
mvment_initialize
end
end
class Window_Movement < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 96)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
refresh
end
def draw_movepoints(x, y)
points = RPG::Cache.picture("")
src_rect = Rect.new(0, 0, width, height)
self.contents.blt(x, y, points, src_rect)
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
draw_movepoints(0, 0)
self.contents.font.color = Color.new(255, 0, 0)
self.contents.font.name = "Brush Script Std"
self.contents.font.size = 42
self.contents.draw_text(60, 6, 64, 32,$movement_points.to_s, 2)
end
def update
refresh
end
end
class Scene_Map
alias mvment_main main
alias mvment_update update
alias mvment_call_battle call_battle
def main
@window_movement = Window_Movement.new
@event_picture = Sprite.new
@event_picture.bitmap = RPG::Cache.picture("ENCOUNTER")
@event_picture.visible = false
@event_picture.z = 5
mvment_main
@window_movement.dispose
@event_picture.dispose
end
def update
@window_movement.update
@event_picture.x = $game_player.screen_x
@event_picture.y = $game_player.screen_y - 56
@event_picture.update
mvment_update
end
end
class Scene_Battle
alias mvment_start_phase5 start_phase5
def start_phase5
$movement_points += 1
mvment_start_phase5
end
end
class Game_Character
alias mvment_move_down move_down
alias mvment_move_left move_left
alias mvment_move_right move_right
alias mvment_move_up move_up
#--------------------------------------------------------------------------
# * Move Down
# turn_enabled : a flag permits direction change on that spot
#--------------------------------------------------------------------------
def move_down(turn_enabled = true)
$movement_points -= 1
mvment_move_down
end
#--------------------------------------------------------------------------
# * Move Left
# turn_enabled : a flag permits direction change on that spot
#--------------------------------------------------------------------------
def move_left(turn_enabled = true)
$movement_points -= 1
mvment_move_left
end
#--------------------------------------------------------------------------
# * Move Right
# turn_enabled : a flag permits direction change on that spot
#--------------------------------------------------------------------------
def move_right(turn_enabled = true)
$movement_points -= 1
mvment_move_right
end
#--------------------------------------------------------------------------
# * Move up
# turn_enabled : a flag permits direction change on that spot
#--------------------------------------------------------------------------
def move_up(turn_enabled = true)
$movement_points -= 1
mvment_move_up
end
end
I'm having a hard time understanding this part:
Code:
def update
refresh
end
I was looking around at how to display a variable in-game, and came across a topic that said to do that. I was wondering how I could make that go away/make more efficient.
Code:
class Game_Character
alias mvment_move_down move_down
alias mvment_move_left move_left
alias mvment_move_right move_right
alias mvment_move_up move_up
#--------------------------------------------------------------------------
# * Move Down
# turn_enabled : a flag permits direction change on that spot
#--------------------------------------------------------------------------
def move_down(turn_enabled = true)
$movement_points -= 1
mvment_move_down
end
#--------------------------------------------------------------------------
# * Move Left
# turn_enabled : a flag permits direction change on that spot
#--------------------------------------------------------------------------
def move_left(turn_enabled = true)
$movement_points -= 1
mvment_move_left
end
#--------------------------------------------------------------------------
# * Move Right
# turn_enabled : a flag permits direction change on that spot
#--------------------------------------------------------------------------
def move_right(turn_enabled = true)
$movement_points -= 1
mvment_move_right
end
#--------------------------------------------------------------------------
# * Move up
# turn_enabled : a flag permits direction change on that spot
#--------------------------------------------------------------------------
def move_up(turn_enabled = true)
$movement_points -= 1
mvment_move_up
end
end
In here is my major dilemma. I'm trying to make it so that the system subtracts one point for every step taken. Right now, it takes away 1, then, 2, and then 3, and so on, even into the negatives.
If any could give me some pointers, thank you.