File tree Expand file tree Collapse file tree 4 files changed +25
-11
lines changed
Expand file tree Collapse file tree 4 files changed +25
-11
lines changed Original file line number Diff line number Diff line change 11require 'spaces/world' #
22
3- class Example < Yeah ::Game
4- #class Example < Game
3+ class Game < Yeah ::Game
4+ self . title = "Example Game"
55 display . size = 640 , 360
66 self . space = World
77end
Original file line number Diff line number Diff line change 44class World < Yeah ::Space #
55#class World < Space
66 self . size = 640 , 360
7- self . clear_color = 0.5 , 0.7 , 0.5
7+ self . color = 0.5 , 0.7 , 0.5
88
9- def initialize
9+ def initialize ( game )
1010 super
1111
12- things << Cloud . new ( x : width * 0.6 , y : height * 0.8 )
13- things << Cloud . new ( x : width * 0.2 , y : height * 0.7 )
14- things << Cloud . new ( x : width * 0.1 , y : height * 0.9 )
15- things << Duck . new ( x : 10 , y : 10 )
12+ things << Cloud . new ( game : game , x : width * 0.6 , y : height * 0.8 )
13+ things << Cloud . new ( game : game , x : width * 0.2 , y : height * 0.7 )
14+ things << Cloud . new ( game : game , x : width * 0.1 , y : height * 0.9 )
15+ things << Duck . new ( game : game , x : 10 , y : 10 )
1616 #things << Duck.new(position: Vec2.divide(size, 2))
1717 end
1818end
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ class Cloud < Yeah::Thing #
44#class Cloud < Thing
55 self . look = CloudLook #
66
7- def act ( input , space , elapsed )
7+ def act ( elapsed )
88 self . x -= 10 * elapsed
99 end
1010end
Original file line number Diff line number Diff line change @@ -5,7 +5,21 @@ class Duck < Yeah::Thing #
55#class Duck < Thing
66 self . look = DuckLook #
77
8- def act ( input , space , elapsed )
9- self . x += 30 * elapsed
8+ def act ( elapsed )
9+ if keyboard . pressing? :left
10+ self . x -= speed * elapsed
11+ end
12+
13+ if keyboard . pressing? :right
14+ self . x += speed * elapsed
15+ end
16+
17+ if keyboard . released? :space
18+ puts "Quack!"
19+ end
20+ end
21+
22+ def speed
23+ 30
1024 end
1125end
You can’t perform that action at this time.
0 commit comments