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
STATS_DIRECTORIES = [ | |
%w(Source src/), | |
%w(Config config/), | |
%w(Maps maps/), | |
%w(Unit\ tests specs/), | |
%w(Libraries lib/), | |
].collect { |name, dir| [ name, "#{APP_ROOT}/#{dir}" ] }.select { |name, dir| File.directory?(dir) } | |
desc "Report code statistics (KLOCs, etc) from the application" | |
task :stats do |
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 'inflector' | |
# Actor represent a game object. | |
# Actors can have behaviors added and removed from them. | |
class Actor | |
attr_accessor :behaviors | |
def initialize | |
@behaviors = {} | |
# add our classes behaviors | |
class_behaviors = self.class.behaviors.dup |
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 'mode' | |
require 'level' | |
require 'director' | |
require 'actor' | |
class ActorView | |
attr_accessor :actor, :mode | |
def initialize(mode,actor) | |
@mode = mode | |
@actor = actor |
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
i = @input_manager | |
i.reg KeyDownEvent, K_SPACE do | |
ship.warp vec2(rand(400)-100,rand(400)-100) | |
end | |
i.reg KeyDownEvent, K_LEFT do | |
ship.moving_left = true | |
end | |
i.reg KeyDownEvent, K_RIGHT do | |
ship.moving_right = true | |
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
@input_manager.when :event_received do |event| | |
case event | |
when KeyDownEvent | |
case event.key | |
when K_SPACE | |
ship.warp vec2(300,300) | |
when K_LEFT | |
ship.moving_left = true | |
when K_RIGHT | |
ship.moving_right = 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
class Clock | |
def tick() | |
passed = Clock.runtime() - @last_tick # how long since the last tick? | |
if @target_frametime | |
wait = @target_frametime - passed | |
if wait > 0 | |
return Clock.wait(@target_frametime - passed) + passed | |
else | |
return passed | |
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
#!/usr/bin/env ruby | |
$: << "#{File.dirname(__FILE__)}/../config" | |
require 'environment' | |
require 'gamebox' | |
if $0 == __FILE__ | |
GameboxApp.run ARGV, ENV | |
end | |
require 'actor' |
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
sanderson@shiny-2:~/code/snelps$ !rsdl | |
rsdl src/app.rb | |
The 'run' provides a unified access point for all the default Rails' commands. | |
Usage: ./script/run <command> [OPTIONS] | |
Examples: | |
./script/run generate controller Admin | |
./script/run process reaper |
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
sudo gem install rcov | |
Building native extensions. This could take a while... | |
ERROR: Error installing rcov: | |
ERROR: Failed to build gem native extension. | |
/usr/local/bin/ruby1.9 extconf.rb install rcov | |
creating Makefile | |
make | |
gcc -I. -I/usr/local/include/ruby1.9-1.9.1/i386-darwin9.6.0 -I/usr/local/include/ruby1.9-1.9.1/ruby/backward -I/usr/local/include/ruby1.9-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -O3 -g -Wall -Wno-parentheses -fno-common -pipe -fno-common -o callsite.o -c callsite.c |
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 'actor' | |
require 'actor_view' | |
require 'ftor' | |
class ParticleSystemView < ActorView | |
def draw(target, x_off, y_off) | |
ax = @actor.x + x_off | |
ay = @actor.y + y_off | |
@actor.particles.each do |part| | |
target.draw_circle_s [part.x,part.y], 3, [part.r,part.g,part.b,part.a] |
OlderNewer