test/games/cheese_game2d.rb
# a game must implement these  functions
a game must implement these  functions
a game must implement these functions
def gameloop
    move = get_input
    if move == :left
      @position[:x] = @position[:x] > 0 ? @position[:x]-1 : @map_size_x-1;
    elsif move == :right
      @position[:x] = @position[:x] < @map_size_x-1 ? @position[:x]+1 : 0;
    elsif move == :down
      @position[:y] = @position[:y] < @map_size_y-1 ? @position[:y]+1 : 0;
    elsif move == :up
      @position[:y] = @position[:y] > 0 ? @position[:y]-1 : @map_size_y-1;
    end
    if @position[:x] == @cheese_x && @position[:y] == @cheese_y
      @score += 1
      @position = @start_position.dup
    end
    if @position[:x] == @pit_x && @position[:y] == @pit_y
      @score -= 1
      @position = @start_position.dup
    end
    if @new_game
      @new_game = false 
    end
  end
def gameloop move = get_input if move == :left @position [ :x ] = @position [ :x ] > 0 ? @position [ :x ] - 1 : @map_size_x - 1 ; elsif move == :right @position [ :x ] = @position [ :x ] < @map_size_x - 1 ? @position [ :x ] + 1 : 0 ; elsif move == :down @position [ :y ] = @position [ :y ] < @map_size_y - 1 ? @position [ :y ] + 1 : 0 ; elsif move == :up @position [ :y ] = @position [ :y ] > 0 ? @position [ :y ] - 1 : @map_size_y - 1 ; end if @position [ :x ] == @cheese_x && @position [ :y ] == @cheese_y @score += 1 @position = @start_position . dup end if @position [ :x ] == @pit_x && @position [ :y ] == @pit_y @score -= 1 @position = @start_position . dup end if @new_game @new_game = false end end
a game must implement these  functions
a game must implement these functions
#@cheese_x = rand(@map_size_x) #@cheese_y = rand(@map_size_y) # No longer a new game after the first input has been received