forked from ashes999/terrace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.rb
29 lines (25 loc) · 966 Bytes
/
main.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# This is your application entry point. Make sure it starts your game by
# calling Game.new(width, height). If you want to require other files, please
# use "#= require" instead of "require" by itself.
# Load the terrace library, and target-specific code. Do not remove these!
#= require ./lib/common/terrace_common.rb
#= require ./lib/TARGET/terrace.rb
g = Game.new(800, 600)
g.load_content({
:images => ['content/images/fox.png', 'content/images/emblem.png'],
:audio => ['content/audio/noise.ogg']
}, lambda {
touches = 0
t = Entity.new(TextComponent.new, TwoDComponent.new)
t.text('Touches: 0')
t.move(8, 8)
e = Entity.new(ImageComponent.new, KeyboardComponent.new, TwoDComponent.new, TouchComponent.new, AudioComponent.new)
e.image('content/images/fox.png')
e.move_with_keyboard
puts "Size of e is #{e.width}x#{e.height}"
e.touch(lambda {
e.play('content/audio/noise.ogg')
touches += 1
t.text("Touches: #{touches}")
})
})