Permalink
Browse files

Easier gemspec build in Rakefile. Chingu gem 0.2.0 released.

  • Loading branch information...
1 parent 94a0cbc commit 2ae593b2be0ef049d40d6ce5520ac1dbe0792fdd @ippa committed Aug 9, 2009
Showing with 117 additions and 89 deletions.
  1. +3 −0 History.txt
  2. +9 −4 Manifest.txt
  3. +25 −12 README.rdoc
  4. +6 −0 Rakefile
  5. +34 −34 chingu.gemspec
  6. +1 −1 examples/example1.rb
  7. +2 −2 examples/example2.rb
  8. +1 −1 examples/example3.rb
  9. +10 −6 examples/example4.rb
  10. +2 −2 lib/chingu.rb
  11. +2 −4 lib/chingu/game_object.rb
  12. +2 −2 lib/chingu/game_state.rb
  13. +6 −6 lib/chingu/input.rb
  14. +14 −15 lib/chingu/window.rb
View
@@ -1,2 +1,5 @@
+=== 0.0.2 / 2009-08-10
+tons of new stuff and fixes. complete keymap. gamestate system. moreexamples/docs. better game_object.
+
=== 0.0.1 / 2009-08-05
first release
View
@@ -6,6 +6,7 @@ chingu.gemspec
examples/example1.rb
examples/example2.rb
examples/example3.rb
+examples/example4.rb
examples/media/Parallax-scroll-example-layer-0.png
examples/media/Parallax-scroll-example-layer-1.png
examples/media/Parallax-scroll-example-layer-2.png
@@ -16,14 +17,18 @@ examples/media/spaceship.png
examples/media/stickfigure.bmp
examples/media/stickfigure.png
lib/chingu.rb
-lib/chingu/actor.rb
-lib/chingu/advanced_actor.rb
lib/chingu/animation.rb
lib/chingu/assets.rb
+lib/chingu/chipmunk_object.rb
lib/chingu/data_structures.rb
lib/chingu/fpscounter.rb
-lib/chingu/keymap.rb
+lib/chingu/game_object.rb
+lib/chingu/game_state.rb
+lib/chingu/game_state_manager.rb
+lib/chingu/helpers.rb
+lib/chingu/input.rb
lib/chingu/named_resource.rb
-lib/chingu/paralaxx.rb
+lib/chingu/parallax.rb
lib/chingu/rect.rb
+lib/chingu/text.rb
lib/chingu/window.rb
View
@@ -1,11 +1,20 @@
= CHINGU
-SOURCE: http://github.com/ippa/chingu/tree/master
+http://github.com/ippa/chingu/tree/master
+
DOCUMENTATION: http://rdoc.info/projects/ippa/chingu
-This is a early preview, a lot of functionality is still missing!
+This is an early preview, a lot of functionality is still missing!
+It's also in a state of flux while I decide on core-naming etc.
+
+== INSTALL
+ gem sources -a http://gems.github.com
+ sudo gem install ippa-chingu
+
== DESCRIPTION
-Game framework built on top of the OpenGL accelerated game lib Gosu. "Chingu" means "Friend" in Korean.
+Game framework built on top of the OpenGL accelerated game lib Gosu.
+It adds simple yet powerfull game states, prettier inputhandling, deploymentsafe asset-handling, a basic re-usable game object and automation of common task.
+
== THE STORY
The last years I've dabbled around a lot with game development.
@@ -17,6 +26,7 @@ After 10+ game prototypes and some finished smaller games I started to see patte
There was always a huge big chunk of checking keyboard-events in the main loop.
Borrowing ideas from Rubygame this has now become @player.keyboard(:left => :move_left, :space => :fire ... etc.
+
== OVERVIEW
Chingu consists of the following core classes:
@@ -101,7 +111,7 @@ Chingu doesn't change any fundamental concept of Gosu, but it will make the abov
# You'll need your own Game#update/#draw after a while, but just put #super there and Chingu can do its thing!
#
@player = Player.new
- @player.keymap = {:left => :move_left, :right => :move_right}
+ @player.input = {:left => :move_left, :right => :move_right}
end
end
@@ -139,7 +149,7 @@ This is our basic "game unit"-class, meaning most in game objects (players, enem
* Encapsulate only the very common basics that Most in game objects need
* Keep naming close to Gosu, but add smart convenient methods / shortcuts and a more rubyish feeling
-* No game logic at all allowed in GameObject, since that is most likely useful for others
+* No game logic allowed in GameObject, since that's not likely to be useful for others.
I've chose to base it around Image#draw_rot. So basically all the arguments that you pass to draw_rot can be passed to GameObject#new when creating a new object, an example using almost all arguments would be:
@@ -223,18 +233,18 @@ In a main loop or in a game state:
* pop_gamestate - removes active gamestate and activates the previous one
* switch_gamestate(state) - pop all gamestates until given state is found
-To switch to a certain gamestate with a keypress use Chingus keymapper:
+To switch to a certain gamestate with a keypress use Chingus input handler:
class Intro < Chingu::GameState
def setup
- self.keymap = { :space => lambda{push_gamestate(Menu.new)} }
+ self.input = { :space => lambda{push_gamestate(Menu.new)} }
end
end
Or Chingus pretty shortcut:
class Intro < Chingu::GameState
def setup
- self.keymap = { :space => Menu } # { :space => Menu.new } works as well.
+ self.input = { :space => Menu } # { :space => Menu.new } works as well.
end
end
@@ -267,14 +277,15 @@ Text is a class to give the use of Gosu::Font more rubyish feel and fit it bette
# Chingu
@text = Chingu::Text.new(:text => "A Text", :x => 200, :y => 50, :zorder => 55, :factor_x => 2.0)
- @text.draw # usually not needed as Text is a GameObject and therefore autodrawn
+ @text.draw
-@text comes with a number of changeable properties, x,y,zorder,angle,factor_x,color,mode etc.
+@text.draw is usually not needed as Text is a GameObject and therefore autodrawn.
+It's not only that the second example is readable by ppl now even familiar with Gosu, @text comes with a number of changeable properties, x,y,zorder,angle,factor_x,color,mode etc. Set a new x or angle or color and it will instantly update on screen.
== TODO:
-* (half done) Complete the keymap-definitions with all possible keys
-* Complete keymap-stuff with released-states etc
+* (done) Complete the input-definitions with all possible inputs (keyboard, gamepad, mouse)!
+* Complete input-stuff with released-states etc
* More gfx effects, for example: fade in/out to a specific color (black makes sense between levels).
* Summon good proven community gosu snippets into Chingu
* (done) Generate docs @ ippa.github.com- http://rdoc.info/projects/ippa/chingu !
@@ -293,6 +304,8 @@ Text is a class to give the use of Gosu::Font more rubyish feel and fit it bette
* A more robust game state <-> game_object system to connect them together.
* Get better at styling rdocs
* all “gamestate” ? “game state” ?
+* FIX example4: :p => Pause.new would Change the "inside_game_state" to Pause and make @player belong to Pause.
+* intergrate rubygame_movie_make (maybe after a rename, GameAutomator? GameSequence?
== WHY?
* Plain Gosu is very minimalistic, perfect to build some higher level logic on!
View
@@ -11,3 +11,9 @@ Hoe.spec "chingu" do
self.rubyforge_name = "chingu"
self.version = Chingu::VERSION
end
+
+desc "Build a working gemspec"
+task :gemspec do
+ system "rake git:manifest"
+ system "rake debug_gem | grep -v \"(in \" > chingu.gemspec"
+end
View
@@ -1,34 +1,34 @@
-# -*- encoding: utf-8 -*-
-
-Gem::Specification.new do |s|
- s.name = %q{chingu}
- s.version = "0.0.1"
-
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["ippa"]
- s.date = %q{2009-08-07}
- s.description = %q{Game framework built on top of the opengl accelerated gamelib Gosu. "Chingu" means "Friend" in korean.}
- s.email = ["ippa@rubylicio.us"]
- s.extra_rdoc_files = ["History.txt", "Manifest.txt"]
- s.files = ["History.txt", "Manifest.txt", "README.rdoc", "Rakefile", "chingu.gemspec", "examples/example1.rb", "examples/example2.rb", "examples/example3.rb", "examples/media/Parallax-scroll-example-layer-0.png", "examples/media/Parallax-scroll-example-layer-1.png", "examples/media/Parallax-scroll-example-layer-2.png", "examples/media/Parallax-scroll-example-layer-3.png", "examples/media/background1.png", "examples/media/fire_bullet.png", "examples/media/spaceship.png", "examples/media/stickfigure.bmp", "examples/media/stickfigure.png", "lib/chingu.rb", "lib/chingu/actor.rb", "lib/chingu/advanced_actor.rb", "lib/chingu/animation.rb", "lib/chingu/assets.rb", "lib/chingu/data_structures.rb", "lib/chingu/fpscounter.rb", "lib/chingu/keymap.rb", "lib/chingu/named_resource.rb", "lib/chingu/paralaxx.rb", "lib/chingu/rect.rb", "lib/chingu/window.rb"]
- s.has_rdoc = true
- s.homepage = %q{SOURCE: http://github.com/ippa/chingu/tree/master}
- s.rdoc_options = ["--main", "README.rdoc"]
- s.require_paths = ["lib"]
- s.rubyforge_project = %q{chingu}
- s.rubygems_version = %q{1.3.1}
- s.summary = %q{Game framework built on top of the opengl accelerated gamelib Gosu}
-
- if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 2
-
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
- s.add_development_dependency(%q<hoe>, [">= 2.3.2"])
- else
- s.add_dependency(%q<hoe>, [">= 2.3.2"])
- end
- else
- s.add_dependency(%q<hoe>, [">= 2.3.2"])
- end
-end
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{chingu}
+ s.version = "0.2.0"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["ippa"]
+ s.date = %q{2009-08-10}
+ s.description = %q{Game framework built on top of the OpenGL accelerated game lib Gosu. It adds simple yet powerfull game states, prettier inputhandling, deploymentsafe asset-handling, a basic re-usable game object and automation of common task.}
+ s.email = ["ippa@rubylicio.us"]
+ s.extra_rdoc_files = ["History.txt", "Manifest.txt"]
+ s.files = ["History.txt", "Manifest.txt", "README.rdoc", "Rakefile", "chingu.gemspec", "examples/example1.rb", "examples/example2.rb", "examples/example3.rb", "examples/example4.rb", "examples/media/Parallax-scroll-example-layer-0.png", "examples/media/Parallax-scroll-example-layer-1.png", "examples/media/Parallax-scroll-example-layer-2.png", "examples/media/Parallax-scroll-example-layer-3.png", "examples/media/background1.png", "examples/media/fire_bullet.png", "examples/media/spaceship.png", "examples/media/stickfigure.bmp", "examples/media/stickfigure.png", "lib/chingu.rb", "lib/chingu/animation.rb", "lib/chingu/assets.rb", "lib/chingu/chipmunk_object.rb", "lib/chingu/data_structures.rb", "lib/chingu/fpscounter.rb", "lib/chingu/game_object.rb", "lib/chingu/game_state.rb", "lib/chingu/game_state_manager.rb", "lib/chingu/helpers.rb", "lib/chingu/input.rb", "lib/chingu/named_resource.rb", "lib/chingu/parallax.rb", "lib/chingu/rect.rb", "lib/chingu/text.rb", "lib/chingu/window.rb"]
+ s.has_rdoc = true
+ s.homepage = %q{http://github.com/ippa/chingu/tree/master}
+ s.rdoc_options = ["--main", "README.rdoc"]
+ s.require_paths = ["lib"]
+ s.rubyforge_project = %q{chingu}
+ s.rubygems_version = %q{1.3.1}
+ s.summary = %q{Game framework built on top of the OpenGL accelerated game lib Gosu}
+
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 2
+
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
+ s.add_development_dependency(%q<hoe>, [">= 2.3.2"])
+ else
+ s.add_dependency(%q<hoe>, [">= 2.3.2"])
+ end
+ else
+ s.add_dependency(%q<hoe>, [">= 2.3.2"])
+ end
+end
View
@@ -15,7 +15,7 @@ class Game < Chingu::Window
def initialize
super
@player = Player.new(:x => 200, :y => 200, :image => Image["spaceship.png"])
- @player.keymap = {:left => :move_left, :right => :move_right, :up => :move_up, :down => :move_down}
+ @player.input = {:left => :move_left, :right => :move_right, :up => :move_up, :down => :move_down}
end
end
View
@@ -15,7 +15,7 @@ def initialize
super
@player = Player.new(:x => 200, :y => 200, :image => Image["spaceship.png"])
- @player.keymap = {:left => :move_left, :right => :move_right, :up => :move_up, :down => :move_down, :space => :fire}
+ @player.input = {:left => :move_left, :right => :move_right, :up => :move_up, :down => :move_down, :space => :fire}
end
#
@@ -32,7 +32,7 @@ def draw
#
# Gosus place for gamelogic is #update in the mainwindow
#
- # A #super call here would call #update on all Chingu::Actors and check their keymaps, and call the specified method.
+ # A #super call here would call #update on all Chingu::Actors and check their inputs, and call the specified method.
#
def update
View
@@ -9,7 +9,7 @@
class Game < Chingu::Window
def initialize
super
- self.keymap = {:left => :scroll_left, :right => :scroll_right, :escape => :close}
+ self.input = {:left => :scroll_left, :right => :scroll_right, :escape => :close}
@parallax = Chingu::Parallax.new(:x => 0, :y => 0, :center_x => 0, :center_y => 0)
View
@@ -31,6 +31,9 @@ class Game < Chingu::Window
def initialize
super
push_gamestate(Intro)
+
+ # Yes you can do crazy things like this :)
+ self.input = { :left_mouse_button => lambda{Chingu::Text.new(:text => "Woff!")}}
end
end
@@ -42,6 +45,7 @@ def initialize(options)
super
@image = Image["spaceship.png"]
end
+
def move_left; @x -= 1; end
def move_right; @x += 1; end
def move_up; @y -= 1; end
@@ -54,7 +58,7 @@ def move_down; @y += 1; end
class Intro < Chingu::GameState
def setup
@title = Chingu::Text.new(:text=>"Intro (press space)", :x=>200, :y=>50, :size=>30)
- self.keymap = { :space => Menu, :escape => :close }
+ self.input = { :space => Menu, :escape => :close }
end
end
@@ -64,7 +68,7 @@ def setup
class Menu < Chingu::GameState
def setup
@title = Chingu::Text.new(:text => "GameState Menu (press 'm')", :x => 200, :y => 50, :size=>30)
- self.keymap = { :m => Level.new(:level => 10) }
+ self.input = { :m => Level.new(:level => 10) }
end
end
@@ -75,12 +79,12 @@ class Level < Chingu::GameState
def setup
@title = Chingu::Text.new(:text=>"Level #{options[:level].to_s}. Pause with 'P'", :x=>200, :y=>10, :size => 30)
@player = Player.new(:x => 200, :y => 200)
- @player.keymap = {:left => :move_left, :right => :move_right, :up => :move_up, :down => :move_down, :left_ctrl => :fire}
+ @player.input = {:left => :move_left, :right => :move_right, :up => :move_up, :down => :move_down, :left_ctrl => :fire}
#
- # The keymapper understands gamestates, when 'p' is pressed push_gamegate(Pause) will be called.
+ # The input-handler understands gamestates. P is pressed --> push_gamegate(Pause)
#
- self.keymap = {:p => Pause, :escape => :close}
+ self.input = {:p => Pause, :escape => :close}
end
end
@@ -90,7 +94,7 @@ def setup
class Pause < Chingu::GameState
def setup
@title = Chingu::Text.new(:text=>"PAUSED (press 'u' to un-pause)", :x=>100, :y=>200, :size=>20, :color => Color.new(0xFF00FF00))
- self.keymap = { :u => :un_pause }
+ self.input = { :u => :un_pause }
end
def un_pause
View
@@ -17,13 +17,13 @@
data_structures
rect
animation
- keymap
+ input
parallax
}.each do |lib|
root ||= File.dirname(File.expand_path(__FILE__))
require File.join(root,"chingu",lib)
end
module Chingu
- VERSION = "0.0.2"
+ VERSION = "0.2.0"
end
@@ -6,10 +6,8 @@ module Chingu
# All objects that inherits from this class will automaticly be updated and drawn.
#
class GameObject
- #include Chingu::KeymapHelpers
-
attr_accessor :image, :x, :y, :angle, :center_x, :center_y, :factor_x, :factor_y, :mode
- attr_accessor :update, :draw, :keymap
+ attr_accessor :update, :draw, :input
attr_reader :options
#
@@ -77,7 +75,7 @@ def initialize(options = {})
# gameloop/framework logic
@update = options[:update] || true
@draw = options[:draw] || true
- @keymap = options[:keymap] || nil
+ @input = options[:input] || nil
#
# A GameObject can either belong to a GameState or our mainwindow ($window)
View
@@ -5,12 +5,12 @@ class GameState
attr_reader :options # so jac can access his :level-number
attr_reader :game_objects
- attr_accessor :keymap
+ attr_accessor :input
def initialize(options = {})
@options = options
@game_objects = Array.new
- @keymap = nil
+ @input = options[:input]
$window.game_state_manager.inside_state = self
setup
end
View
@@ -1,5 +1,5 @@
module Chingu
- module Keymap
+ module Input
include Gosu::Button
#
@@ -28,7 +28,7 @@ module Keymap
KbInsert => [:insert, :ins],
KbLeft => [:left],
KbLeftAlt => [:left_alt, :lalt],
- KbLeftControl => [:left_controll, :left_ctrl, :lctrl],
+ KbLeftControl => [:left_control, :left_ctrl, :lctrl],
KbLeftShift => [:left_shift, :lshift],
@@ -54,10 +54,10 @@ module Keymap
MsWheelDown => [:mouse_wheel_down, :wheel_down],
MsWheelUp => [:mouse_wheel_up, :wheel_up],
- GpDown => [:gamepad_down, :gp_down],
- GpLeft => [:gamepad_left, :gp_left],
- GpRight => [:gamepad_right, :gp_right],
- GpUp => [:gamepad_up, :gp_up]
+ GpDown => [:gamepad_down, :gp_down, :pad_down],
+ GpLeft => [:gamepad_left, :gp_left, :pad_left],
+ GpRight => [:gamepad_right, :gp_right, :pad_right],
+ GpUp => [:gamepad_up, :gp_up, :pad_up]
}
# Letters, A-Z
Oops, something went wrong.

0 comments on commit 2ae593b

Please sign in to comment.