Skip to content

Instantly share code, notes, and snippets.

@creaturenex
Created February 18, 2021 01:14
Show Gist options
  • Save creaturenex/f336a1d92c3c8d55a6d5901295191f0b to your computer and use it in GitHub Desktop.
Save creaturenex/f336a1d92c3c8d55a6d5901295191f0b to your computer and use it in GitHub Desktop.
space_invader
class Invader
def initialize
self.animate
end
def down
puts " ▒▒ ▒▒"
puts " ▒▒ ▒▒"
puts " ▒▒▒▒▒▒▒▒▒▒▒▒▒▒"
puts " ▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒"
puts " ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"
puts " ▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒"
puts " ▒▒ ▒▒ ▒▒ ▒▒"
puts " ▒▒▒▒ ▒▒▒▒"
end
def up
puts " ▒▒ ▒▒"
puts " ▒▒ ▒▒ ▒▒ ▒▒"
puts " ▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒"
puts " ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒"
puts " ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"
puts " ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"
puts " ▒▒ ▒▒"
puts " ▒▒ ▒▒"
end
def animate
10.times do
system('clear')
self.down
sleep (0.5)
system('clear')
self.up
sleep(0.5)
end
end
end
alien = Invader.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment