Browse Source

Initial commit

master
ldk 3 years ago
commit
5e82f9125d
  1. 90
      .drone.yml
  2. 7
      .gitignore
  3. 26
      .smaugignore
  4. 6
      Dockerfile
  5. 9
      LICENSE
  6. 5
      README.md
  7. 22
      Smaug.toml
  8. 7
      app/main.rb
  9. 307
      app/repl.rb
  10. 29
      app/tests.rb
  11. 1
      data/.gitkeep
  12. 1
      fonts/.gitkeep
  13. 10
      metadata/game_metadata.txt
  14. BIN
      metadata/icon.png
  15. 14
      metadata/ios_metadata.txt
  16. 12
      nginx.conf
  17. 4
      smaug.rb
  18. 1
      sounds/.gitkeep
  19. BIN
      sprites/misc/dragon-0.png
  20. BIN
      sprites/misc/dragon-1.png
  21. BIN
      sprites/misc/dragon-2.png
  22. BIN
      sprites/misc/dragon-3.png
  23. BIN
      sprites/misc/dragon-4.png
  24. BIN
      sprites/misc/dragon-5.png
  25. BIN
      sprites/misc/explosion-0.png
  26. BIN
      sprites/misc/explosion-1.png
  27. BIN
      sprites/misc/explosion-2.png
  28. BIN
      sprites/misc/explosion-3.png
  29. BIN
      sprites/misc/explosion-4.png
  30. BIN
      sprites/misc/explosion-5.png
  31. BIN
      sprites/misc/explosion-6.png
  32. BIN
      sprites/misc/explosion-sheet.png
  33. 53
      waypoint.hcl

90
.drone.yml

@ -0,0 +1,90 @@
---
kind: pipeline
type: docker
name: Waypoint
#workspace:
# path: /drone/workspace
image_pull_secrets:
- dockerconfig
steps:
- name: build
environment:
REGISTRY_URL: registry.digitalocean.com
REGISTRY_TOKEN:
from_secret: REGISTRY_TOKEN
image: docker:dind
volumes:
- name: dockersock
#path: /var/run/docker.sock
path: /var/run
commands:
- sleep 5 # give docker enough time to start
- docker login -u $REGISTRY_TOKEN -p $REGISTRY_TOKEN $REGISTRY_URL
- addgroup --gid 1000 user
- adduser -D -g '' -G user -u 1000 user
- chown -R user:user /drone/src
- docker run -v /drone/src/:/app/src/ --rm $REGISTRY_URL/smaug/smaug:latest build
- name: waypoint_deploy
image: hashicorp/waypoint:latest
environment:
WAYPOINT_SERVER_TOKEN:
from_secret: WAYPOINT_SERVER_TOKEN
WAYPOINT_SERVER_ADDR: waypoint.smaug.dev:9701
WAYPOINT_SERVER_TLS: 1
WAYPOINT_SERVER_TLS_SKIP_VERIFY: 1
commands:
- pwd
- ls -la
- waypoint init
- waypoint build
- waypoint deploy -release=false
- waypoint release -prune-retain=0
- name: gitea_release
image: plugins/gitea-release
settings:
api_key:
from_secret: GITEA_API_KEY
base_url: https://git.smaug.dev
files:
- builds/*-html5.zip
checksum:
- sha512
when:
event:
- tag
services:
- name: docker
image: docker:dind
privileged: true
volumes:
- name: dockersock
#path: /var/run/docker.sock
path: /var/run
volumes:
- name: dockersock
temp: {}
#host:
#path: /var/run/docker.sock
trigger:
branch:
- master
- main
event:
- push
- pull_request
- custom
---
kind: secret
name: WAYPOINT_SERVER_TOKEN
data: yYSmJ+ShC0BcgGptRBVK2pbdagqE+N03A5++izgkwIgs1IyHIDfpzrdtlVtkvMHAnw==

7
.gitignore

@ -0,0 +1,7 @@
builds/
logs/
exceptions/
last_replay.txt
replay.txt
.DS_Store
.secrets

26
.smaugignore

@ -0,0 +1,26 @@
.gitkeep
.gitlab-ci.yml
.rspec
.github/
.gitignore
.rubocop.yml
.travis.yml
.do/
.smaugignore
Rakefile
Gemfile
Gemfile.lock
*.gemspec
smaug/**/bin/
smaug/**/spec/
smaug/**/samples/
logs/
builds/
dist/
index.html
*.md
exceptions
.DS_Store
.drone.yml
.secrets
waypoint.hcl

6
Dockerfile

@ -0,0 +1,6 @@
FROM nginx:alpine
COPY ./builds/*-html5.zip /tmp/
RUN unzip -d /var/www /tmp/*-html5.zip
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 3000

9
LICENSE

@ -0,0 +1,9 @@
MIT License
Copyright (c) 2022 ldk
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

5
README.md

@ -0,0 +1,5 @@
# oviform-decadence
> A new Smaug project
---

22
Smaug.toml

@ -0,0 +1,22 @@
[project]
# The name of your game's executable. This should only contain a-z, A-Z, 0-9, _ or -.
name = "oviform_decadence"
# The game's title. This will show up in the tile bar of your executable.
title = "Oviform-Decadence"
version = "0.1.0"
authors = ["TODO: ldk <todo@example.com>"]
icon = "metadata/icon.png"
compile_ruby = false
[dragonruby]
version = "2.26"
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"

7
app/main.rb

@ -0,0 +1,7 @@
require 'smaug.rb'
def tick args
args.outputs.labels << [640, 500, 'Oviform-Decadence', 5, 1]
args.outputs.labels << [640, 460, 'A new Smaug project', 5, 1]
args.outputs.sprites << [576, 280, 128, 101, 'dragonruby.png']
end

307
app/repl.rb

@ -0,0 +1,307 @@
# ===============================================================
# Welcome to repl.rb
# ===============================================================
# You can experiement with code within this file. Code in this
# file is only executed when you save (and only excecuted ONCE).
# ===============================================================
# ===============================================================
# REMOVE the "x" from the word "xrepl" and save the file to RUN
# the code in between the do/end block delimiters.
# ===============================================================
# ===============================================================
# ADD the "x" to the word "repl" (make it xrepl) and save the
# file to IGNORE the code in between the do/end block delimiters.
# ===============================================================
# Remove the x from xrepl to run the code. Add the x back to ignore to code.
xrepl do
puts "The result of 1 + 2 is: #{1 + 2}"
end
# ====================================================================================
# Ruby Crash Course:
# Strings, Numeric, Booleans, Conditionals, Looping, Enumerables, Arrays
# ====================================================================================
# ====================================================================================
# Strings
# ====================================================================================
# Remove the x from xrepl to run the code. Add the x back to ignore to code.
xrepl do
message = "Hello World"
puts "The value of message is: " + message
puts "Any value can be interpolated within a string using \#{}."
puts "Interpolated message: #{message}."
puts 'This #{message} is not interpolated because the string uses single quotes.'
end
# ====================================================================================
# Numerics
# ====================================================================================
# Remove the x from xrepl to run the code. Add the x back to ignore to code.
xrepl do
a = 10
puts "The value of a is: #{a}"
puts "a + 1 is: #{a + 1}"
puts "a / 3 is: #{a / 3}"
end
# Remove the x from xrepl to run the code. Add the x back to ignore to code.
xrepl do
b = 10.12
puts "The value of b is: #{b}"
puts "b + 1 is: #{b + 1}"
puts "b as an integer is: #{b.to_i}"
puts ''
end
# ====================================================================================
# Booleans
# ====================================================================================
# Remove the x from xrepl to run the code. Add the x back to ignore to code.
xrepl do
c = 30
puts "The value of c is #{c}."
if c
puts "This if statement ran because c is truthy."
end
end
# Remove the x from xrepl to run the code. Add the x back to ignore to code.
xrepl do
d = false
puts "The value of d is #{d}."
if !d
puts "This if statement ran because d is falsey, using the not operator (!) makes d evaluate to true."
end
e = nil
puts "Nil is also considered falsey. The value of e is: #{e}."
if !e
puts "This if statement ran because e is nil (a falsey value)."
end
end
# ====================================================================================
# Conditionals
# ====================================================================================
# Remove the x from xrepl to run the code. Add the x back to ignore to code.
xrepl do
i_am_true = true
i_am_nil = nil
i_am_false = false
i_am_hi = "hi"
puts "======== if statement"
i_am_one = 1
if i_am_one
puts "This was printed because i_am_one is truthy."
end
puts "======== if/else statement"
if i_am_false
puts "This will NOT get printed because i_am_false is false."
else
puts "This was printed because i_am_false is false."
end
puts "======== if/elsif/else statement"
if i_am_false
puts "This will NOT get printed because i_am_false is false."
elsif i_am_true
puts "This was printed because i_am_true is true."
else
puts "This will NOT get printed i_am_true was true."
end
puts "======== case statement "
i_am_one = 1
case i_am_one
when 10
puts "case equaled: 10"
when 9
puts "case equaled: 9"
when 5
puts "case equaled: 5"
when 1
puts "case equaled: 1"
else
puts "Value wasn't cased."
end
puts "======== different types of comparisons"
if 4 == 4
puts "equal (4 == 4)"
end
if 4 != 3
puts "not equal (4 != 3)"
end
if 3 < 4
puts "less than (3 < 4)"
end
if 4 > 3
puts "greater than (4 > 3)"
end
if ((4 > 3) || (3 < 4) || false)
puts "or statement ((4 > 3) || (3 < 4) || false)"
end
if ((4 > 3) && (3 < 4))
puts "and statement ((4 > 3) && (3 < 4))"
end
end
# ====================================================================================
# Looping
# ====================================================================================
# Remove the x from xrepl to run the code. Add the x back to ignore to code.
xrepl do
puts "======== times block"
3.times do |i|
puts i
end
puts "======== range block exclusive"
(0...3).each do |i|
puts i
end
puts "======== range block inclusive"
(0..3).each do |i|
puts i
end
end
# ====================================================================================
# Enumerables
# ====================================================================================
# Remove the x from xrepl to run the code. Add the x back to ignore to code.
xrepl do
puts "======== array each"
colors = ["red", "blue", "yellow"]
colors.each do |color|
puts color
end
puts '======== array each_with_index'
colors = ["red", "blue", "yellow"]
colors.each_with_index do |color, i|
puts "#{color} at index #{i}"
end
end
# Remove the x from xrepl to run the code. Add the x back to ignore to code.
xrepl do
puts "======== single parameter function"
def add_one_to n
n + 5
end
puts add_one_to(3)
puts "======== function with default value"
def function_with_default_value v = 10
v * 10
end
puts "passing three: #{function_with_default_value(3)}"
puts "passing nil: #{function_with_default_value}"
puts "======== Or Equal (||=) operator for nil values"
def function_with_nil_default_with_local a = nil
result = a
result ||= "or equal operator was exected and set a default value"
end
puts "passing 'hi': #{function_with_nil_default_with_local 'hi'}"
puts "passing nil: #{function_with_nil_default_with_local}"
end
# ====================================================================================
# Arrays
# ====================================================================================
# Remove the x from xrepl to run the code. Add the x back to ignore to code.
xrepl do
puts "======== Create an array with the numbers 1 to 10."
one_to_ten = (1..10).to_a
puts one_to_ten
puts "======== Create a new array that only contains even numbers from the previous array."
one_to_ten = (1..10).to_a
evens = one_to_ten.find_all do |number|
number % 2 == 0
end
puts evens
puts "======== Create a new array that rejects odd numbers."
one_to_ten = (1..10).to_a
also_even = one_to_ten.reject do |number|
number % 2 != 0
end
puts also_even
puts "======== Create an array that doubles every number."
one_to_ten = (1..10).to_a
doubled = one_to_ten.map do |number|
number * 2
end
puts doubled
puts "======== Create an array that selects only odd numbers and then multiply those by 10."
one_to_ten = (1..10).to_a
odd_doubled = one_to_ten.find_all do |number|
number % 2 != 0
end.map do |odd_number|
odd_number * 10
end
puts odd_doubled
puts "======== All combination of numbers 1 to 10."
one_to_ten = (1..10).to_a
all_combinations = one_to_ten.product(one_to_ten)
puts all_combinations
puts "======== All uniq combinations of numbers. For example: [1, 2] is the same as [2, 1]."
one_to_ten = (1..10).to_a
uniq_combinations =
one_to_ten.product(one_to_ten)
.map do |unsorted_number|
unsorted_number.sort
end.uniq
puts uniq_combinations
end
# ====================================================================================
# Advanced Arrays
# ====================================================================================
# Remove the x from xrepl to run the code. Add the x back to ignore to code.
xrepl do
puts "======== All unique Pythagorean Triples between 1 and 40 sorted by area of the triangle."
one_to_hundred = (1..40).to_a
triples =
one_to_hundred.product(one_to_hundred).map do |width, height|
[width, height, Math.sqrt(width ** 2 + height ** 2)]
end.find_all do |_, _, hypotenuse|
hypotenuse.to_i == hypotenuse
end.map do |triangle|
triangle.map(&:to_i)
end.uniq do |triangle|
triangle.sort
end.map do |width, height, hypotenuse|
[width, height, hypotenuse, (width * height) / 2]
end.sort_by do |_, _, _, area|
area
end
triples.each do |width, height, hypotenuse, area|
puts "(#{width}, #{height}, #{hypotenuse}) = #{area}"
end
end

29
app/tests.rb

@ -0,0 +1,29 @@
# For advanced users:
# You can put some quick verification tests here, any method
# that starts with the `test_` will be run when you save this file.
# Here is an example test and game
# To run the test: ./dragonruby mygame --eval app/tests.rb --no-tick
class MySuperHappyFunGame
attr_gtk
def tick
outputs.solids << [100, 100, 300, 300]
end
end
def test_universe args, assert
game = MySuperHappyFunGame.new
game.args = args
game.tick
assert.true! args.outputs.solids.length == 1, "failure: a solid was not added after tick"
assert.false! 1 == 2, "failure: some how, 1 equals 2, the world is ending"
puts "test_universe completed successfully"
end
puts "running tests"
$gtk.reset 100
$gtk.log_level = :off
$gtk.tests.start

1
data/.gitkeep

@ -0,0 +1 @@
Put level data and other txt files here.

1
fonts/.gitkeep

@ -0,0 +1 @@
Put your custom fonts here.

10
metadata/game_metadata.txt

@ -0,0 +1,10 @@
# This file was automatically @generated by Smaug.
# Do not manually edit this file. Edit Smaug.toml instead.
devid=todo-change-me
devtitle=TODO: ${REPO_OWNER} &lt;todo@example.com&gt;
gameid=${REPO_NAME_SNAKE}
gametitle=${REPO_NAME_TITLE}
version=0.1.0
icon=metadata/icon.png
compile_ruby=false

BIN
metadata/icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

14
metadata/ios_metadata.txt

@ -0,0 +1,14 @@
# ios_metadata.txt is used by the Pro version of DragonRuby Game Toolkit to create iOS apps.
# Information about the Pro version can be found at: http://dragonruby.org/toolkit/game#purchase
# teamname needs to be set to your assigned team id which can be found at https://developer.apple.com/account/#/membership/L7H57V9CRD
teamid=
# appid needs to be set to your application identifier which can be found at https://developer.apple.com/account/resources/identifiers/list
appid=
# appname is the name you want to show up underneath the app icon on the device
appname=
# devcert is the certificate to use for development/deploying to your local device
devcert=
# prodcert is the certificate to use for distribution to the app store
prodcert=

12
nginx.conf

@ -0,0 +1,12 @@
server {
listen 3000;
server_name _;
root /var/www/;
index index.html;
# Send all single page app paths to index.html
location / {
try_files $uri /index.html;
}
}

4
smaug.rb

@ -0,0 +1,4 @@
# This file was automatically @generated by Smaug.
# Do not manually edit this file. Edit Smaug.toml instead.

1
sounds/.gitkeep

@ -0,0 +1 @@
Put your sounds here.

BIN
sprites/misc/dragon-0.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
sprites/misc/dragon-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
sprites/misc/dragon-2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
sprites/misc/dragon-3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
sprites/misc/dragon-4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
sprites/misc/dragon-5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
sprites/misc/explosion-0.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 B

BIN
sprites/misc/explosion-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

BIN
sprites/misc/explosion-2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
sprites/misc/explosion-3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
sprites/misc/explosion-4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

BIN
sprites/misc/explosion-5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
sprites/misc/explosion-6.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
sprites/misc/explosion-sheet.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

53
waypoint.hcl

@ -0,0 +1,53 @@
# The name of your project. A project typically maps 1:1 to a VCS repository.
# This name must be unique for your Waypoint server. If you're running in
# local mode, this must be unique to your machine.
project = "smaug_project_template"
runner {
enabled = true
data_source "git" {
url = "https://git.smaug.dev/ereborstudios/smaug_project_template.git"
ref = "master"
}
}
# Labels can be specified for organizational purposes.
# labels = { "foo" = "bar" }
# An application to deploy.
app "smaug_project_template" {
config {
env = {
}
}
labels = {
"service" = var.name
}
# Build specifies how an application should be deployed. In this case,
# we'll build using a Dockerfile and keeping it in a local registry.
build {
use "docker" {
}
}
# Deploy to Docker
deploy {
use "docker" {
labels = {
"traefik.http.routers.${var.name}.rule" = "Host(`${var.name}.waypoint.smaug.dev`)"
"traefik.http.routers.${var.name}.entrypoints" = "websecure"
"traefik.http.routers.${var.name}.tls.certresolver" = "myresolver"
"traefik.http.services.${var.name}.loadbalancer.server.port" = "3000"
}
}
}
}
variable "name" {
type = string
default = "smaug_project_template"
description = "Project name"
}
Loading…
Cancel
Save