game.loading do |loader|
loader.add :window, :system => "window"
loader.add :gui_item, :system => "gui_item"
loader.add :human_image, 8
end
# ゲームの初期化
game.on_init do
set_window_image :window
set_gui_image :gui_item
# オープニングのシーンへ
scene_change :start_scene
end
scene :start_scene do |scene|
scene.on_init do
scene.add :image, :template => :human, :center_position => [16, 24]
end
end
sprite_template :human do |st|
st.texture :human_image
st.src_size 32, 32
st.dest_size 32, 32
st.center_offset 32/2, 32/2
st.motion :default do |commands|
commands.loop true
commands.proc_call do |sprite|
sprite.change_animation :down
end
commands.move_to_v 0, 418, 4
commands.wait_motion
commands.proc_call do |sprite|
sprite.change_animation :right
end
commands.move_to_v 768, 418, 4
commands.wait_motion
commands.proc_call do |sprite|
sprite.change_animation :up
end
commands.move_to_v 768, 0, 4
commands.wait_motion
commands.proc_call do |sprite|
sprite.change_animation :left
end
commands.move_to_v 0, 0, 4
commands.wait_motion
end
st.animation :down do |commands|
commands.loop true
commands.copy_rect :frame => 16, :src => [0, 0]
commands.wait_animation
commands.copy_rect :frame => 16, :src => [1, 0]
commands.wait_animation
end
st.animation :up do |commands|
commands.loop true
commands.copy_rect :frame => 16, :src => [0, 3]
commands.wait_animation
commands.copy_rect :frame => 16, :src => [1, 3]
commands.wait_animation
end
st.animation :left do |commands|
commands.loop true
commands.copy_rect :frame => 16, :src => [0, 1]
commands.wait_animation
commands.copy_rect :frame => 16, :src => [1, 1]
commands.wait_animation
end
st.animation :right do |commands|
commands.loop true
commands.copy_rect :frame => 16, :src => [0, 2]
commands.wait_animation
commands.copy_rect :frame => 16, :src => [1, 2]
commands.wait_animation
end
end