Skip to content

Instantly share code, notes, and snippets.

@kazoo04
Created April 25, 2014 06:50
Show Gist options
  • Save kazoo04/efd3fb2c24a7c191843f to your computer and use it in GitHub Desktop.
Save kazoo04/efd3fb2c24a7c191843f to your computer and use it in GitHub Desktop.
Capsule
# encoding: utf-8
WIDTH = 8
HEIGHT = 16
class Item
end
class Capsule < Item
def initialize(t)
@type = t
end
def type
@type
end
def character
return '◯' if @type == :red
return '●' if @type == :yellow
return '◎' if @type == :blue
end
end
def show(field)
for y in 0...HEIGHT do
for x in 0...WIDTH do
if field[x][y].nil?
print ' '
else
print field[x][y].character
end
end
puts
end
end
field = Array.new(WIDTH).map{ Array.new(HEIGHT, nil) }
field[6][10] = Capsule.new(:red)
field[5][12] = Capsule.new(:blue)
field[2][ 8] = Capsule.new(:yellow)
show(field)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment