How to make a grid layout in Ruby (Gosu)?


Posted by: user3213110 on 08/21/2015 | Add Revision

So I'm attempting to make a simple Snake game. However, there's one major problem with that - I don't know how to make my playing field as a grid.

So far I've split my snake into segemnts, which are drawn every time it eats an apple. My turn method looks like that (it's analogical for every direction pretty much):

if @direction == :right
  x = @head.x + @speed
  y = @head.y
  new_segment =, self, [x, y])

with new_segment being immediately pushed into the array segments.

The problem with that is that the snake is too independant. I'd like to make it move in predetermined rows and columns a.k.a make myself a grid. Could somoene help me with that? Thank you!

Visit Website