Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 109 lines (78 sloc) 1.33 KB
#!/usr/bin/env ruby -I lib -w
require 'environment'
require 'models/spaceship'
require 'models/sky'
require 'views/fuselage'
require 'views/sky_view'
class SpaceWars < Controller
on "w" do
spaceship.pitch_down
end
on "s" do
spaceship.pitch_up
end
on "a" do
spaceship.roll_left
end
on "d" do
spaceship.roll_right
end
on "z" do
spaceship.yaw_left
end
on "c" do
spaceship.yaw_right
end
on "x" do
spaceship.reset_rotation
end
on '[' do
spaceship.accelerate
end
on '\'' do
spaceship.brake
end
on "=" do
$camera.zoom_in
end
on "-" do
$camera.zoom_out
end
on "h" do
$camera.roll(-0.1)
end
on "j" do
$camera.pitch( 0.1)
end
on "k" do
$camera.pitch(-0.1)
end
on "l" do
$camera.roll( 0.1)
end
on "f" do
window.enter_full_screen
end
on "F" do
window.leave_full_screen
end
on "q" do
exit
end
def spaceship
@spaceship ||= Spaceship.new
end
def on_tick
spaceship.animate
end
end
space_wars = SpaceWars.new
window = Window.new(space_wars)
$camera = Camera.new( -40)
$camera.pitch(Math::PI/2)
window.views << CameraView.new($camera)
window.views << Fuselage.new(space_wars.spaceship)
window.views << SkyView.new(Sky.new)
# window.views << SunView.new(Sun.new)
$window = window
window.start
Jump to Line
Something went wrong with that request. Please try again.