Created
April 15, 2012 01:27
-
-
Save poemdexter/2389213 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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