Skip to content

Instantly share code, notes, and snippets.

@kbparagua
Last active November 30, 2015 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kbparagua/acb44fa439d0ef377874 to your computer and use it in GitHub Desktop.
Save kbparagua/acb44fa439d0ef377874 to your computer and use it in GitHub Desktop.
class Pacman
def self.get_instance
# instantiate the singleton instance if it is not existing yet.
if @instance.nil?
@instance = Pacman.new
end
@instance
end
def initialize x, y
@x = x
@y = y
end
def move_up
@y = @y + 1
end
def move_down
@y = @y - 1
end
def move_right
@x = @x + 1
end
def move_left
@x = @x - 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment