ippa-chingu 0.4.7 → 0.4.8

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
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{chingu}
5
- s.version = "0.4.7"
5
+ s.version = "0.4.8"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["ippa"]
9
- s.date = %q{2009-08-28}
9
+ s.date = %q{2009-08-30}
10
10
  s.description = %q{Game framework built on top of the OpenGL accelerated game lib Gosu.
11
11
  It adds simple yet powerfull game states, prettier inputhandling, deploymentsafe asset-handling, a basic re-usable game object and automation of common task.}
12
12
  s.email = ["ippa@rubylicio.us"]
@@ -19,15 +19,17 @@ module Chingu
19
19
  #
20
20
  #
21
21
  def initialize(options)
22
- @loop = options[:loop] || true
23
- @bounce = options[:bounce] || false
22
+ options = {:loop => true, :bounce => false, :width => 32, :height => 32, :index => 0, :delay => 100}.merge(options)
23
+
24
+ @loop = options[:loop]
25
+ @bounce = options[:bounce]
24
26
  @file = options[:file]
25
- @height = options[:height] || 32
26
- @width = options[:width] || 32
27
- @index = options[:index] || 0
28
- @delay = options[:delay] || 100
27
+ @height = options[:height]
28
+ @width = options[:width]
29
+ @index = options[:index]
30
+ @delay = options[:delay]
29
31
  @dt = 0
30
-
32
+
31
33
  @frame_actions = []
32
34
  @frames = Gosu::Image.load_tiles($window, @file, @width, @height, true)
33
35
  @step = 1
@@ -74,19 +76,18 @@ module Chingu
74
76
  def next!
75
77
  if (@dt += $window.milliseconds_since_last_tick) > @delay
76
78
  @dt = 0
79
+ @previous_index = @index
77
80
  @index += @step
78
81
 
79
82
  # Has the animation hit end or beginning... time for bounce or loop?
80
83
  if (@index >= @frames.size || @index < 0)
81
84
  if @bounce
82
- if @step == 1
83
- @step = -1
84
- else
85
- @step = 1
86
- end
85
+ @step *= -1 # invert number
87
86
  @index += @step
88
87
  elsif @loop
89
88
  @index = 0
89
+ else
90
+ @index = @previous_index # no bounce or loop, use previous frame
90
91
  end
91
92
  end
92
93
  @frame_actions[@index].call if @frame_actions[@index]
@@ -6,7 +6,7 @@ module Chingu
6
6
  # All objects that inherits from this class will automaticly be updated and drawn.
7
7
  #
8
8
  class GameObject
9
- attr_accessor :image, :x, :y, :angle, :center_x, :center_y, :factor_x, :factor_y, :color, :mode
9
+ attr_accessor :image, :x, :y, :angle, :center_x, :center_y, :factor_x, :factor_y, :color, :mode, :zorder
10
10
  attr_accessor :update, :draw
11
11
  attr_reader :options, :parent
12
12
 
data/lib/chingu.rb CHANGED
@@ -34,5 +34,5 @@ require 'set'
34
34
  end
35
35
 
36
36
  module Chingu
37
- VERSION = "0.4.7"
37
+ VERSION = "0.4.8"
38
38
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ippa-chingu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.7
4
+ version: 0.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - ippa
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-28 00:00:00 -07:00
12
+ date: 2009-08-30 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -80,7 +80,6 @@ files:
80
80
  - lib/chingu/window.rb
81
81
  has_rdoc: false
82
82
  homepage: http://github.com/ippa/chingu/tree/master
83
- licenses:
84
83
  post_install_message:
85
84
  rdoc_options:
86
85
  - --main
@@ -102,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
101
  requirements: []
103
102
 
104
103
  rubyforge_project: chingu
105
- rubygems_version: 1.3.5
104
+ rubygems_version: 1.2.0
106
105
  signing_key:
107
106
  specification_version: 3
108
107
  summary: Game framework built on top of the OpenGL accelerated game lib Gosu