class Window_Command < Window_Selectable
attr_reader :commands
end
# define a Scene
class Scene_PokeGear
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# here comes the code to initialize the objects
# for example the command_window, help_window, background and the cursor
# create the commands
s1 = "Time"
s2 = "Map"
s3 = "Radio"
s4 = "Phone"
s5 = "Exit"
commands = [s1,s2,s3,s4,s5]
# create a command window (vertical)
@command_window = Window_Command.new(132, commands)
@command_window.z = 3
# create a help window to display text
@help_window = Window_Help.new
# set the width and height
@help_window.width = 156
@help_window.height = 64
# set the x, y and z values
@help_window.x = $width - @help_window.width
@help_window.y = $height - @help_window.height
@help_window.z = 3
# set no text
@help_window.set_text("")
# create a sprite
@background = Sprite.new
# create a bitmap
@background.bitmap = RPG::Cache.picture("background")
# give the bitmap a position by the x and y value
@background.x, @background.y = 0, 0
# make the background double size
@background.zoom_x, @background.zoom_y = 2,2
# give the bitmap a layer
@background.z = 0
# now we do the same for the cursor
# this cursor is for the region-map
@cursor = Sprite.new
@cursor.bitmap = RPG::Cache.picture("arrow_1")
@cursor.x, @cursor.y = 100, 100
# make the cursor double size
@cursor.zoom_x, @cursor.zoom_y = 2,2
@cursor.visible = false
# make the layer 1 so it's above the background
@cursor.z = 9
# Window for the cursor display
@window = Window_Base.new(100, 100, 128, 128)
@window.z = 8
@window.visible = false
# Transition run
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# dispose content
@command_window.dispose
@help_window.dispose
@background.dispose
@cursor.dispose
@window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# update content
@command_window.update
@help_window.update
@background.update
@cursor.update
@window.update
# call update_command when command_window is active
if @command_window.active
update_command
return
end
# check if the cursor is on the map
# and check if the command_window is not active
# then call the method update_cursor
if @command_window.index == 1 && !@command_window.active
update_cursor
update_text
return
end
end
#--------------------------------------------------------------------------
# * Update Command
#--------------------------------------------------------------------------
def update_command
if Input.trigger?(Input::B)
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
case @command_window.commands[@command_window.index]
when "Time"
when "Map"
update_cursor
when "Radio"
when "Phone"
when "Exit"
$scene = Scene_Map.new
end
return
end
end
#--------------------------------------------------------------------------
# * Update Map(Region) Cursor
#--------------------------------------------------------------------------
def update_cursor
@cursor.visible = true
@window.visible = true
@command_window.active = false
# define variables for min/max position of the cursor,
# so it can't leave the screen.
min_x = 100
max_x = 200
min_y = 100
max_y = 200
# return to the command_window if press cancel button
if Input.trigger?(Input::B)
@command_window.active = true
@cursor.visible = false
@window.visible = false
end
# press Shift key to check x and y spots
if Input.trigger?(Input::SHIFT)
print "X: #{@cursor.x} , Y: #{@cursor.y}"
end
# if press right and the cursor x is smaller then max_x,
# move the cursor right
if Input.press?(Input::RIGHT) and @cursor.x < max_x
@cursor.x += 2
end
# if press left and the cursor x is bigger then min_x,
# move the cursor left
if Input.press?(Input::LEFT) and @cursor.x > min_x
@cursor.x -= 2
end
# if press down and the cursor y is smaller then max_y,
# move the cursor down
if Input.press?(Input::DOWN) and @cursor.y < max_y
@cursor.y += 2
end
# if press up and the cursor y is bigger then min_y,
# move the cursor up
if Input.press?(Input::UP) and @cursor.y > min_y
@cursor.y -= 2
end
end
#--------------------------------------------------------------------------
# * Update Text
#--------------------------------------------------------------------------
def update_text
# if the cursor is between the values, display the text
if @cursor.x.between?(100, 120) && @cursor.y.between?(100, 120)
@help_window.set_text("Left-Up")
elsif @cursor.x.between?(190, 200) && @cursor.y.between?(100, 120)
@help_window.set_text("Right-Up")
elsif @cursor.x.between?(100, 120) && @cursor.y.between?(190, 200)
@help_window.set_text("Left-Down")
elsif @cursor.x.between?(190, 200) && @cursor.y.between?(190, 200)
@help_window.set_text("Right-Down")
elsif @cursor.x.between?(140, 160) && @cursor.y.between?(140, 160)
@help_window.set_text("Middle")
elsif @cursor.x.between?(190, 200) && @cursor.y.between?(110, 190)
@help_window.set_text("Right")
elsif @cursor.x.between?(100, 110) && @cursor.y.between?(110, 190)
@help_window.set_text("Left")
elsif @cursor.x.between?(110, 190) && @cursor.y.between?(100, 110)
@help_window.set_text("Up")
elsif @cursor.x.between?(110, 190) && @cursor.y.between?(190, 200)
@help_window.set_text("Down")
else
@help_window.set_text("")
end
end
end