Sha256: 9aa44b7918a86253080272477bd53db614f1135c5510605411f02946c8fbb849

Contents?: true

Size: 1.77 KB

Versions: 5

Compression:

Stored size: 1.77 KB

Contents

require File.join(File.dirname(__FILE__),'helper')
require 'animated'

describe 'A new animated behavior' do
  before do
    @rm = stub(:load_animation_set => ['1.png_img_obj','2.png_img_obj'])

    opts = {:stage=>"stage", :input=>"input", :resources=>@rm}
    @actor = Actor.new opts
    @actor.should_receive(:is?).with(:updatable).and_return(true)
    @animated = Animated.new @actor
  end

  it 'should define methods on actor' do
    @actor.respond_to?(:image).should be(true)
    @actor.respond_to?(:start_animating).should be(true)
    @actor.respond_to?(:stop_animating).should be(true)
    @actor.respond_to?(:action=).should be(true)
    @actor.respond_to?(:animated).should be(true)
  end

  it 'shouldn\'t update frame for non-animating' do
    @animated.stop_animating

    @animated.update @animated.frame_update_time+1

    @animated.frame_time.should equal(0)
    @animated.frame_num.should equal(0)
  end

  it 'should update frame for animating' do
    time_passed = @animated.frame_update_time-1
    @animated.update time_passed
    @animated.frame_time.should equal(time_passed)
    @animated.frame_num.should equal(0)

    time_passed_again = 2
    @animated.update time_passed_again
    # we rolled over the time
    @animated.frame_time.should equal(1)
    @animated.frame_num.should equal(1)

    time_passed_again = @animated.frame_update_time
    @animated.update time_passed_again
    # we rolled over the time
    @animated.frame_time.should equal(1)
    @animated.frame_num.should equal(0)
  end

  it 'should stop animating' do
    @animated.stop_animating
    @animated.animating.should equal(false)
  end

  it 'should start animating' do
    @animated.start_animating
    @animated.animating.should equal(true)
  end

  it 'should set the action and animate accordingly'

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gamebox-0.2.1 spec/animated_spec.rb
gamebox-0.1.1 spec/animated_spec.rb
gamebox-0.1.0 spec/animated_spec.rb
gamebox-0.0.9 spec/animated_spec.rb
gamebox-0.0.8 spec/animated_spec.rb