Changeset 13479
- Timestamp:
- 06/08/08 16:39:15 (5 years ago)
- Location:
- lang/ruby/RogueLike/rogue_like
- Files:
-
- 6 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/ruby/RogueLike/rogue_like/chara.rb
r12627 r13479 6 6 7 7 def initialize(map_x, map_y) 8 @map_x = map_x9 @map_y = map_y10 @mode = :waiting8 @map_x = map_x 9 @map_y = map_y 10 @mode = :waiting 11 11 @walk_pathes = [] 12 @strength = 1 12 13 end 13 14 … … 16 17 end 17 18 18 def set_map_pos(m x, my)19 @map_x, @map_y = m x, my19 def set_map_pos(map_x, map_y) 20 @map_x, @map_y = map_x, map_y 20 21 end 21 22 … … 33 34 34 35 def x=(val) 35 @ x = val / CELL_W36 @map_x = val / CELL_W 36 37 end 37 38 38 39 def y=(val) 39 @ y = val / CELL_H40 @map_y = val / CELL_H 40 41 end 41 42 end -
lang/ruby/RogueLike/rogue_like/config.rb
r13281 r13479 17 17 MIN_RECT_SIZE = MIN_ROOM_SIZE + MARGIN_BETWEEN_RECT_AND_ROOM * 2 18 18 19 SCREEN_W = MAP_WINDOW_W + CELL_W * 2 20 SCREEN_H = MAP_WINDOW_H + CELL_H * 2 19 STATUS_WINDOW_W = CELL_W * 16 20 STATUS_WINDOW_H = CELL_H * 16 21 STATUS_WINDOW_X = MAP_WINDOW_X + MAP_WINDOW_W + CELL_W 22 STATUS_WINDOW_Y = CELL_H 23 24 SCREEN_W = MAP_WINDOW_W + STATUS_WINDOW_W + CELL_W * 3 25 SCREEN_H = MAP_WINDOW_H + CELL_H * 2 21 26 WINDOW_SCALE = 1 22 GAME_TITLE = 'Rogue Like'27 GAME_TITLE = 'Rogue Like' 23 28 24 29 INIT_CHARA_NUM = 4 -
lang/ruby/RogueLike/rogue_like/controller.rb
r13074 r13479 23 23 24 24 def update_playing(model) 25 if Input.triggers(:keyboard).include?(:r) 25 if Input.triggers(:keyboard).include?(:r) # restart 26 26 update_start(model) 27 elsif Input.triggers(:keyboard).include?(:d) 27 elsif Input.triggers(:keyboard).include?(:d) # debug 28 28 model.toggle_debug_mode 29 # elsif Input.repeatings(:mouse).include?(:left) 30 # 29 elsif Input.triggers(:keyboard).include?(:p) # pause 30 31 elsif Input.triggers(:mouse).include?(:left) 32 x, y = Input.mouse_location 33 model.map.left_click(x, y) 31 34 end 32 35 model.activate_charas -
lang/ruby/RogueLike/rogue_like/map.rb
r13281 r13479 2 2 class Map 3 3 attr_accessor :data 4 attr_reader :walk_map 4 attr_reader :walk_map, :left_click_cell 5 5 6 6 def initialize … … 9 9 @walkable_poses = nil # 歩行可能な座標を要素に持つ 10 10 @buildable_poses = nil # 建築可能な座標を要素に持つ 11 @left_click_cell = nil 11 12 end 12 13 … … 14 15 (MAP_WINDOW_X <= x and x <= MAP_WINDOW_X + MAP_WINDOW_W ) and 15 16 (MAP_WINDOW_Y <= y and y <= MAP_WINDOW_Y + MAP_WINDOW_H) 17 end 18 19 def left_click(x, y) 20 if in?(x, y) 21 map_x = (x - MAP_WINDOW_X) / CELL_W 22 map_y = (y - MAP_WINDOW_Y) / CELL_H 23 @left_click_cell = @data[map_y][map_x] 24 end 16 25 end 17 26 -
lang/ruby/RogueLike/rogue_like/model.rb
r13281 r13479 158 158 def activate_charas 159 159 @charas.each_with_index do |chara, idx| 160 p chara.mode161 160 case chara.mode 162 161 when :waiting … … 164 163 @wp.push do 165 164 start = chara.get_map_pos 165 # このやり方だと別々の AI がかたまって同じ行動をするようになるので 166 # 向かう場所の探索と経路の探索は別々にした方がよさそう 166 167 bss = BStar::Searcher.new(@map.data, start, :room) 167 168 chara.walk_pathes = bss.search -
lang/ruby/RogueLike/rogue_like/view.rb
r13281 r13479 13 13 def initialize 14 14 @textures = { 15 :cursor => Texture.load('images/cursor'), 16 :wall => Texture.load('images/wall'), 17 :rect => Texture.load('images/rect'), 18 :room => Texture.load('images/room'), 19 :road => Texture.load('images/road'), 20 :chara => Texture.load('images/chara'), 21 :home => Texture.load('images/home'), 22 :position => Texture.load('images/position'), 23 :map_window => Texture.new(MAP_WINDOW_W, MAP_WINDOW_H), 24 :pause_info => Texture.new(SCREEN_W, SCREEN_H), 15 :cursor => Texture.load('images/cursor'), 16 :wall => Texture.load('images/wall'), 17 :rect => Texture.load('images/rect'), 18 :room => Texture.load('images/room'), 19 :road => Texture.load('images/road'), 20 :chara => Texture.load('images/chara'), 21 :home => Texture.load('images/home'), 22 :position => Texture.load('images/position'), 23 :map_window => Texture.new(MAP_WINDOW_W, MAP_WINDOW_H), 24 :status_window => Texture.new(STATUS_WINDOW_W, STATUS_WINDOW_H), 25 :pause_info => Texture.new(SCREEN_W, SCREEN_H), 25 26 } 26 27 @font = Font.new('fonts/ORANGEKI', FONT_SIZE) … … 42 43 43 44 if [:playing].include?(model.state) 45 # マップ 44 46 window = @textures[:map_window] 45 47 model.map.data.each_with_index do |row, y| … … 53 55 end 54 56 55 # 繧ォ繝シ繧ス繝ォ縺ョ謠冗判57 # カーソル 56 58 x, y = Input.mouse_location 57 59 if model.map.in?(x, y) … … 60 62 window.render_texture(@textures[:cursor], x, y) 61 63 end 64 65 # ステータス 66 window = @textures[:status_window] 67 bg_color = Color.new(55, 55, 55) 68 window.fill_rect(0, 0, STATUS_WINDOW_W, STATUS_WINDOW_H, bg_color) 69 if select_image = @textures[model.map.left_click_cell] 70 window.render_texture(select_image, CELL_W, CELL_H, :scale_x => 2, :scale_y => 2) 71 end 62 72 end 63 73 64 74 screen.clear 65 75 screen.render_texture(@textures[:map_window], MAP_WINDOW_X, MAP_WINDOW_Y) 76 screen.render_texture(@textures[:status_window], STATUS_WINDOW_X, STATUS_WINDOW_Y) 66 77 67 78 case model.state
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)