chingu 0.7.6.3 → 0.7.6.4

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.
data/chingu.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{chingu}
8
- s.version = "0.7.6.3"
8
+ s.version = "0.7.6.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["ippa"]
data/lib/chingu.rb CHANGED
@@ -33,7 +33,7 @@ require_all "#{CHINGU_ROOT}/chingu/traits"
33
33
  require_all "#{CHINGU_ROOT}/chingu"
34
34
 
35
35
  module Chingu
36
- VERSION = "0.7.6.3"
36
+ VERSION = "0.7.6.4"
37
37
 
38
38
  DEBUG_COLOR = Gosu::Color.new(0xFFFF0000)
39
39
  DEBUG_ZORDER = 9999
@@ -53,10 +53,11 @@ module Chingu
53
53
  @classes = Array(options[:classes] || game_object_classes)
54
54
  @except = options[:except] || []
55
55
  @classes -= Array(@except)
56
-
57
56
  @debug = options[:debug]
58
57
  @zorder = 10000
59
58
 
59
+ p @classes if @debug
60
+
60
61
  @hud_color = Gosu::Color.new(180,70,70,70)
61
62
  @selected_game_object = nil
62
63
  self.input = {
@@ -124,19 +125,22 @@ module Chingu
124
125
 
125
126
  # We initialize x,y,zorder,rotation_center after creation
126
127
  # so they're not overwritten by the class initialize/setup or simular
127
- game_object = klass.create(:paused => true)
128
- game_object.x = x
129
- game_object.y = y
130
- game_object.zorder = @zorder
131
- game_object.options[:toolbar] = true
132
-
133
- # Scale down big objects, don't scale objects under [32, 32]
134
- if game_object.image
135
- game_object.factor_x = 32.0 / game_object.image.width if game_object.image.width > 32
136
- game_object.factor_y = 32.0 / game_object.image.height if game_object.image.height > 32
137
- game_object.cache_bounding_box if game_object.respond_to?(:cache_bounding_box)
138
- end
139
- x += 40
128
+ begin
129
+ game_object = klass.create(:paused => true)
130
+ game_object.x = x
131
+ game_object.y = y
132
+ game_object.zorder = @zorder
133
+ game_object.options[:toolbar] = true
134
+
135
+ # Scale down object to fit our toolbar
136
+ if game_object.image
137
+ game_object.size = [32,32]
138
+ game_object.cache_bounding_box if game_object.respond_to?(:cache_bounding_box)
139
+ end
140
+ x += 40
141
+ rescue
142
+ puts "Couldn't use #{klass} in editor."
143
+ end
140
144
  end
141
145
  end
142
146
 
@@ -272,6 +276,13 @@ module Chingu
272
276
  @selected_game_object.options[:selected] = true
273
277
  end
274
278
 
279
+ if holding?(:left_shift)
280
+ #puts @selected_game_object.class.all.size
281
+ previous_game_state.game_objects.select { |x| x.class == @selected_game_object.class }.each do |game_object|
282
+ game_object.options[:selected] = true
283
+ end
284
+ end
285
+
275
286
  #
276
287
  # Re-align all objects x/y offset in relevance to the cursor
277
288
  #
data/lib/chingu/text.rb CHANGED
@@ -80,7 +80,7 @@ module Chingu
80
80
  create_image unless @image
81
81
 
82
82
  if options[:background]
83
- @background = GameObject.create(:image => options[:background])
83
+ @background = GameObject.new(:image => options[:background])
84
84
  @background.attributes = self.attributes
85
85
  @background.color = Color::WHITE
86
86
  @background.zorder -= 1
@@ -28,7 +28,7 @@ module Chingu
28
28
  # Can be useful for example collision detection
29
29
  #
30
30
  module Velocity
31
- attr_accessor :velocity_x, :velocity_y, :acceleration_x, :acceleration_y, :max_velocity
31
+ attr_accessor :velocity_x, :velocity_y, :acceleration_x, :acceleration_y, :max_velocity_x, :max_velocity_y
32
32
  attr_reader :previous_x, :previous_y
33
33
 
34
34
  module ClassMethods
@@ -47,8 +47,11 @@ module Chingu
47
47
  @acceleration_x = options[:acceleration_x] || 0
48
48
  @acceleration_y = options[:acceleration_y] || 0
49
49
  self.acceleration = options[:acceleration] if options[:acceleration]
50
-
51
- @max_velocity = options[:max_velocity] || 1000
50
+
51
+ @max_velocity_x = options[:max_velocity_x] || 1000
52
+ @max_velocity_y = options[:max_velocity_y] || 1000
53
+ self.max_velocity = options[:max_velocity] if options[:max_velocity]
54
+
52
55
  super
53
56
  end
54
57
 
@@ -70,22 +73,31 @@ module Chingu
70
73
 
71
74
  def acceleration; [@acceleration_x, @acceleration_y]; end
72
75
 
76
+ #
77
+ # Sets X and Y acceleration with one single call. Takes an Array-argument with 2 values.
78
+ #
79
+ def max_velocity=(max_velocity)
80
+ @max_velocity_x, @max_velocity_y = max_velocity
81
+ end
82
+
83
+ def max_velocity; [@max_velocity_x, @max_velocity_y]; end
84
+
73
85
  #
74
86
  # Modifies X & Y of parent
75
87
  #
76
88
  def update_trait
77
- @velocity_y += @acceleration_y if (@velocity_y + @acceleration_y).abs < @max_velocity
78
- @velocity_x += @acceleration_x if (@velocity_x + @acceleration_x).abs < @max_velocity
89
+ @velocity_x += @acceleration_x if (@velocity_x + @acceleration_x).abs < @max_velocity_x
90
+ @velocity_y += @acceleration_y if (@velocity_y + @acceleration_y).abs < @max_velocity_y
79
91
 
80
- @previous_y = @y
81
92
  @previous_x = @x
93
+ @previous_y = @y
82
94
 
83
95
  #
84
96
  # if option :apply is false, just calculate velocities, don't apply them to x/y
85
97
  #
86
98
  unless trait_options[:velocity][:apply] == false
87
- self.y += @velocity_y
88
99
  self.x += @velocity_x
100
+ self.y += @velocity_y
89
101
  end
90
102
 
91
103
  super
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chingu
3
3
  version: !ruby/object:Gem::Version
4
- hash: 105
4
+ hash: 103
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
9
  - 6
10
- - 3
11
- version: 0.7.6.3
10
+ - 4
11
+ version: 0.7.6.4
12
12
  platform: ruby
13
13
  authors:
14
14
  - ippa