Skip to content

Commit 41b4d98

Browse files
author
Artur Ostręga
committed
Extend example
1 parent a29fe02 commit 41b4d98

File tree

8 files changed

+56
-7
lines changed

8 files changed

+56
-7
lines changed

example/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Example Game
22

3-
Barebones example game for Yeah
3+
Barebones example game for Yeah, a work in progress
44

55
## Usage
66

example/assets/images/duck.jpg

75.7 KB
Loading

example/src/game.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
class ExampleGame < Yeah::Game
2-
def initialize
3-
super
1+
require 'spaces/world' #
42

5-
puts "Hello!"
6-
display.size = 320, 240
7-
end
3+
class Example < Yeah::Game
4+
#class Example < Game
5+
display.size = 320, 240
6+
self.space = World
87
end

example/src/looks/cloud_look.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require 'yeah/fill_look' #
2+
3+
class CloudLook < Yeah::FillLook #
4+
#class CloudLook < FillLook
5+
self.size = 120, 20
6+
self.color = 0.8, 0.8, 0.9
7+
end

example/src/looks/duck_look.rb

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

example/src/spaces/world.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
require 'things/duck' #
2+
require 'things/cloud' #
3+
4+
class World < Yeah::Space #
5+
#class World < Space
6+
self.size = 320, 240
7+
self.clear_color = 0.5, 0.7, 0.5
8+
9+
def initialize
10+
super
11+
12+
things << Cloud.new(x: width * 0.6, y: height * 0.8)
13+
things << Duck.new(x: width / 2, y: height / 2)
14+
#things << Duck.new(position: Vec2.divide(size, 2))
15+
end
16+
end

example/src/things/cloud.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
require 'looks/cloud_look' #
2+
3+
class Cloud < Yeah::Thing #
4+
#class Cloud < Thing
5+
self.look = CloudLook #
6+
7+
def act(input, space)
8+
self.x -= 1
9+
end
10+
end

example/src/things/duck.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require 'yeah/thing' #
2+
require 'looks/duck_look' #
3+
4+
class Duck < Yeah::Thing #
5+
#class Duck < Thing
6+
self.look = DuckLook #
7+
8+
def act(input, space)
9+
puts "Quack" if rand > 0.8
10+
end
11+
end

0 commit comments

Comments
 (0)