Skip to content

Commit 1ad553c

Browse files
committed
Add smaug support and run in 2.16
1 parent 24a2bd9 commit 1ad553c

File tree

9 files changed

+62
-65
lines changed

9 files changed

+62
-65
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@
1313
# ToR
1414
/guides
1515
/mygame/app/texts.rb
16+
/mygame/exceptions/*.txt
17+
/mygame/logs/*.txt

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ $ cp /path/to/dragonruby-macos/font.ttf .
2727
$ ./dragonruby
2828
```
2929

30+
## Run with smaug
31+
32+
```bash
33+
cd mygame
34+
smaug install
35+
smaug run
36+
```
37+
3038
## Package
3139

3240
```

docs/gamedata/app/main.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def output
5252
y: grid.center_y,
5353
text: state.text,
5454
alignment_enum: 1,
55+
vertical_alignment_enum: 1,
5556
font: FONTS[:code],
5657
size_enum: 10,
5758
r: 150,
@@ -64,6 +65,7 @@ def output
6465
y: grid.center_y,
6566
text: state.input + ' ' * (state.text.size - state.input.size),
6667
alignment_enum: 1,
68+
vertical_alignment_enum: 1,
6769
font: FONTS[:code_bold],
6870
size_enum: 10
6971
)
@@ -73,6 +75,7 @@ def output
7375
y: grid.center_y - 20,
7476
text: ' ' * state.input.size + '_' + ' ' * [state.text.size - state.input.size - 1, 0].max,
7577
alignment_enum: 1,
78+
vertical_alignment_enum: 1,
7679
font: FONTS[:code],
7780
size_enum: 10
7881
)
@@ -88,6 +91,7 @@ def output
8891
y: grid.h * 0.9,
8992
text: [minutes, seconds, milliseconds10].map { |t| '%02d' % t }.join(':'),
9093
alignment_enum: 0,
94+
vertical_alignment_enum: 1,
9195
font: FONTS[:base],
9296
size_enum: -1
9397
)
@@ -97,6 +101,7 @@ def output
97101
y: grid.h * 0.9,
98102
text: "WPM: %.1f" % state.wpm.to_s,
99103
alignment_enum: 2,
104+
vertical_alignment_enum: 1,
100105
font: FONTS[:base],
101106
size_enum: -1
102107
)

docs/gamedata/app/primitives.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Line < Primitive
3535
end
3636

3737
class Label < Primitive
38-
@@attr_keys = %i[x y text size_enum alignment_enum font r g b a]
38+
@@attr_keys = %i[x y text size_enum alignment_enum vertical_alignment_enum font r g b a]
3939
attr_accessor(*@@attr_keys)
4040
end
4141

mygame/.smaugignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
logs/
2+
builds/
3+
exceptions
4+
Smaug.toml

mygame/Smaug.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[project]
2+
# The name of your game's executable. This should only contain a-z, A-Z, 0-9, _ or -.
3+
name = "typing-on-rails"
4+
# The game's title. This will show up in the tile bar of your executable.
5+
title = "Typing on Rails"
6+
version = "0.1"
7+
authors = ["tnantoka"]
8+
icon = "metadata/icon.png"
9+
compile_ruby = false
10+
11+
[dragonruby]
12+
version = "2.16"
13+
edition = "pro"
14+
15+
[dependencies]
16+
17+
[itch]
18+
# The Project URL you set when you created the game on Itch.io. https://my-username.itch.io/my-game.
19+
# This will also be the name of your build files, so fill it out even if you aren't uploading to Itch.io.
20+
url = "todo-change-me"
21+
# Your username on Itch.io.
22+
username = "todo-change-me"

mygame/app/main.rb

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
require 'app/primitives.rb'
21
require 'app/texts.rb'
32

43
class Game
@@ -47,59 +46,64 @@ def update_state
4746
def output
4847
outputs.background_color = [245, 245, 245]
4948

50-
outputs.labels << Label.new(
49+
outputs.labels << {
5150
x: grid.center_x,
5251
y: grid.center_y,
5352
text: state.text,
5453
alignment_enum: 1,
54+
vertical_alignment_enum: 1,
5555
font: FONTS[:code],
5656
size_enum: 10,
5757
r: 150,
5858
g: 150,
5959
b: 150
60-
)
60+
}.label
6161

62-
outputs.labels << Label.new(
62+
outputs.labels << {
6363
x: grid.center_x,
6464
y: grid.center_y,
6565
text: state.input + ' ' * (state.text.size - state.input.size),
6666
alignment_enum: 1,
67+
vertical_alignment_enum: 1,
6768
font: FONTS[:code_bold],
6869
size_enum: 10
69-
)
70+
}.label
7071

71-
outputs.labels << Label.new(
72+
outputs.labels << {
7273
x: grid.center_x,
7374
y: grid.center_y - 20,
7475
text: ' ' * state.input.size + '_' + ' ' * [state.text.size - state.input.size - 1, 0].max,
7576
alignment_enum: 1,
77+
vertical_alignment_enum: 1,
7678
font: FONTS[:code],
7779
size_enum: 10
78-
)
80+
}.label
7981

8082

8183
time = elapsed_time
8284
minutes = (time.to_i / 60).floor
8385
seconds = time.to_i % 60
8486
milliseconds10 = time * 100 % 100
8587

86-
outputs.labels << Label.new(
88+
outputs.labels << {
8789
x: grid.w * 0.1,
8890
y: grid.h * 0.9,
8991
text: [minutes, seconds, milliseconds10].map { |t| '%02d' % t }.join(':'),
9092
alignment_enum: 0,
93+
vertical_alignment_enum: 1,
9194
font: FONTS[:base],
9295
size_enum: -1
93-
)
96+
}.label
9497

95-
outputs.labels << Label.new(
98+
outputs.labels << {
9699
x: grid.w * 0.9,
97100
y: grid.h * 0.9,
98101
text: "WPM: %.1f" % state.wpm.to_s,
99102
alignment_enum: 2,
103+
vertical_alignment_enum: 1,
100104
font: FONTS[:base],
101105
size_enum: -1
102-
)
106+
}.label
103107
end
104108

105109
def serialize

mygame/app/primitives.rb

Lines changed: 0 additions & 51 deletions
This file was deleted.

mygame/metadata/game_metadata.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
devid=tnantoka
1+
# This file was automatically @generated by Smaug.
2+
# Do not manually edit this file. Edit Smaug.toml instead.
3+
4+
devid=dragonrider
25
devtitle=tnantoka
36
gameid=typing-on-rails
47
gametitle=Typing on Rails
58
version=0.1
69
icon=metadata/icon.png
7-
10+
compile_ruby=false

0 commit comments

Comments
 (0)