Skip to content

Instantly share code, notes, and snippets.

@poemdexter
Created April 15, 2012 01:27
Show Gist options
  • Save poemdexter/2389213 to your computer and use it in GitHub Desktop.
Save poemdexter/2389213 to your computer and use it in GitHub Desktop.
class World < Chingu::GameObject
attr_reader :grid, :width, :height, :walls
def initialize(options)
super
@width = 20
@height = 20
@grid = Array.new(width,[])
@grid = @grid.map {Array.new(height,0)}
#@target_sprite = Image["grass.bmp"]
#@wall_sprite = Image["wall.bmp"]
@walls = []
end
def update
end
def draw
@grid.each_with_index do |inner, x|
inner.each_index do |y|
@target_sprite.draw(x*24,y*24,0)
end
end
@walls.each do |pos|
@wall_sprite.draw(24*pos[0], 24*pos[1], 2)
end
end
def handle_wall_click(x, y)
x = (x/24).floor
y = (y/24).floor
if @walls.include?([x,y])
@walls.delete([x,y])
elsif
@walls << [x,y]
end
end
end
require 'gosu'
require 'chingu'
require_relative 'player'
require_relative 'world'
require_relative 'enemy'
require_relative 'pathfinder'
class Game < Gosu::Window
attr_reader :world
def initialize
super 480, 480, false
self.caption = "Dan's Shit Game For Idiots: Dubstep Protocol"
@world = World.create(:x=>2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment