Skip to content

Instantly share code, notes, and snippets.

/game.rb Secret

Created June 14, 2015 06:21
Show Gist options
  • Save anonymous/c71c6ce4c48553e39500 to your computer and use it in GitHub Desktop.
Save anonymous/c71c6ce4c48553e39500 to your computer and use it in GitHub Desktop.
require 'io/console'
x, y, guy = 1, 1, '(^u^)'
gs = guy.size
world = ['####################']
10.times { world << '#' + ' ' * 18 + '#' }
world << world[0]
world[y][x, gs] = guy
loop do
print `clear`
puts world
world[y][x, gs] = ' ' * gs
case c = STDIN.getch
when ?q; break
when ?w; y -= 1
when ?a; x -= 1
when ?s; y += 1
when ?d; x += 1
end
world[y][x, gs] = guy
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment