Sha256: 98bba96dd518a44c7afaea73c87565876b0e45793f523b6c6af064172bca42c2

Contents?: true

Size: 437 Bytes

Versions: 82

Compression:

Stored size: 437 Bytes

Contents

# -*- coding: utf-8 -*-
require 'smalruby'

car1 = Character.new(x: 0, y: 0, costume: 'car1.png')
car2 = Character.new(x: 639, y: 0, costume: 'car2.png')

car1.on(:start) do
  loop do
    move(5)
    if reach_wall?
      turn
    end
  end
end

car1.on(:hit, car2) do
  move_back(20)
  turn
end

car2.on(:start) do
  loop do
    move(10)
    if reach_wall?
      turn
    end
  end
end

car2.on(:hit, car1) do
  move_back(20)
  turn
end

Version data entries

82 entries across 82 versions & 1 rubygems

Version Path
smalruby-0.1.11-x86-mingw32 samples/hit_car.rb
smalruby-0.1.11 samples/hit_car.rb
smalruby-0.1.10-x86-mingw32 samples/hit_car.rb
smalruby-0.1.10 samples/hit_car.rb
smalruby-0.1.9-x86-mingw32 samples/hit_car.rb
smalruby-0.1.9 samples/hit_car.rb
smalruby-0.1.8-x86-mingw32 samples/hit_car.rb
smalruby-0.1.8 samples/hit_car.rb
smalruby-0.1.7-x86-mingw32 samples/hit_car.rb
smalruby-0.1.7 samples/hit_car.rb
smalruby-0.1.6-x86-mingw32 samples/hit_car.rb
smalruby-0.1.6 samples/hit_car.rb
smalruby-0.1.5-x86-mingw32 samples/hit_car.rb
smalruby-0.1.5 samples/hit_car.rb
smalruby-0.1.4-x86-mingw32 samples/hit_car.rb
smalruby-0.1.4 samples/hit_car.rb
smalruby-0.1.3-x86-mingw32 samples/hit_car.rb
smalruby-0.1.3 samples/hit_car.rb
smalruby-0.1.2-x86-mingw32 samples/hit_car.rb
smalruby-0.1.2 samples/hit_car.rb