I require 'ruby2d' in my code and write a simple program to build onto for my snake game. I am trying to get the program to pop-up a window on the screen. This is my code
require 'ruby2d'
set background: 'navy'
#width = 640 / 20 =32
#height = 480 / 2- = 24
GRID_SIZE = 20
class Snake
def init
@positions = [[2,0], [2,1], [2,2], [2,3]]
end
def draw
@positions.each do |position|
Square.new(x:position[0] * GRID_SIZE, y: position[1] * GRID_SIZE, size: GRID_SIZE, color: 'white')
end
end
end
snake = Snake.new
snake.draw
show
I also ran the command gem install ruby2d in the terminal and it gave me this error,
Fetching ruby2d-0.10.0.gem
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.