chingu 0.8.0.2 → 0.8.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{chingu}
8
- s.version = "0.8.0.2"
8
+ s.version = "0.8.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["ippa"]
12
- s.date = %q{2010-12-14}
12
+ s.date = %q{2010-12-20}
13
13
  s.description = %q{OpenGL accelerated 2D game framework for Ruby. Builds on Gosu (Ruby/C++) which provides all the core functionality. Chingu adds simple yet powerful game states, prettier input handling, deployment safe asset-handling, a basic re-usable game object and stackable game logic.}
14
14
  s.email = %q{ippa@rubylicio.us}
15
15
  s.extra_rdoc_files = [
@@ -37,7 +37,7 @@ require_all "#{CHINGU_ROOT}/chingu/traits"
37
37
  require_all "#{CHINGU_ROOT}/chingu"
38
38
 
39
39
  module Chingu
40
- VERSION = "0.8.0.2"
40
+ VERSION = "0.8.0.3"
41
41
 
42
42
  DEBUG_COLOR = Gosu::Color.new(0xFFFF0000)
43
43
  DEBUG_ZORDER = 9999
@@ -62,6 +62,7 @@ module Chingu
62
62
  @except = options[:except] || []
63
63
  @classes -= Array(@except)
64
64
  @debug = options[:debug]
65
+ @attributes = options[:attributes] || [:x, :y, :angle, :zorder, :factor_x, :factor_y, :alpha]
65
66
 
66
67
  #
67
68
  # Turn on cursor + turn it back to its original value in finalize()
@@ -489,7 +490,7 @@ END_OF_STRING
489
490
  pop_game_state
490
491
  end
491
492
  def save
492
- save_game_objects(:game_objects => editable_game_objects, :file => @file, :classes => @classes)
493
+ save_game_objects(:game_objects => editable_game_objects, :file => @file, :classes => @classes, :attributes => @attributes)
493
494
  end
494
495
  def save_and_quit
495
496
  save unless holding?(:left_ctrl)
@@ -102,7 +102,13 @@ module Chingu
102
102
  next if classes and !classes.empty? and !classes.include?(game_object.class)
103
103
 
104
104
  attr_hash = {}
105
- attributes.each { |attr| attr_hash[attr] = game_object.send(attr) }
105
+ attributes.each do |attr|
106
+ begin
107
+ attr_hash[attr] = game_object.send(attr)
108
+ rescue NoMethodError
109
+ # silently ignore attributes that doesn't exist on the particular game object
110
+ end
111
+ end
106
112
  objects << {game_object.class.to_s => attr_hash}
107
113
  end
108
114
 
@@ -55,6 +55,15 @@ module Chingu
55
55
 
56
56
  super
57
57
  end
58
+
59
+ #
60
+ # Let's have some useful information in to_s()
61
+ #
62
+ def to_s
63
+ "#{self.class.to_s} @ #{x.to_i} / #{y.to_i} " <<
64
+ "(#{width.to_i} x #{height.to_i}) - " <<
65
+ " ratio: #{sprintf("%.2f",width/height)} scale: #{sprintf("%.2f", factor_x)}/#{sprintf("%.2f", factor_y)} angle: #{angle.to_i} zorder: #{zorder} alpha: #{alpha}"
66
+ end
58
67
 
59
68
  def color=(color)
60
69
  @color = color.is_a?(Gosu::Color) ? color : Gosu::Color.new(color || 0xFFFFFFFF)
@@ -54,6 +54,8 @@ module Chingu
54
54
  # Center the viewport around the given object (it must respont to x/y)
55
55
  # Center will fail if object is in the corners of the game area
56
56
  #
57
+ # TODO: Add support for x,y here!
58
+ #
57
59
  def center_around(object)
58
60
  self.x = object.x - $window.width / 2
59
61
  self.y = object.y - $window.height / 2
@@ -89,7 +91,7 @@ module Chingu
89
91
  end
90
92
 
91
93
  # Returns true object is outside the view port
92
- def outside?(object, y)
94
+ def outside?(object, y = nil)
93
95
  not inside?(object, y)
94
96
  end
95
97
 
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 0
7
7
  - 8
8
8
  - 0
9
- - 2
10
- version: 0.8.0.2
9
+ - 3
10
+ version: 0.8.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - ippa
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-14 00:00:00 +01:00
18
+ date: 2010-12-20 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency