実験 800x450 公開中

マップ描画のテスト

投稿者:akasata 投稿日時: 2013/08/30 16:15:16
マップチップ描画のテストです。
RmakeCommonSpriteクラスのset_rectsメソッドを使っています。
閲覧: 148 評価: 0
  • Starwhite
  • Starwhite
  • Starwhite
  • Starwhite
  • Starwhite
  • Starwhite
  • Starwhite
  • Starwhite
  • Starwhite
  • Starwhite
あなたはまだ評価していません。
game.loading do |loader| loader.add :window, :system => "window" loader.add :gui_item, :system => "gui_item" loader.add :nd3_image, 22 loader.add :mapchip, 192 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 speak("マップ描画のテストです。画面をタップすると終了します。") map_sprite = scene.add :image, :name => :map_sprite, :template => :map, :center_position => [400, 225] scene.add :image, :name => :nd3_sprite, :template => :nd3, :center_position => [48, 48] map_sprite.event :on_click do |event| speak("メニューに戻ります") game.change_project "start_menu" end end end sprite_template :map do |st| st.texture :mapchip st.dest_size 800, 448 st.center_offset 400, 224 st.animation :default do |commands| commands.proc_call do |sprite| dest_rects = [] 14.times do |j| 25.times do |i| dest_rects << -400 + 0 + i * 32 # x dest_rects << -224 + 0 + j * 32 # y dest_rects << 32 # w dest_rects << 32 # h end end colors = [] (25*14).times do colors << 255 # R colors << 255 # G colors << 255 # B colors << 255 # A end # 草原で塗りつぶす # 隣のチップを巻き込まないために元画像のサイズを1px小さく指定 # その際、0.5pxずらす src_rects = [] 14.times do |j| 25.times do |i| src_rects << 0.5 # x src_rects << 0.5 # y src_rects << 31 # w src_rects << 31 # h end end # 黄色い横一本道を10マスつける # マップエディタが欲しい(^^; 10.times do |i| src_rects[(25*1 + i + 3) * 4 + 0] = 32.5 # x src_rects[(25*1 + i + 3) * 4 + 1] = 0.5 # y src_rects[(25*1 + i + 3) * 4 + 2] = 31 # w src_rects[(25*1 + i + 3) * 4 + 3] = 31 # h end sprite.set_rects dest_rects, colors, src_rects end end end sprite_template :nd3 do |st| st.texture :nd3_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 32, 386, 4 commands.wait_motion commands.proc_call do |sprite| sprite.change_animation :right end commands.move_to_v 736, 386, 4 commands.wait_motion commands.proc_call do |sprite| sprite.change_animation :up end commands.move_to_v 736, 32, 4 commands.wait_motion commands.proc_call do |sprite| sprite.change_animation :left end commands.move_to_v 32, 32, 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
コード一覧
  • start.rb

コメントするには、ログインする必要があります。

コメント一覧
お知らせ

2014/03/04 ver. 0.1.39 を公開しました!
・0.1.36でWindowsで起動しない問題を修正しました
(Android版はバージョン番号のみの変更です。)

2014/03/04 ver. 0.1.36 を公開しました!
・アプリケーションアイコンを変更しました
・セーブ・ロードを繰り返すとアプリが強制終了する問題を修正しました
・他、重大なバグを修正しました

ダウンロードはこちらから。

2013/07/17 Code on Rmakeをα公開しました!