Changeset 13583

Show
Ignore:
Timestamp:
06/09/08 15:55:30 (5 years ago)
Author:
gan2
Message:

家が建つのに少し間を持たせるようにした
複数のキャラが同座標にいるときは合体して1つになるようにした など

Location:
lang/ruby/RogueLike/rogue_like
Files:
1 added
5 modified

Legend:

Unmodified
Added
Removed
  • lang/ruby/RogueLike/rogue_like/chara.rb

    r13479 r13583  
    33module RogueLike 
    44  class Chara 
    5     attr_accessor :map_x, :map_y, :mode, :walk_pathes 
     5    attr_accessor :map_x, :map_y, :mode, :walk_pathes, :strength 
    66 
    77    def initialize(map_x, map_y) 
     
    1010      @mode        = :waiting 
    1111      @walk_pathes = [] 
    12       @strength    = 1 
     12      @strength    = 5 
    1313    end 
    1414 
  • lang/ruby/RogueLike/rogue_like/config.rb

    r13479 r13583  
    2727  GAME_TITLE   = 'Rogue Like' 
    2828 
    29   INIT_CHARA_NUM = 4 
     29  INIT_CHARA_NUM = 8 
    3030 
    3131  # g_random_int_range と同じ 
  • lang/ruby/RogueLike/rogue_like/map.rb

    r13479 r13583  
    1818 
    1919    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 
     20      map_x = (x - MAP_WINDOW_X) / CELL_W 
     21      map_y = (y - MAP_WINDOW_Y) / CELL_H 
     22      @left_click_cell = @data[map_y][map_x] 
    2523    end 
    2624     
  • lang/ruby/RogueLike/rogue_like/model.rb

    r13479 r13583  
    44require 'rogue_like/couple' 
    55require 'rogue_like/chara' 
     6require 'rogue_like/home' 
    67require 'rogue_like/astar' 
    78require 'rogue_like/bstar' 
     
    2425      @debug_mode = nil 
    2526      @wp         = Workpile.new # ブロックを受け取りその実行を別スレッドに委託する 
     27      @home_map   = Array.new(MAP_H) { Array.new(MAP_W) { nil } } 
    2628      make_map 
    2729      make_charas 
     
    5759        @charas << Chara.new(x, y) 
    5860      end 
    59     end 
    60      
     61      @select_chara = nil 
     62    end 
     63 
    6164    # 区画を分割できなくなるまで分割する 
    6265    def split_rect(parent) 
     
    173176          if chara.walk_pathes.size > 0 
    174177            chara.walk 
     178            if @charas.select {|c| c.x == chara.x and c.y == chara.y }.size > 1 
     179              @charas.delete(chara) 
     180              chara2 = @charas.find {|chara2| chara2.x == chara.x and chara2.y == chara.y } 
     181              chara.strength += chara2.strength 
     182              @charas.delete(chara2) 
     183              @charas << chara 
     184            end 
    175185          else 
    176186            if @map.data[chara.map_y][chara.map_x] == :room 
     
    181191          end 
    182192        when :building 
    183           @map.data[chara.map_y][chara.map_x] = :home 
    184           @map.draw_position(chara.map_x, chara.map_y) 
    185           chara.mode = :waiting 
    186         end 
     193          x = chara.map_x 
     194          y = chara.map_y 
     195          if @map.data[y][x] == :room 
     196            @map.data[y][x] = :pre_home 
     197            @home_map[y][x] = Home.new(x, y) 
     198          else 
     199            @home_map[y][x].strength += chara.strength 
     200            if @home_map[y][x].strength >= 50 
     201              @map.data[y][x] = :home 
     202              @map.draw_position(x, y) 
     203              chara.mode = :waiting 
     204            end 
     205          end 
     206        end 
     207      end 
     208    end 
     209 
     210    def left_click(x, y) 
     211      if @map.in?(x, y) 
     212        @select_chara = @charas.find {|chara| x == chara.x and y == chara.y } 
     213        @map.left_click(x, y) unless @select_chara 
     214        p @select_chara 
    187215      end 
    188216    end 
  • lang/ruby/RogueLike/rogue_like/view.rb

    r13479 r13583  
    1919        :road          => Texture.load('images/road'), 
    2020        :chara         => Texture.load('images/chara'), 
     21        :pre_home      => Texture.load('images/room'), 
    2122        :home          => Texture.load('images/home'), 
    2223        :position      => Texture.load('images/position'),