Skip to content

Instantly share code, notes, and snippets.

@mh61503891
Created June 9, 2014 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mh61503891/6baa4922283bf9f92b0a to your computer and use it in GitHub Desktop.
Save mh61503891/6baa4922283bf9f92b0a to your computer and use it in GitHub Desktop.
猫キャッチボール
require "smalruby"
ball1 = Character.new(costume: "ball6.png", x: 0, y: 0, angle: 0)
cat1 = Character.new(costume: "cat1.png", x: 0, y: 0, angle: 0)
cat2 = Character.new(costume: "cat2.png", x: 0, y: 0, angle: 0)
ball1.on(:start) do
loop do
move(35)
if 100 >= (cat1.x - x).abs && 100 >= (cat1.y - y).abs
go_to(cat1)
else
if hit?(cat2)
point_towards(cat1)
end
end
end
end
ball1.on(:key_push, K_SPACE) do
if hit?(cat1)
point_towards(cat2)
if cat2.x - cat1.x >= 0
self.x = 110 + cat1.x
else
self.x = -110 + cat1.x
end
if cat2.y - cat1.y >= 0
self.y = 110 + cat1.y
else
self.y = -110 + cat1.y
end
end
end
cat1.on(:start) do
loop do
go_to(:mouse)
end
end
cat1.on(:key_push, K_SPACE) do
say(message: "Д゜)ゴルァ!")
sleep(1)
say(message: "")
end
cat1.on(:start) do
say(message: "スペースで投げる")
sleep(5)
say(message: "")
end
cat2.on(:start) do
loop do
if 50 >= (cat1.x - ball1.x).abs && 50 >= (cat1.y - ball1.y).abs
point_towards(cat1)
rotate(180)
move(15)
say(message: " ∀・) マダカナ")
else
point_towards(ball1)
move(15)
if hit?(ball1)
say(message: "Д゜)ゴルァ!")
else
say(message: "∀゜)キター!")
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment