Skip to content

Instantly share code, notes, and snippets.

View shawn42's full-sized avatar

Shawn Anderson shawn42

  • Cisco
  • Holland, MI
View GitHub Profile
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
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
require 'mode'
require 'level'
require 'director'
require 'actor'
class ActorView
attr_accessor :actor, :mode
def initialize(mode,actor)
@mode = mode
@actor = actor
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
@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
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
#!/usr/bin/env ruby
$: << "#{File.dirname(__FILE__)}/../config"
require 'environment'
require 'gamebox'
if $0 == __FILE__
GameboxApp.run ARGV, ENV
end
require 'actor'
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
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
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]