Skip to content

Commit 7e68e68

Browse files
author
Artur Ostręga
committed
Update example
1 parent fe183c1 commit 7e68e68

File tree

6 files changed

+27
-35
lines changed

6 files changed

+27
-35
lines changed

example/src/looks/cloud_look.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require 'yeah/fill_look' #
2-
31
class CloudLook < Yeah::FillLook #
42
#class CloudLook < FillLook
53
self.size = 120, 20

example/src/looks/duck_look.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
require 'yeah/image_look' #
2-
31
class DuckLook < Yeah::ImageLook #
42
#class DuckLook < ImageLook
5-
self.image = "duck.jpg" #
3+
self.image = Yeah::Image['duck.jpg'] #
64
end

example/src/looks/guy_look.rb

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
require 'yeah/sprite_look' #
2-
31
class GuyLook < Yeah::SpriteLook #
4-
#class GuyLook < ImageLook
5-
self.image = "guy.png" #
2+
#class GuyLook < SpriteLook
3+
self.image = Yeah::Image['guy.png'] #
64
self.size = 64, 64
75

86
self.animations = {
9-
walk_up: (0..8),
10-
walk_left: (9..17),
11-
walk_down: (18..26),
12-
walk_right: { frames: (27..35), mirror_x: false },
137
stand_up: 0,
148
stand_left: 9,
159
stand_down: 18,
16-
stand_right: 27
10+
stand_right: 27,
11+
walk_up: (0..8),
12+
walk_left: (9..17),
13+
walk_down: (18..26),
14+
walk_right: (27..35)
1715
}
1816
end

example/src/things/cloud.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
require 'yeah/thing' #
21
require 'looks/cloud_look' #
32

43
class Cloud < Yeah::Thing #

example/src/things/duck.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
require 'yeah/thing' #
21
require 'looks/duck_look' #
32

43
class Duck < Yeah::Thing #

example/src/things/guy.rb

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
1-
require 'yeah/thing' #
21
require 'looks/guy_look' #
32

43
class Guy < Yeah::Thing
54
#class Guy < Thing
65
self.look = GuyLook #
76

87
def act(elapsed)
9-
walked = false
10-
11-
if keyboard.pressing? :left
12-
look.animation = :walk_left
13-
self.x -= speed * elapsed
14-
walked = true
15-
end
8+
walking = false
169

1710
if keyboard.pressing? :right
18-
look.animation = :walk_right
1911
self.x += speed * elapsed
20-
walked = true
12+
look.animation = :walk_right if keyboard.pressed? :right
13+
walking = true
2114
end
2215

23-
if keyboard.pressing? :down
24-
look.animation = :walk_down
25-
self.y -= speed * elapsed
26-
walked = true
16+
if keyboard.pressing? :left
17+
self.x -= speed * elapsed
18+
look.animation = :walk_left if keyboard.pressed? :left
19+
walking = true
2720
end
2821

2922
if keyboard.pressing? :up
30-
look.animation = :walk_up
3123
self.y += speed * elapsed
32-
walked = true
24+
look.animation = :walk_up if keyboard.pressed? :up
25+
walking = true
3326
end
3427

35-
unless walked
36-
look.animation = :stand_left if keyboard.released? :left
28+
if keyboard.pressing? :down
29+
self.y -= speed * elapsed
30+
look.animation = :walk_down if keyboard.pressed? :down
31+
walking = true
32+
end
33+
34+
unless walking
3735
look.animation = :stand_right if keyboard.released? :right
38-
look.animation = :stand_down if keyboard.released? :down
36+
look.animation = :stand_left if keyboard.released? :left
3937
look.animation = :stand_up if keyboard.released? :up
38+
look.animation = :stand_down if keyboard.released? :down
4039
end
40+
4141
end
4242

4343
def speed

0 commit comments

Comments
 (0)