Skip to content

Add smaug support and run in 2.16 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
# ToR
/guides
/mygame/app/texts.rb
/mygame/exceptions/*.txt
/mygame/logs/*.txt
/mygame/builds/*
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ $ cp /path/to/dragonruby-macos/font.ttf .
$ ./dragonruby
```

## Run with smaug

```bash
cd mygame
smaug install
smaug run
```

## Package

```
Expand Down
5 changes: 5 additions & 0 deletions docs/gamedata/app/main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def output
y: grid.center_y,
text: state.text,
alignment_enum: 1,
vertical_alignment_enum: 1,
font: FONTS[:code],
size_enum: 10,
r: 150,
Expand All @@ -64,6 +65,7 @@ def output
y: grid.center_y,
text: state.input + ' ' * (state.text.size - state.input.size),
alignment_enum: 1,
vertical_alignment_enum: 1,
font: FONTS[:code_bold],
size_enum: 10
)
Expand All @@ -73,6 +75,7 @@ def output
y: grid.center_y - 20,
text: ' ' * state.input.size + '_' + ' ' * [state.text.size - state.input.size - 1, 0].max,
alignment_enum: 1,
vertical_alignment_enum: 1,
font: FONTS[:code],
size_enum: 10
)
Expand All @@ -88,6 +91,7 @@ def output
y: grid.h * 0.9,
text: [minutes, seconds, milliseconds10].map { |t| '%02d' % t }.join(':'),
alignment_enum: 0,
vertical_alignment_enum: 1,
font: FONTS[:base],
size_enum: -1
)
Expand All @@ -97,6 +101,7 @@ def output
y: grid.h * 0.9,
text: "WPM: %.1f" % state.wpm.to_s,
alignment_enum: 2,
vertical_alignment_enum: 1,
font: FONTS[:base],
size_enum: -1
)
Expand Down
2 changes: 1 addition & 1 deletion docs/gamedata/app/primitives.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Line < Primitive
end

class Label < Primitive
@@attr_keys = %i[x y text size_enum alignment_enum font r g b a]
@@attr_keys = %i[x y text size_enum alignment_enum vertical_alignment_enum font r g b a]
attr_accessor(*@@attr_keys)
end

Expand Down
4 changes: 4 additions & 0 deletions mygame/.smaugignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
logs/
builds/
exceptions
Smaug.toml
22 changes: 22 additions & 0 deletions mygame/Smaug.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[project]
# The name of your game's executable. This should only contain a-z, A-Z, 0-9, _ or -.
name = "typing-on-rails"
# The game's title. This will show up in the tile bar of your executable.
title = "Typing on Rails"
version = "0.1"
authors = ["tnantoka"]
icon = "metadata/icon.png"
compile_ruby = false

[dragonruby]
version = "2.17"
edition = "pro"

[dependencies]

[itch]
# The Project URL you set when you created the game on Itch.io. https://my-username.itch.io/my-game.
# This will also be the name of your build files, so fill it out even if you aren't uploading to Itch.io.
url = "todo-change-me"
# Your username on Itch.io.
username = "todo-change-me"
26 changes: 15 additions & 11 deletions mygame/app/main.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'app/primitives.rb'
require 'app/texts.rb'

class Game
Expand Down Expand Up @@ -47,59 +46,64 @@ def update_state
def output
outputs.background_color = [245, 245, 245]

outputs.labels << Label.new(
outputs.labels << {
x: grid.center_x,
y: grid.center_y,
text: state.text,
alignment_enum: 1,
vertical_alignment_enum: 1,
font: FONTS[:code],
size_enum: 10,
r: 150,
g: 150,
b: 150
)
}.label

outputs.labels << Label.new(
outputs.labels << {
x: grid.center_x,
y: grid.center_y,
text: state.input + ' ' * (state.text.size - state.input.size),
alignment_enum: 1,
vertical_alignment_enum: 1,
font: FONTS[:code_bold],
size_enum: 10
)
}.label

outputs.labels << Label.new(
outputs.labels << {
x: grid.center_x,
y: grid.center_y - 20,
text: ' ' * state.input.size + '_' + ' ' * [state.text.size - state.input.size - 1, 0].max,
alignment_enum: 1,
vertical_alignment_enum: 1,
font: FONTS[:code],
size_enum: 10
)
}.label


time = elapsed_time
minutes = (time.to_i / 60).floor
seconds = time.to_i % 60
milliseconds10 = time * 100 % 100

outputs.labels << Label.new(
outputs.labels << {
x: grid.w * 0.1,
y: grid.h * 0.9,
text: [minutes, seconds, milliseconds10].map { |t| '%02d' % t }.join(':'),
alignment_enum: 0,
vertical_alignment_enum: 1,
font: FONTS[:base],
size_enum: -1
)
}.label

outputs.labels << Label.new(
outputs.labels << {
x: grid.w * 0.9,
y: grid.h * 0.9,
text: "WPM: %.1f" % state.wpm.to_s,
alignment_enum: 2,
vertical_alignment_enum: 1,
font: FONTS[:base],
size_enum: -1
)
}.label
end

def serialize
Expand Down
51 changes: 0 additions & 51 deletions mygame/app/primitives.rb

This file was deleted.

7 changes: 5 additions & 2 deletions mygame/metadata/game_metadata.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
devid=tnantoka
# This file was automatically @generated by Smaug.
# Do not manually edit this file. Edit Smaug.toml instead.

devid=dragonrider
devtitle=tnantoka
gameid=typing-on-rails
gametitle=Typing on Rails
version=0.1
icon=metadata/icon.png

compile_ruby=false