chichilku3 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/bin/chichilku3 +3 -0
 - data/bin/chichilku3-server +3 -0
 - data/client.json +6 -0
 - data/lib/client/chichilku3.rb +18 -0
 - data/lib/client/client.rb +289 -0
 - data/lib/client/client_cfg.rb +15 -0
 - data/lib/client/gui.rb +492 -0
 - data/lib/client/img/background1024x512.png +0 -0
 - data/lib/client/img/battle1024x576.png +0 -0
 - data/lib/client/img/connecting1024x512.png +0 -0
 - data/lib/client/img/grass1024x512.png +0 -0
 - data/lib/client/img/grey128.png +0 -0
 - data/lib/client/img/menu1920x1080.png +0 -0
 - data/lib/client/img/stick128/stick0.png +0 -0
 - data/lib/client/img/stick128/stick1.png +0 -0
 - data/lib/client/img/stick128/stick2.png +0 -0
 - data/lib/client/img/stick128/stick3.png +0 -0
 - data/lib/client/img/stick128/stick4.png +0 -0
 - data/lib/client/img/stick128/stick5.png +0 -0
 - data/lib/client/img/stick128/stick_crouching0.png +0 -0
 - data/lib/client/img/stick128/stick_crouching1.png +0 -0
 - data/lib/client/img/stick128/stick_crouching2.png +0 -0
 - data/lib/client/img/stick128/stick_crouching3.png +0 -0
 - data/lib/client/img/stick128/stick_crouching4.png +0 -0
 - data/lib/client/img/stick128/stick_crouching5.png +0 -0
 - data/lib/client/scoreboard.rb +25 -0
 - data/lib/client/test.rb +39 -0
 - data/lib/client/text.rb +86 -0
 - data/lib/server/chichilku3_server.rb +293 -0
 - data/lib/server/gamelogic.rb +121 -0
 - data/lib/server/server_cfg.rb +6 -0
 - data/lib/share/config.rb +53 -0
 - data/lib/share/console.rb +18 -0
 - data/lib/share/network.rb +145 -0
 - data/lib/share/player.rb +286 -0
 - data/server.json +4 -0
 - metadata +81 -0
 
    
        data/lib/share/player.rb
    ADDED
    
    | 
         @@ -0,0 +1,286 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Player used by Client and Server
         
     | 
| 
      
 2 
     | 
    
         
            +
            require_relative 'console'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require_relative 'network'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            SPAWN_X = 512
         
     | 
| 
      
 6 
     | 
    
         
            +
            SPAWN_Y = 100
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            class Player
         
     | 
| 
      
 9 
     | 
    
         
            +
              attr_accessor :x, :y, :dy, :dx, :id, :name, :score, :state, :dead, :dead_ticks, :was_crouching
         
     | 
| 
      
 10 
     | 
    
         
            +
              attr_reader :collide, :collide_str, :img_index, :version, :w, :h
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              def initialize(id, score, x = nil, y = nil, name = 'def', ip = nil)
         
     | 
| 
      
 13 
     | 
    
         
            +
                @id = id
         
     | 
| 
      
 14 
     | 
    
         
            +
                @x = x.nil? ? SPAWN_X : x
         
     | 
| 
      
 15 
     | 
    
         
            +
                @y = y.nil? ? SPAWN_Y : y
         
     | 
| 
      
 16 
     | 
    
         
            +
                @w = TILE_SIZE / 2
         
     | 
| 
      
 17 
     | 
    
         
            +
                @h = TILE_SIZE
         
     | 
| 
      
 18 
     | 
    
         
            +
                @dx = 0
         
     | 
| 
      
 19 
     | 
    
         
            +
                @dy = 0
         
     | 
| 
      
 20 
     | 
    
         
            +
                @collide = {up: false, down: false, right: false, left: false}
         
     | 
| 
      
 21 
     | 
    
         
            +
                @state = {bleeding: false, crouching: false}
         
     | 
| 
      
 22 
     | 
    
         
            +
                @was_crouching = false
         
     | 
| 
      
 23 
     | 
    
         
            +
                @name = name
         
     | 
| 
      
 24 
     | 
    
         
            +
                @score = score
         
     | 
| 
      
 25 
     | 
    
         
            +
                @dead = false # only used by server for now
         
     | 
| 
      
 26 
     | 
    
         
            +
                @dead_ticks = 0
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                # used by client
         
     | 
| 
      
 29 
     | 
    
         
            +
                @img_index = 0
         
     | 
| 
      
 30 
     | 
    
         
            +
                @last_x = 0
         
     | 
| 
      
 31 
     | 
    
         
            +
                @last_y = 0
         
     | 
| 
      
 32 
     | 
    
         
            +
                @tick = 0
         
     | 
| 
      
 33 
     | 
    
         
            +
                @not_changed_y = 0
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                # used by server
         
     | 
| 
      
 36 
     | 
    
         
            +
                @version = nil
         
     | 
| 
      
 37 
     | 
    
         
            +
                @ip = ip
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
              ###############
         
     | 
| 
      
 41 
     | 
    
         
            +
              # client only #
         
     | 
| 
      
 42 
     | 
    
         
            +
              ###############
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
              def draw_tick
         
     | 
| 
      
 45 
     | 
    
         
            +
                @tick += 1
         
     | 
| 
      
 46 
     | 
    
         
            +
                update_img
         
     | 
| 
      
 47 
     | 
    
         
            +
              end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
              def update_img
         
     | 
| 
      
 50 
     | 
    
         
            +
                return if @tick % 5 != 0
         
     | 
| 
      
 51 
     | 
    
         
            +
                if @x != @last_x
         
     | 
| 
      
 52 
     | 
    
         
            +
                  new_x = true
         
     | 
| 
      
 53 
     | 
    
         
            +
                end
         
     | 
| 
      
 54 
     | 
    
         
            +
                if @y != @last_y
         
     | 
| 
      
 55 
     | 
    
         
            +
                  new_y = true
         
     | 
| 
      
 56 
     | 
    
         
            +
                  @not_changed_y = 0
         
     | 
| 
      
 57 
     | 
    
         
            +
                else
         
     | 
| 
      
 58 
     | 
    
         
            +
                  @not_changed_y += 1
         
     | 
| 
      
 59 
     | 
    
         
            +
                end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                if new_x || new_y
         
     | 
| 
      
 62 
     | 
    
         
            +
                  @img_index += 1
         
     | 
| 
      
 63 
     | 
    
         
            +
                  @img_index = 0 if @img_index > 4
         
     | 
| 
      
 64 
     | 
    
         
            +
                  # $console.log "img updated to: #{@img_index}"
         
     | 
| 
      
 65 
     | 
    
         
            +
                end
         
     | 
| 
      
 66 
     | 
    
         
            +
                @last_x = @x
         
     | 
| 
      
 67 
     | 
    
         
            +
                @last_y = @y
         
     | 
| 
      
 68 
     | 
    
         
            +
                # if @not_changed_y > 10
         
     | 
| 
      
 69 
     | 
    
         
            +
                #   $console.log "player is chillin"
         
     | 
| 
      
 70 
     | 
    
         
            +
                #   @img_index = 5
         
     | 
| 
      
 71 
     | 
    
         
            +
                # end
         
     | 
| 
      
 72 
     | 
    
         
            +
              end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
              #####################
         
     | 
| 
      
 75 
     | 
    
         
            +
              # client and server #
         
     | 
| 
      
 76 
     | 
    
         
            +
              #####################
         
     | 
| 
      
 77 
     | 
    
         
            +
              def self.get_player_index_by_id(players, id)
         
     | 
| 
      
 78 
     | 
    
         
            +
                players.index(get_player_by_id(players, id))
         
     | 
| 
      
 79 
     | 
    
         
            +
              end
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
              def self.get_player_by_id(players, id)
         
     | 
| 
      
 82 
     | 
    
         
            +
                players.find { |player| id == player.id }
         
     | 
| 
      
 83 
     | 
    
         
            +
              end
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
              def self.update_player(players, id, x, y, score)
         
     | 
| 
      
 86 
     | 
    
         
            +
                player = get_player_by_id(players, id)
         
     | 
| 
      
 87 
     | 
    
         
            +
                player.x = x
         
     | 
| 
      
 88 
     | 
    
         
            +
                player.y = y
         
     | 
| 
      
 89 
     | 
    
         
            +
                player.score = score
         
     | 
| 
      
 90 
     | 
    
         
            +
                player
         
     | 
| 
      
 91 
     | 
    
         
            +
              end
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
              ###############
         
     | 
| 
      
 94 
     | 
    
         
            +
              # server only #
         
     | 
| 
      
 95 
     | 
    
         
            +
              ###############
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
              def set_version(version)
         
     | 
| 
      
 98 
     | 
    
         
            +
                @version = version
         
     | 
| 
      
 99 
     | 
    
         
            +
              end
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
              def tick
         
     | 
| 
      
 102 
     | 
    
         
            +
                move_x(@dx)
         
     | 
| 
      
 103 
     | 
    
         
            +
                move_y(@dy)
         
     | 
| 
      
 104 
     | 
    
         
            +
                @dx = normalize_zero(@dx)
         
     | 
| 
      
 105 
     | 
    
         
            +
                @dy = normalize_zero(@dy)
         
     | 
| 
      
 106 
     | 
    
         
            +
                check_out_of_world
         
     | 
| 
      
 107 
     | 
    
         
            +
              end
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
              def check_player_collide(other)
         
     | 
| 
      
 110 
     | 
    
         
            +
                # $console.log "x: #{@x} y: #{@y} ox: #{other.x} oy: #{other.y}"
         
     | 
| 
      
 111 
     | 
    
         
            +
                # x crash is more rare so make it the outer condition
         
     | 
| 
      
 112 
     | 
    
         
            +
                if other.x + other.w > @x && other.x < @x + @w
         
     | 
| 
      
 113 
     | 
    
         
            +
                  if other.y + other.h > @y && other.y < @y + @h
         
     | 
| 
      
 114 
     | 
    
         
            +
                    # $console.log "collide!"
         
     | 
| 
      
 115 
     | 
    
         
            +
                    return @x < other.x ? -7 : 7
         
     | 
| 
      
 116 
     | 
    
         
            +
                  end
         
     | 
| 
      
 117 
     | 
    
         
            +
                end
         
     | 
| 
      
 118 
     | 
    
         
            +
                return 0
         
     | 
| 
      
 119 
     | 
    
         
            +
              end
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
              # def check_out_of_world #die
         
     | 
| 
      
 122 
     | 
    
         
            +
              #   # y
         
     | 
| 
      
 123 
     | 
    
         
            +
              #   if @y < 0
         
     | 
| 
      
 124 
     | 
    
         
            +
              #     die
         
     | 
| 
      
 125 
     | 
    
         
            +
              #   elsif @y > WINDOW_SIZE_Y
         
     | 
| 
      
 126 
     | 
    
         
            +
              #     die
         
     | 
| 
      
 127 
     | 
    
         
            +
              #   end
         
     | 
| 
      
 128 
     | 
    
         
            +
              #   # x ( comment me out to add the glitch feature agian )
         
     | 
| 
      
 129 
     | 
    
         
            +
              #   if @x < 0
         
     | 
| 
      
 130 
     | 
    
         
            +
              #     die
         
     | 
| 
      
 131 
     | 
    
         
            +
              #   elsif @x > WINDOW_SIZE_X - TILE_SIZE - 1
         
     | 
| 
      
 132 
     | 
    
         
            +
              #     die
         
     | 
| 
      
 133 
     | 
    
         
            +
              #   end
         
     | 
| 
      
 134 
     | 
    
         
            +
              # end
         
     | 
| 
      
 135 
     | 
    
         
            +
              def check_out_of_world # swap size
         
     | 
| 
      
 136 
     | 
    
         
            +
                # y
         
     | 
| 
      
 137 
     | 
    
         
            +
                if @y < 0
         
     | 
| 
      
 138 
     | 
    
         
            +
                  die
         
     | 
| 
      
 139 
     | 
    
         
            +
                elsif @y > WINDOW_SIZE_Y
         
     | 
| 
      
 140 
     | 
    
         
            +
                  die
         
     | 
| 
      
 141 
     | 
    
         
            +
                end
         
     | 
| 
      
 142 
     | 
    
         
            +
                # x ( comment me out to add the glitch feature agian )
         
     | 
| 
      
 143 
     | 
    
         
            +
                if @x < 0
         
     | 
| 
      
 144 
     | 
    
         
            +
                  @x = WINDOW_SIZE_X - @w - 2
         
     | 
| 
      
 145 
     | 
    
         
            +
                elsif @x > WINDOW_SIZE_X - @w - 1
         
     | 
| 
      
 146 
     | 
    
         
            +
                  @x = 0
         
     | 
| 
      
 147 
     | 
    
         
            +
                end
         
     | 
| 
      
 148 
     | 
    
         
            +
              end
         
     | 
| 
      
 149 
     | 
    
         
            +
             
     | 
| 
      
 150 
     | 
    
         
            +
              def die
         
     | 
| 
      
 151 
     | 
    
         
            +
                $console.log("[death] id=#{@id} name='#{@name}'")
         
     | 
| 
      
 152 
     | 
    
         
            +
                @x = SPAWN_X
         
     | 
| 
      
 153 
     | 
    
         
            +
                @y = SPAWN_Y
         
     | 
| 
      
 154 
     | 
    
         
            +
              end
         
     | 
| 
      
 155 
     | 
    
         
            +
             
     | 
| 
      
 156 
     | 
    
         
            +
              #TODO: check for collision before update
         
     | 
| 
      
 157 
     | 
    
         
            +
              # if move_left or move_right set u on a collided field
         
     | 
| 
      
 158 
     | 
    
         
            +
              # dont update the position or slow down speed
         
     | 
| 
      
 159 
     | 
    
         
            +
              # idk make sure to not get stuck in walls
         
     | 
| 
      
 160 
     | 
    
         
            +
              def move_left
         
     | 
| 
      
 161 
     | 
    
         
            +
                # @dx = -8
         
     | 
| 
      
 162 
     | 
    
         
            +
                @x -= state[:crouching] ? 4 : 8
         
     | 
| 
      
 163 
     | 
    
         
            +
              end
         
     | 
| 
      
 164 
     | 
    
         
            +
             
     | 
| 
      
 165 
     | 
    
         
            +
              def move_right
         
     | 
| 
      
 166 
     | 
    
         
            +
                # @dx = 8
         
     | 
| 
      
 167 
     | 
    
         
            +
                @x += state[:crouching] ? 4 : 8
         
     | 
| 
      
 168 
     | 
    
         
            +
              end
         
     | 
| 
      
 169 
     | 
    
         
            +
             
     | 
| 
      
 170 
     | 
    
         
            +
              def apply_force(x, y)
         
     | 
| 
      
 171 
     | 
    
         
            +
                @dx += x
         
     | 
| 
      
 172 
     | 
    
         
            +
                @dy += y
         
     | 
| 
      
 173 
     | 
    
         
            +
              end
         
     | 
| 
      
 174 
     | 
    
         
            +
             
     | 
| 
      
 175 
     | 
    
         
            +
              def do_jump
         
     | 
| 
      
 176 
     | 
    
         
            +
                return if !@collide[:down]
         
     | 
| 
      
 177 
     | 
    
         
            +
             
     | 
| 
      
 178 
     | 
    
         
            +
                if @dead 
         
     | 
| 
      
 179 
     | 
    
         
            +
                  @dy = -5
         
     | 
| 
      
 180 
     | 
    
         
            +
                else
         
     | 
| 
      
 181 
     | 
    
         
            +
                  @dy = state[:crouching] ? -20 : -30
         
     | 
| 
      
 182 
     | 
    
         
            +
                end
         
     | 
| 
      
 183 
     | 
    
         
            +
              end
         
     | 
| 
      
 184 
     | 
    
         
            +
             
     | 
| 
      
 185 
     | 
    
         
            +
              def add_score(score = 1)
         
     | 
| 
      
 186 
     | 
    
         
            +
                @score = (@score + score).clamp(NET_MIN_INT, NET_MAX_INT)
         
     | 
| 
      
 187 
     | 
    
         
            +
              end
         
     | 
| 
      
 188 
     | 
    
         
            +
             
     | 
| 
      
 189 
     | 
    
         
            +
              def collide_string
         
     | 
| 
      
 190 
     | 
    
         
            +
                str = "collide:\n"
         
     | 
| 
      
 191 
     | 
    
         
            +
                str += "down: #{@collide[:down]} up: #{@collide[:up]}\n"
         
     | 
| 
      
 192 
     | 
    
         
            +
                str += "left: #{@collide[:left]} right: #{@collide[:right]}"
         
     | 
| 
      
 193 
     | 
    
         
            +
                str
         
     | 
| 
      
 194 
     | 
    
         
            +
              end
         
     | 
| 
      
 195 
     | 
    
         
            +
             
     | 
| 
      
 196 
     | 
    
         
            +
              def do_collide(position, value)
         
     | 
| 
      
 197 
     | 
    
         
            +
                if position == :right && @dx > 0
         
     | 
| 
      
 198 
     | 
    
         
            +
                  @dx = 0
         
     | 
| 
      
 199 
     | 
    
         
            +
                elsif position == :left && @dx < 0
         
     | 
| 
      
 200 
     | 
    
         
            +
                  @dx = 0
         
     | 
| 
      
 201 
     | 
    
         
            +
                elsif position == :down && @dy > 0
         
     | 
| 
      
 202 
     | 
    
         
            +
                  @dy = 0
         
     | 
| 
      
 203 
     | 
    
         
            +
                elsif position == :up && @dy < 0
         
     | 
| 
      
 204 
     | 
    
         
            +
                  @dy = 0
         
     | 
| 
      
 205 
     | 
    
         
            +
                end
         
     | 
| 
      
 206 
     | 
    
         
            +
                @collide[position] = value
         
     | 
| 
      
 207 
     | 
    
         
            +
              end
         
     | 
| 
      
 208 
     | 
    
         
            +
             
     | 
| 
      
 209 
     | 
    
         
            +
              def reset_collide
         
     | 
| 
      
 210 
     | 
    
         
            +
                @collide = {up: false, down: false, right: false, left: false}
         
     | 
| 
      
 211 
     | 
    
         
            +
              end
         
     | 
| 
      
 212 
     | 
    
         
            +
             
     | 
| 
      
 213 
     | 
    
         
            +
              ##
         
     | 
| 
      
 214 
     | 
    
         
            +
              # Creates name package str
         
     | 
| 
      
 215 
     | 
    
         
            +
              #
         
     | 
| 
      
 216 
     | 
    
         
            +
              # only used by server
         
     | 
| 
      
 217 
     | 
    
         
            +
              #
         
     | 
| 
      
 218 
     | 
    
         
            +
              # @return [String] partial network packet
         
     | 
| 
      
 219 
     | 
    
         
            +
             
     | 
| 
      
 220 
     | 
    
         
            +
              def to_n_pck
         
     | 
| 
      
 221 
     | 
    
         
            +
                name = @name.ljust(5, '_')
         
     | 
| 
      
 222 
     | 
    
         
            +
                # format("%02d#{name}", @id) # old 2 char ids
         
     | 
| 
      
 223 
     | 
    
         
            +
                "#{@id}#{net_pack_int(@score)}#{name}" # new 1 char id
         
     | 
| 
      
 224 
     | 
    
         
            +
              end
         
     | 
| 
      
 225 
     | 
    
         
            +
             
     | 
| 
      
 226 
     | 
    
         
            +
              def to_s
         
     | 
| 
      
 227 
     | 
    
         
            +
                # "#{'%02d' % @id}#{'%03d' % @x}#{'%03d' % @y}" # old 2 char ids
         
     | 
| 
      
 228 
     | 
    
         
            +
                # "#{@id}#{net_pack_int(@score)}#{'%03d' % @x}#{'%03d' % @y}" # old 3 char coords
         
     | 
| 
      
 229 
     | 
    
         
            +
                #                            unused
         
     | 
| 
      
 230 
     | 
    
         
            +
                #                             V
         
     | 
| 
      
 231 
     | 
    
         
            +
                "#{@id}#{net_pack_int(@score)}0#{state_to_net()}#{net_pack_bigint(@x, 2)}#{net_pack_bigint(@y, 2)}" # new 2 char coords
         
     | 
| 
      
 232 
     | 
    
         
            +
              end
         
     | 
| 
      
 233 
     | 
    
         
            +
             
     | 
| 
      
 234 
     | 
    
         
            +
              def state_to_net
         
     | 
| 
      
 235 
     | 
    
         
            +
                @w = TILE_SIZE / 2
         
     | 
| 
      
 236 
     | 
    
         
            +
                @h = TILE_SIZE
         
     | 
| 
      
 237 
     | 
    
         
            +
                if @state[:bleeding] && @state[:crouching]
         
     | 
| 
      
 238 
     | 
    
         
            +
                  "s"
         
     | 
| 
      
 239 
     | 
    
         
            +
                elsif @state[:bleeding]
         
     | 
| 
      
 240 
     | 
    
         
            +
                  "b"
         
     | 
| 
      
 241 
     | 
    
         
            +
                elsif @state[:crouching]
         
     | 
| 
      
 242 
     | 
    
         
            +
                  @w = TILE_SIZE
         
     | 
| 
      
 243 
     | 
    
         
            +
                  @h = TILE_SIZE / 2
         
     | 
| 
      
 244 
     | 
    
         
            +
                  "c"
         
     | 
| 
      
 245 
     | 
    
         
            +
                else
         
     | 
| 
      
 246 
     | 
    
         
            +
                  "0"
         
     | 
| 
      
 247 
     | 
    
         
            +
                end
         
     | 
| 
      
 248 
     | 
    
         
            +
              end
         
     | 
| 
      
 249 
     | 
    
         
            +
             
     | 
| 
      
 250 
     | 
    
         
            +
              def net_to_state(net)
         
     | 
| 
      
 251 
     | 
    
         
            +
                if net == "b"
         
     | 
| 
      
 252 
     | 
    
         
            +
                  @state = {bleeding: true, crouching: false}
         
     | 
| 
      
 253 
     | 
    
         
            +
                elsif net == "c"
         
     | 
| 
      
 254 
     | 
    
         
            +
                  @state = {bleeding: false, crouching: true}
         
     | 
| 
      
 255 
     | 
    
         
            +
                elsif net == "s"
         
     | 
| 
      
 256 
     | 
    
         
            +
                  @state = {bleeding: true, crouching: true}
         
     | 
| 
      
 257 
     | 
    
         
            +
                else
         
     | 
| 
      
 258 
     | 
    
         
            +
                  @state = {bleeding: false, crouching: false}
         
     | 
| 
      
 259 
     | 
    
         
            +
                end
         
     | 
| 
      
 260 
     | 
    
         
            +
              end
         
     | 
| 
      
 261 
     | 
    
         
            +
             
     | 
| 
      
 262 
     | 
    
         
            +
              private
         
     | 
| 
      
 263 
     | 
    
         
            +
             
     | 
| 
      
 264 
     | 
    
         
            +
              def move_x(x)
         
     | 
| 
      
 265 
     | 
    
         
            +
                return if x < 0 && @collide[:left]
         
     | 
| 
      
 266 
     | 
    
         
            +
                return if x > 0 && @collide[:right]
         
     | 
| 
      
 267 
     | 
    
         
            +
             
     | 
| 
      
 268 
     | 
    
         
            +
                @x += x
         
     | 
| 
      
 269 
     | 
    
         
            +
              end
         
     | 
| 
      
 270 
     | 
    
         
            +
             
     | 
| 
      
 271 
     | 
    
         
            +
              def move_y(y)
         
     | 
| 
      
 272 
     | 
    
         
            +
                return if y < 0 && @collide[:up]
         
     | 
| 
      
 273 
     | 
    
         
            +
                return if y > 0 && @collide[:down]
         
     | 
| 
      
 274 
     | 
    
         
            +
             
     | 
| 
      
 275 
     | 
    
         
            +
                @y += y
         
     | 
| 
      
 276 
     | 
    
         
            +
              end
         
     | 
| 
      
 277 
     | 
    
         
            +
             
     | 
| 
      
 278 
     | 
    
         
            +
              # This method puts the value towards zero
         
     | 
| 
      
 279 
     | 
    
         
            +
              # used to normalize speed
         
     | 
| 
      
 280 
     | 
    
         
            +
              def normalize_zero(x)
         
     | 
| 
      
 281 
     | 
    
         
            +
                return x if x.zero?
         
     | 
| 
      
 282 
     | 
    
         
            +
             
     | 
| 
      
 283 
     | 
    
         
            +
                return x - 1 if x > 0
         
     | 
| 
      
 284 
     | 
    
         
            +
                x + 1
         
     | 
| 
      
 285 
     | 
    
         
            +
              end
         
     | 
| 
      
 286 
     | 
    
         
            +
            end
         
     | 
    
        data/server.json
    ADDED
    
    
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,81 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: chichilku3
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 5.0.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - ChillerDragon
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2020-04-15 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies: []
         
     | 
| 
      
 13 
     | 
    
         
            +
            description: Simple 2d multiplayer stick figure battle game using the gosu (SDL2 based)
         
     | 
| 
      
 14 
     | 
    
         
            +
              gem for client side graphics. The network protocol is tcp based.
         
     | 
| 
      
 15 
     | 
    
         
            +
            email: ChillerDragon@gmail.com
         
     | 
| 
      
 16 
     | 
    
         
            +
            executables:
         
     | 
| 
      
 17 
     | 
    
         
            +
            - chichilku3
         
     | 
| 
      
 18 
     | 
    
         
            +
            - chichilku3-server
         
     | 
| 
      
 19 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 20 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 21 
     | 
    
         
            +
            files:
         
     | 
| 
      
 22 
     | 
    
         
            +
            - bin/chichilku3
         
     | 
| 
      
 23 
     | 
    
         
            +
            - bin/chichilku3-server
         
     | 
| 
      
 24 
     | 
    
         
            +
            - client.json
         
     | 
| 
      
 25 
     | 
    
         
            +
            - lib/client/chichilku3.rb
         
     | 
| 
      
 26 
     | 
    
         
            +
            - lib/client/client.rb
         
     | 
| 
      
 27 
     | 
    
         
            +
            - lib/client/client_cfg.rb
         
     | 
| 
      
 28 
     | 
    
         
            +
            - lib/client/gui.rb
         
     | 
| 
      
 29 
     | 
    
         
            +
            - lib/client/img/background1024x512.png
         
     | 
| 
      
 30 
     | 
    
         
            +
            - lib/client/img/battle1024x576.png
         
     | 
| 
      
 31 
     | 
    
         
            +
            - lib/client/img/connecting1024x512.png
         
     | 
| 
      
 32 
     | 
    
         
            +
            - lib/client/img/grass1024x512.png
         
     | 
| 
      
 33 
     | 
    
         
            +
            - lib/client/img/grey128.png
         
     | 
| 
      
 34 
     | 
    
         
            +
            - lib/client/img/menu1920x1080.png
         
     | 
| 
      
 35 
     | 
    
         
            +
            - lib/client/img/stick128/stick0.png
         
     | 
| 
      
 36 
     | 
    
         
            +
            - lib/client/img/stick128/stick1.png
         
     | 
| 
      
 37 
     | 
    
         
            +
            - lib/client/img/stick128/stick2.png
         
     | 
| 
      
 38 
     | 
    
         
            +
            - lib/client/img/stick128/stick3.png
         
     | 
| 
      
 39 
     | 
    
         
            +
            - lib/client/img/stick128/stick4.png
         
     | 
| 
      
 40 
     | 
    
         
            +
            - lib/client/img/stick128/stick5.png
         
     | 
| 
      
 41 
     | 
    
         
            +
            - lib/client/img/stick128/stick_crouching0.png
         
     | 
| 
      
 42 
     | 
    
         
            +
            - lib/client/img/stick128/stick_crouching1.png
         
     | 
| 
      
 43 
     | 
    
         
            +
            - lib/client/img/stick128/stick_crouching2.png
         
     | 
| 
      
 44 
     | 
    
         
            +
            - lib/client/img/stick128/stick_crouching3.png
         
     | 
| 
      
 45 
     | 
    
         
            +
            - lib/client/img/stick128/stick_crouching4.png
         
     | 
| 
      
 46 
     | 
    
         
            +
            - lib/client/img/stick128/stick_crouching5.png
         
     | 
| 
      
 47 
     | 
    
         
            +
            - lib/client/scoreboard.rb
         
     | 
| 
      
 48 
     | 
    
         
            +
            - lib/client/test.rb
         
     | 
| 
      
 49 
     | 
    
         
            +
            - lib/client/text.rb
         
     | 
| 
      
 50 
     | 
    
         
            +
            - lib/server/chichilku3_server.rb
         
     | 
| 
      
 51 
     | 
    
         
            +
            - lib/server/gamelogic.rb
         
     | 
| 
      
 52 
     | 
    
         
            +
            - lib/server/server_cfg.rb
         
     | 
| 
      
 53 
     | 
    
         
            +
            - lib/share/config.rb
         
     | 
| 
      
 54 
     | 
    
         
            +
            - lib/share/console.rb
         
     | 
| 
      
 55 
     | 
    
         
            +
            - lib/share/network.rb
         
     | 
| 
      
 56 
     | 
    
         
            +
            - lib/share/player.rb
         
     | 
| 
      
 57 
     | 
    
         
            +
            - server.json
         
     | 
| 
      
 58 
     | 
    
         
            +
            homepage: https://github.com/chichilku/chichilku3
         
     | 
| 
      
 59 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 60 
     | 
    
         
            +
            - Unlicense
         
     | 
| 
      
 61 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 62 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 63 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 64 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 65 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 66 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 67 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 68 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 69 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 70 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 71 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 72 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 73 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 74 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 75 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 76 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 77 
     | 
    
         
            +
            rubygems_version: 3.0.3
         
     | 
| 
      
 78 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 79 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 80 
     | 
    
         
            +
            summary: Stick battle game
         
     | 
| 
      
 81 
     | 
    
         
            +
            test_files: []
         
     |