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 | |
attr_reader :grid, :width, :height | |
def initialize(window) | |
@width = 20 | |
@height = 20 | |
@grid = Array.new(width,[]) | |
@grid = @grid.map {Array.new(height,0)} | |
@target_sprite = Gosu::Image.new(window, "target.bmp", true) |
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
def backtrack_through_closed | |
final_path = [] | |
next_position = @closed_list.select{|x| x[2] == @finish}[0][2] | |
final_path.unshift(next_position) | |
while next_position != @start | |
next_position = @closed_list.select{|x| x[2] == next_position}[0][3] | |
final_path.unshift(next_position) | |
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
def button_down(id) | |
case id | |
when Gosu::MsLeft | |
if (0 < mouse_x && mouse_x < 480 && 0 < mouse_y && mouse_y < 480) | |
@player.reposition(mouse_x, mouse_y) | |
end | |
end | |
def reposition(x, y) | |
@x = (x/24).floor |
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)} | |
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 'nokogiri' | |
#@url = "http://ws.spotify.com/lookup/1/?uri=spotify:track:6NmXV4o6bmp704aPGyTVVG" | |
@url = "http://www.google.com/" | |
@doc = Nokogiri::HTML(open(@url)) |
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 Spotify | |
include Cinch::Plugin | |
listen_to :message | |
def listen(m) | |
url_regex = /(?<http>http\:\/\/)?open.spotify.com\/(?<tag>track|album|artist)\/(?<id>[a-zA-Z0-9]{22})/ | |
match = url_regex.match(m.message) | |
if match | |
parse(match[:tag],match[:id],m) | |
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
<?xml version='1.0' encoding='UTF-8'?><entry xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' xmlns:gd='http://schemas.google.com/g/2005' xmlns:yt='http://gdata.youtube.com/schemas/2007' gd:etag='W/"AkcFR347eCp7I2A9WhVXFU8."'><id>tag:youtube.com,2008:video:QH2-TGUlwu4</id><published>2011-04-06T03:21:59.000Z</published><updated>2012-04-15T22:13:36.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#video'/><category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' term='Comedy' label='Comedy'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='cat'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='flying through space'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='annoying'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='amazing'/><category scheme='http://gdata.youtube.com/schemas/2007 |
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
<?xml version='1.0' encoding='UTF-8'?> | |
<entry xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' xmlns:gd='http://schemas.google.com/g/2005' xmlns:yt='http://gdata.youtube.com/schemas/2007' gd:etag='W/"AkcFR347eCp7I2A9WhVXFU8."'> | |
<id>tag:youtube.com,2008:video:QH2-TGUlwu4</id> | |
<published>2011-04-06T03:21:59.000Z</published> | |
<updated>2012-04-15T22:13:36.000Z</updated> | |
<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#video'/> | |
<category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' term='Comedy' label='Comedy'/> | |
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='cat'/> | |
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='flying through space'/> | |
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='annoying'/> |
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 FSMBuild | |
state_machine :initial => :wait do | |
event :walk do | |
transition :wait => :walking | |
end | |
event :stop do | |
transition :walking => :wait |
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 FSMBuild | |
state_machine :initial => :searching_mat do | |
event :path_found do | |
transition :searching_mat => :walking_mat, :searching_buildspot => :walking_buildspot | |
end | |
event :path_not_found do | |
transition :searching_mat => same, :searching_buildspot => same |