Skip to content

Instantly share code, notes, and snippets.

@JamesZoft
JamesZoft / sokoban.rb
Created March 28, 2012 14:32
Sokoban
#!/usr/bin/ruby
require 'pp'
$rows
$cols
class Sokoban
attr_accessor :crates, :empty_storage, :filled_storage, :playing_grid, :crate_id, :man_id, :wall_id, :floor_id,
:storage_id, :crate_on_storage_id, :man_on_storage_id, :symbols, :workman, :move_coords
@JamesZoft
JamesZoft / sokoban_extract.rb
Created March 28, 2012 14:40
sokoban_extract
def play
puts "Welcome to Sokoban! The aim of the game is to put all of the crates, which are the \'" + @crate_id + "\' symbols onto the storage pallets, which are the \'" + @storage_id + "\' symbols! A list of all the symbols is available if you type \"help\", and the status of the game is available if you type \"status\"."
status()
loop do
input = gets.chomp()
pp input
case input.downcase!
when "help"
help()
when "move"
def move(direction) #Returns what the new coords would be, Sokoban.handle_move then checks if these are valid
pp @coordinates
case direction.downcase!
when "up"
move_up()
when "down"
move_down()
when "right"
move_right()
when "left"
@JamesZoft
JamesZoft / shooter.rb
Created April 19, 2012 09:26
2d shooter
#!/usr/bin/env ruby
require 'rubygems'
require 'gosu'
require 'pp'
class GameWindow < Gosu::Window
def initialize
super 640, 480, false
@JamesZoft
JamesZoft / game.rb
Created April 19, 2012 15:24
Asteroids....sorta
#!/usr/bin/env ruby
require 'rubygems'
require 'gosu'
require 'pp'
class GameWindow < Gosu::Window
attr_accessor :bullets, :stars
#!/usr/bin/env ruby
require 'gosu'
require 'pp'
class GameWindow < Gosu::Window
attr_reader :tilemap
def initialize
#!/usr/bin/env ruby
require 'gosu'
require 'pp'
class GameWindow < Gosu::Window
attr_reader :tilemap
def initialize
#!/usr/bin/env ruby
require 'gosu'
require 'pp'
class GameWindow < Gosu::Window
attr_reader :tilemap
def initialize
while line = @irc.gets
puts line
ping_message_regex = "PING :.*\.freenode\.net"
if line =~ ping_message_regex
send("PRIVMSG " + @server + " PONG!")
end
end
def give_youtube_description(line)
channel = get_input_channel(line)
if line =~ /.*youtube.com.*/
url = line.gsub(/.*\:/, '').gsub(/.*youtube/, 'youtube').strip.gsub(/\ .*/, '')
puts url
begin
page = open("http://www." + url)
contents = page.read.gsub(/.*meta name="keywords" content="/m, '').gsub(/".*/m, '').strip
puts channel + " " + url + " " + contents
send("PRIVMSG " + channel + " :http://www." + url + " " + contents)