Compare commits

...

20 commits
0.1.0 ... main

Author SHA1 Message Date
fc0d35c609 updated submodule url 2023-11-15 16:53:46 +11:00
863e75482b updated dragonruby to 5.5 2023-08-17 11:21:18 +10:00
81c60b7a2a updated menu to not accept presses while "scrambling" 2023-08-17 11:19:16 +10:00
24d176ec53 Update iOS app icon and bump version slightly 2023-08-03 14:14:26 +10:00
3c1b0999c4 Added screen dimensions to debug label 2023-08-03 13:47:02 +10:00
b7985070ff modify packaging and publishing slightly 2023-08-02 11:42:24 +10:00
de90447904 Fix package batch file and bump version number
Also, adding the keystore to the repo so that it is actually saved somewhere
2023-08-01 15:26:58 +10:00
3886790925 Added some screenshot functionality on ctrl+p
Also tidied up some vs code stuff
2023-08-01 13:13:29 +10:00
24718bc096 updated dragonruby core to 5.4 2023-08-01 11:36:16 +10:00
e78f9073e4 Commented out some console logs 2023-07-24 11:47:54 +10:00
3c70ae51cf Added restart option to pause menu 2023-07-20 14:37:41 +10:00
4233a560dd new, bigger menu image and replaced black bars with dirt 2023-07-20 14:37:03 +10:00
48686f5bbf Updated all-screen drawing
So there is less black space on iOS devices
2023-07-20 10:24:12 +10:00
ab4f6cdffd Update Readme with graphic 2023-07-13 02:16:08 +00:00
23b6b88cf0 updated readme and gitmodules (for tag) 2023-07-13 11:19:33 +10:00
33a807e7af Moved some metadata assets to a marketing assets folder
This will prevent these marketing assets from being packaged into the game binary
Also updated the run / package scripts to copy the app icons to the correct locations
2023-07-13 10:38:33 +10:00
41044f5dfc Attempted adding dragonruby base files as a submodule 2023-07-11 14:37:44 +10:00
f8df79d063 Fixed some paths and added a short readme 2023-07-11 13:02:56 +10:00
aee8651566 move the build and run scripts outside the game dir 2023-07-11 13:02:49 +10:00
2ee9098cae reorg part 1: move everything into subfolder 2023-07-11 11:11:24 +10:00
164 changed files with 472 additions and 243 deletions
.dragonruby.gitattributes.gitmodulesREADME.md
app/classes
cube-tube.keystore
installer
marketing-assets
packagepackage.batpublish.batrunrun.batrun_tests🕹️cube-tube.code-workspace
🕹️cube-tube

1
.dragonruby Submodule

@ -0,0 +1 @@
Subproject commit 57ccb75151e4133e18e64fe42f07e1a4a676026b

1
.gitattributes vendored Normal file
View file

@ -0,0 +1 @@
🕹cube-tube/sprites/menu_l.png filter=lfs diff=lfs merge=lfs -text

4
.gitmodules vendored Normal file
View file

@ -0,0 +1,4 @@
[submodule ".dragonruby"]
path = .dragonruby
url = ssh://git@forge.death.id.au:2222/death.au/dragonruby-base.git
tag = 5.1

120
README.md
View file

@ -1,108 +1,24 @@
# Scale
# Cube Tube
_Tetrominoes on a Train!_
![Feature Image](./marketing-assets/feature_w.png)
![repeating red dragon scale pixel art](https://user-images.githubusercontent.com/928367/204090457-0d096cbe-21cc-4753-9c63-f7786d165cfa.png)
This is my first DragonRuby game project. It's basically a Tetris clone, after following these tutorials:
1. Building Tetris - Part 1: https://youtu.be/xZMwRSbC4rY
2. Building Tetris - Part 2: https://youtu.be/C3LLzDUDgz4
**Simple DragonRuby Game Toolkit Game Starter Template**
Then making a whole bunch of modifications, including graphics, sounds, music, rotating the whole thing on its side and more.
Status: usable but not yet stable! This is pre-v1 software.
It also made use of the [Scale Framework](https://github.com/DragonRidersUnite/scale), which itself got heavily modified and is mostly unrecognisable now.
Quickly start a new DragonRuby Game Toolkit game with useful conventions and helpful extensions.
## DragonRuby
DragonRuby binaries, etc are in a git submodule under the `.dragonruby` folder
Looking for a simpler version? Check out [the `simple` release](https://github.com/DragonRidersUnite/scale/releases/tag/simple) that's just `app/main.rb` with some constants and helper methods.
To update DragonRuby, update the `tag` value in `.gitmodules` then run the following git commands:
```
git submodule sync
git submodule foreach --recursive 'git fetch --tags'
git submodule update --init --recursive --remote
```
(or just dump the files in the .dragonruby folder)
[Check out the CHANGELOG for the summary of recent changes!](https://github.com/DragonRidersUnite/scale/wiki/CHANGELOG)
## Bugs / Features
Last tested against DragonRuby Game Toolkit v4.3.
- Functional approach to the code, namespaced in modules
- Use the DragonRuby GTK methods and data structures you know and love
- Driven by `args.state`
- Menus and pause screen
- Sensible default controls
- Defined location for where to put scenes
- Settings that persist to disk
- Displays framerate in the upper-right hand corner of the game when running in development mode
- `#debug?` helper to easily check if the game is running in development mode; useful for custom commands
- `#mobile?` to easily check when on mobile and <kbd>M</kbd> to simulate mobile
- Reload all sprites in development using the `i` key
- Reset the game with `r` key, calls `$gtk.reset`
- Put all debug-only code in `#debug_tick`
- `#init` method that gets run once on game boot
- `#version` to get the version of your game
- Constants for various values and enums: `FPS`, `BLEND_*`, `ALIGN_*`
- Tests for the methods!
- See more in [SCALE_DOCS.md](./SCALE_DOCS.md)
## Use It
There are two main ways you can use the Scale template for your games.
[📺 Video demo showing how to get started](https://www.youtube.com/watch?v=eek3a3aO-zo)
### Download the Zip
The fastest way to get started is to download the template zip file and put it into your unzipped DragonRuby Game Toolkit folder.
1. Download and unzip the DragonRuby Game Toolkit engine zip
2. Delete the `mygame` directory
3. [Download Scale](https://github.com/DragonRidersUnite/scale/archive/refs/heads/main.zip)
4. Unzip the `scale-main.zip`
5. Move the `scale-main` folder into the DRGTK folder
6. Rename `scale-main` to `mygame`
7. Start DragonRuby, and make an awesome game!
### Use GitHub's Template System
If you're going to track your game with Git and use GitHub, the baked-in template system will get you going quickly.
1. View the project on GitHub: https://github.com/DragonRidersUnite/scale
2. Click "Use this template"
3. Click "Create a new repository"
4. Fill out the details and create the repository
5. Unzip the DragonRuby Game Toolkit engine zip
6. Delete the `mygame` directory
7. Clone your new repository into the DRGTK engine folder with the folder name `mygame`, example: `git clone git@github.com:USERNAME/REPO.git mygame`
7. Start DragonRuby, and make an awesome game!
### Updating
Because Scale is a template with all of its source as part of your game, updating the framework's source code in your game isn't an easy thing to do.
I generally would say: don't worry about it! Take ownership over the code in your game and change what Scale provides you without concern. When it comes time to start your next game, Scale will be updated and improved.
But if you do find yourself wanting to keep it updated, [watch the GitHub repo](https://github.com/DragonRidersUnite/scale) for releases. You could pull in just the changes you want. Or you could set an upstream in your repo to the template and merge the changes in.
## Documentation
Every game that uses Scale comes with the [SCALE_DOCS.md](./SCALE_DOCS.md) file. Read through that document to find a quickstart guide and information about useful methods.
## Release Approach & Versioning
Code on the `main` branch is intended to be stable because Scale is a template. When significant changes have been made, a tag and release are created. This allows progress to be tracked and previous versions to be easily downloaded.
Scale uses a simplified major.minor versioning scheme. Major version bumps means there are breaking changes to the API (the methods and structure). Minor bumps mean non-breaking additions and fixes.
## Template License
The template source code falls under the [Unlicense](https://unlicense.org/), meaning it is dedicated to the public domain and you are free to do with it what you want.
## Contribute
Conributions are welcome!
Open an issue or submit PRs if you notice something isn't working.
If you find yourself adding the same files, methods, constants, etc. to your DRGTK games, submit a PR to add it to Scale.
---
[Clear out what's above in this README out and add your own details for making your game!]
## Debug Shortcuts
- <kbd>0</kbd> — display debug details (ex: framerate)
- <kbd>i</kbd> — reload sprites from disk
- <kbd>r</kbd> — reset the entire game state
- <kbd>m</kbd> — toggle mobile simulation
Also, for iOS, make sure to create icons in `marketing-assets/AppIcon.appiconset/` (see the `.gitkeep` file in that folder for more info). The `run` and `package` scripts should copy these to the correct locations in `.dragonruby/dragonruby-ios-simulator.app/Assets.xcassets/AppIcon.appiconset/` and `.dragonruby/dragonruby-ios.app/Assets.xcassets/AppIcon.appiconset` respectively.

View file

@ -1,18 +0,0 @@
# frozen_string_literal: true
# class to represent scenes
class SceneInstance
def initialize(_args, opts = {})
@tick_in_background = opts.tick_in_background._? false
@reset_on_pop = opts.reset_on_pop._? false
end
attr_reader :tick_in_background
attr_accessor :reset_on_pop
# called every tick of the game loop
def tick(args) end
# custom logic to reset this scene
def reset(args) end
end

BIN
cube-tube.keystore Normal file

Binary file not shown.

View file

@ -208,15 +208,15 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:Cube Tube"
"ProductCode" = "8:{0DF427A0-5821-48F0-9CA5-B34F1123F839}"
"PackageCode" = "8:{27B06BB4-4B81-4D50-A8E0-10378563DE9D}"
"ProductCode" = "8:{FAD41339-47C6-4BE0-9CE0-901208A5F92D}"
"PackageCode" = "8:{485042AA-0822-4605-9240-4B88CAAE3CCE}"
"UpgradeCode" = "8:{CD4947B5-EF08-4530-A370-44E0B5F6F762}"
"AspNetVersion" = "8:4.0.30319.0"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:FALSE"
"ProductVersion" = "8:0.1.1"
"ProductVersion" = "8:0.2.0"
"Manufacturer" = "8:death.au"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:"

View file

@ -0,0 +1,17 @@
Place iOS App Icon assets here, as listed below:
- icon-20pt@2x.png - 40 x 40 px
- icon-20pt@3x.png - 60 x 60 px
- icon-29pt@2x.png - 58 x 58 px
- icon-29pt@3x.png - 87 x 87 px
- icon-38pt@2x.png - 76 x 76 px
- icon-38pt@3x.png - 114 x 114 px
- icon-40pt@2x.png - 80 x 80 px
- icon-40pt@3x.png - 120 x 120 px
- icon-60pt@2x.png - 120 x 120 px
- icon-60pt@3x.png - 180 x 180 px
- icon-64pt@2x.png - 128 x 128 px
- icon-64pt@3x.png - 192 x 192 px
- icon-68pt@2x.png - 136 x 136 px
- icon-76pt@2x.png - 152 x 152 px
- icon-83.5pt@2x.png - 167 x 167 px
- icon-1024pt.png - 1024 x 1024 px

Binary file not shown.

After

(image error) Size: 209 KiB

Binary file not shown.

After

(image error) Size: 1.8 KiB

Binary file not shown.

After

(image error) Size: 3.1 KiB

Binary file not shown.

After

(image error) Size: 2.9 KiB

Binary file not shown.

After

(image error) Size: 5.3 KiB

Binary file not shown.

After

(image error) Size: 4.4 KiB

Binary file not shown.

After

(image error) Size: 8.1 KiB

Binary file not shown.

After

(image error) Size: 4.7 KiB

Binary file not shown.

After

(image error) Size: 8.8 KiB

Binary file not shown.

After

(image error) Size: 8.8 KiB

Binary file not shown.

After

(image error) Size: 17 KiB

Binary file not shown.

After

(image error) Size: 9.8 KiB

Binary file not shown.

After

(image error) Size: 20 KiB

Binary file not shown.

After

(image error) Size: 11 KiB

Binary file not shown.

After

(image error) Size: 13 KiB

Binary file not shown.

After

(image error) Size: 15 KiB

View file

@ -0,0 +1,119 @@
{
"images" : [
{
"filename" : "AppIcon20x20@2x.png",
"idiom" : "universal",
"platform" : "ios",
"scale" : "2x",
"size" : "20x20"
},
{
"filename" : "AppIcon20x20@3x.png",
"idiom" : "universal",
"platform" : "ios",
"scale" : "3x",
"size" : "20x20"
},
{
"filename" : "AppIcon29x29@2x.png",
"idiom" : "universal",
"platform" : "ios",
"scale" : "2x",
"size" : "29x29"
},
{
"filename" : "AppIcon29x29@3x.png",
"idiom" : "universal",
"platform" : "ios",
"scale" : "3x",
"size" : "29x29"
},
{
"filename" : "AppIcon38x38@2x.png",
"idiom" : "universal",
"platform" : "ios",
"scale" : "2x",
"size" : "38x38"
},
{
"filename" : "AppIcon38x38@3x.png",
"idiom" : "universal",
"platform" : "ios",
"scale" : "3x",
"size" : "38x38"
},
{
"filename" : "AppIcon40x40@2x.png",
"idiom" : "universal",
"platform" : "ios",
"scale" : "2x",
"size" : "40x40"
},
{
"filename" : "AppIcon40x40@3x.png",
"idiom" : "universal",
"platform" : "ios",
"scale" : "3x",
"size" : "40x40"
},
{
"filename" : "AppIcon60x60@2x.png",
"idiom" : "universal",
"platform" : "ios",
"scale" : "2x",
"size" : "60x60"
},
{
"filename" : "AppIcon60x60@3x.png",
"idiom" : "universal",
"platform" : "ios",
"scale" : "3x",
"size" : "60x60"
},
{
"filename" : "AppIcon64x64@2x.png",
"idiom" : "universal",
"platform" : "ios",
"scale" : "2x",
"size" : "64x64"
},
{
"filename" : "AppIcon64x64@3x.png",
"idiom" : "universal",
"platform" : "ios",
"scale" : "3x",
"size" : "64x64"
},
{
"filename" : "AppIcon68x68@2x.png",
"idiom" : "universal",
"platform" : "ios",
"scale" : "2x",
"size" : "68x68"
},
{
"filename" : "AppIcon76x76@2x.png",
"idiom" : "universal",
"platform" : "ios",
"scale" : "2x",
"size" : "76x76"
},
{
"filename" : "AppIcon83.5x83.5@2x.png",
"idiom" : "universal",
"platform" : "ios",
"scale" : "2x",
"size" : "83.5x83.5"
},
{
"filename" : "AppIcon1024x1024.png",
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View file

Before

(image error) Size: 68 KiB

After

(image error) Size: 68 KiB

View file

Before

(image error) Size: 399 KiB

After

(image error) Size: 399 KiB

View file

Before

(image error) Size: 544 KiB

After

(image error) Size: 544 KiB

View file

Before

(image error) Size: 86 KiB

After

(image error) Size: 86 KiB

View file

Before

(image error) Size: 54 KiB

After

(image error) Size: 54 KiB

View file

Before

(image error) Size: 499 KiB

After

(image error) Size: 499 KiB

View file

Before

(image error) Size: 3.2 KiB

After

(image error) Size: 3.2 KiB

13
package Normal file → Executable file
View file

@ -1,8 +1,7 @@
#!/bin/sh
cd "`dirname "$0"`"
result=${PWD##*/} # to assign to a variable
result=${result:-/} # to correct for the case where PWD=/
cd ..
exec ./dragonruby-publish --only-package ${result}
cd "`dirname "$0"`"/.dragonruby
cp -R ../marketing-assets/AppIcon.appiconset ./dragonruby-ios.app/Assets.xcassets/
cp -R ../marketing-assets/AppIcon.appiconset ./dragonruby-ios-simulator.app/Assets.xcassets/
cp -R ../🕹cube-tube ./cube-tube
exec ./dragonruby-publish --only-package cube-tube
rmdir -R ./cube-tube

View file

@ -1,62 +1 @@
@echo off
cd /d %~dp0
for %%I in (.) do set CurrDirName=%%~nxI
for /F %%a IN ('powershell -command "$([guid]::NewGuid().ToString().toUpper())"') DO (set newProductCode=%%a)
for /F %%a IN ('powershell -command "$([guid]::NewGuid().ToString().toUpper())"') DO (set newPackageCode=%%a)
@setlocal ENABLEEXTENSIONS
@set version=0
@for /F "tokens=*" %%A in (./metadata/game_metadata.txt) do @call :CheckForVersion "%%A"
cd ..
@echo on
dragonruby-publish --only-package %CurrDirName%
@echo off
cd builds
if exist ./%CurrDirName%-windows-amd64.exe (
if exist ../%CurrDirName%/installer/installer.vdproj (
echo "Building windows installer..."
for /F "tokens=* USEBACKQ" %%t IN (`findstr /c:"%version%" ..\%CurrDirName%\installer\installer.vdproj`) do (SET OldVersion=%%t)
if defined OldVersion (
echo "version already the same"
) else (
echo "need to update version & product/package codes (%version%, %newProductCode%, %newPackageCode%)"
powershell -Command "(Get-Content ../%CurrDirName%/installer/installer.vdproj) | Foreach-Object { $_ -replace '""""ProductCode"""" = """"8:\{.*\}""""$', '""""ProductCode"""" = """"8:{%newProductCode%}""""' -replace '""""PackageCode"""" = """"8:\{.*\}""""$', '""""PackageCode"""" = """"8:{%newPackageCode%}""""' -replace '""""ProductVersion"""" = """"8:.+""""$', '""""ProductVersion"""" = """"8:%version%""' } | Out-File -encoding UTF8 ../%CurrDirName%/installer/installer.vdproj"
)
call "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\devenv.exe" ..\%CurrDirName%\installer\installer.sln /build Release
) else (
ECHO "no installer project?"
ECHO ../%CurrDirName%/installer/installer.vdproj
)
) else (
ECHO "no exe?"
ECHO ./%CurrDirName%-windows-amd64.exe
)
if not exist ./%CurrDirName%.keystore (
echo "no keystore, generating keys"
keytool -genkey -v -keystore %CurrDirName%.keystore -alias %CurrDirName% -keyalg RSA -keysize 2048 -validity 10000
)
if exist ./%CurrDirName%-android.apk (
echo "Signing apk..."
call "C:\Program Files (x86)\Android\android-sdk\build-tools\32.0.0\apksigner.bat" sign -ks %CurrDirName%.keystore %CurrDirName%-android.apk
echo "Signing aab..."
call jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA-256 -keystore %CurrDirName%.keystore %CurrDirName%-googleplay.aab %CurrDirName%
) else (
ECHO "no apk?"
ECHO ./%CurrDirName%-android.apk
)
ECHO "All done!"
explorer.exe %cd%
PAUSE
@exit /b 0
:CheckForVersion
@set _line=%~1
@set _linePrefeix=%_line:~0,8%
@if "%_linePrefeix%" equ "version=" (@set version="%_line:~8%")
@exit /b 0
call publish.bat --only-package

72
publish.bat Normal file
View file

@ -0,0 +1,72 @@
@echo off
chcp 65001 >NUL
cd /d %~dp0
set gamedir=🕹cube-tube
for /F %%a IN ('powershell -command "$([guid]::NewGuid().ToString().toUpper())"') DO (set newProductCode=%%a)
for /F %%a IN ('powershell -command "$([guid]::NewGuid().ToString().toUpper())"') DO (set newPackageCode=%%a)
@setlocal ENABLEEXTENSIONS
@set version=0
@for /F "tokens=*" %%A in (%gamedir%/metadata/game_metadata.txt) do @call :CheckForVersion "%%A"
cd .dragonruby
robocopy ../marketing-assets/AppIcon.appiconset ./dragonruby-ios.app/Assets.xcassets/AppIcon.appiconset /e
robocopy ../marketing-assets/AppIcon.appiconset ./dragonruby-ios-simulator.app/Assets.xcassets/AppIcon.appiconset /e
robocopy ../%gamedir% ./%gameid% /e
@echo on
dragonruby-publish %* %gameid%
@echo off
rd /s /q %gameid%
cd builds
if exist ./%gameid%-windows-amd64.exe (
if exist ../../installer/installer.vdproj (
echo "Building windows installer..."
for /F "tokens=* USEBACKQ" %%t IN (`findstr /c:"%version%" ..\..\installer\installer.vdproj`) do (SET OldVersion=%%t)
if defined OldVersion (
echo "version already the same"
) else (
echo "need to update version & product/package codes (%version%, %newProductCode%, %newPackageCode%)"
powershell -Command "(Get-Content ../../installer/installer.vdproj) | Foreach-Object { $_ -replace '""""ProductCode"""" = """"8:\{.*\}""""$', '""""ProductCode"""" = """"8:{%newProductCode%}""""' -replace '""""PackageCode"""" = """"8:\{.*\}""""$', '""""PackageCode"""" = """"8:{%newPackageCode%}""""' -replace '""""ProductVersion"""" = """"8:.+""""$', '""""ProductVersion"""" = """"8:%version%""' } | Out-File -encoding UTF8 ../../installer/installer.vdproj"
)
call "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\devenv.exe" ..\..\installer\installer.sln /build Release
) else (
ECHO "no installer project?"
ECHO ../../installer/installer.vdproj
)
) else (
ECHO "no exe?"
ECHO ./%gameid%-windows-amd64.exe
)
if not exist ../../%gameid%.keystore (
echo "no keystore, generating keys"
keytool -genkey -v -keystore ../../%gameid%.keystore -alias %gameid% -keyalg RSA -keysize 2048 -validity 10000
)
if exist ./%gameid%-android.apk (
echo "Signing apk..."
call "C:\Program Files (x86)\Android\android-sdk\build-tools\32.0.0\apksigner.bat" sign -ks ../../%gameid%.keystore %gameid%-android.apk
echo "Signing aab..."
call jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA-256 -keystore ../../%gameid%.keystore %gameid%-googleplay.aab %gameid%
) else (
ECHO "no apk?"
ECHO ./%gameid%-android.apk
)
ECHO "All done!"
explorer.exe %cd%
PAUSE
@exit /b 0
:CheckForVersion
@set _line=%~1
@set _linePrefeix=%_line:~0,8%
@if "%_linePrefeix%" equ "version=" (@set version="%_line:~8%")
@set _linePrefeix=%_line:~0,7%
@if "%_linePrefeix%" equ "gameid=" (@set gameid="%_line:~7%")
@exit /b 0

11
run
View file

@ -1,8 +1,5 @@
#!/bin/sh
cd "`dirname "$0"`"
result=${PWD##*/} # to assign to a variable
result=${result:-/} # to correct for the case where PWD=/
cd ..
exec ./dragonruby ${result}
cd "`dirname "$0"`"/.dragonruby
cp -R ../marketing-assets/AppIcon.appiconset ./dragonruby-ios.app/Assets.xcassets/
cp -R ../marketing-assets/AppIcon.appiconset ./dragonruby-ios-simulator.app/Assets.xcassets/
exec ./dragonruby ../🕹cube-tube

View file

@ -1,9 +1,8 @@
@echo off
cd /d %~dp0
for %%I in (.) do set CurrDirName=%%~nxI
cd ..
cd .dragonruby
robocopy ../marketing-assets/AppIcon.appiconset ./dragonruby-ios.app/Assets.xcassets/AppIcon.appiconset /e
robocopy ../marketing-assets/AppIcon.appiconset ./dragonruby-ios-simulator.app/Assets.xcassets/AppIcon.appiconset /e
@echo on
dragonruby %CurrDirName%
dragonruby ../🕹cube-tube
EXIT /B

View file

@ -1,10 +0,0 @@
#!/usr/bin/env sh
set -e
rm -f test-failures.txt
if ! ../dragonruby . --eval app/tests.rb --no-tick --exit-on-fail; then
echo "🙀 tests failed!"
cat test-failures.txt
exit 1
else
echo "🪩 tests passed!"
fi

View file

@ -0,0 +1,8 @@
{
"folders": [
{
"path": "🕹cube-tube"
}
],
"settings": {}
}

View file

@ -8,7 +8,10 @@
"name": "Run Game",
"type": "node-terminal",
"request": "launch",
"command": "${workspaceRoot}/../dragonruby.exe ${workspaceRoot}",
"command": "\"${workspaceRoot}/../.dragonruby/dragonruby\" \"${workspaceRoot}\"",
"windows": {
"command": "${workspaceRoot}/../.dragonruby/dragonruby.exe ${workspaceRoot}",
},
}
]
}

108
🕹️cube-tube/README.md Normal file
View file

@ -0,0 +1,108 @@
# Scale
![repeating red dragon scale pixel art](https://user-images.githubusercontent.com/928367/204090457-0d096cbe-21cc-4753-9c63-f7786d165cfa.png)
**Simple DragonRuby Game Toolkit Game Starter Template**
Status: usable but not yet stable! This is pre-v1 software.
Quickly start a new DragonRuby Game Toolkit game with useful conventions and helpful extensions.
Looking for a simpler version? Check out [the `simple` release](https://github.com/DragonRidersUnite/scale/releases/tag/simple) that's just `app/main.rb` with some constants and helper methods.
[Check out the CHANGELOG for the summary of recent changes!](https://github.com/DragonRidersUnite/scale/wiki/CHANGELOG)
## Bugs / Features
Last tested against DragonRuby Game Toolkit v4.3.
- Functional approach to the code, namespaced in modules
- Use the DragonRuby GTK methods and data structures you know and love
- Driven by `args.state`
- Menus and pause screen
- Sensible default controls
- Defined location for where to put scenes
- Settings that persist to disk
- Displays framerate in the upper-right hand corner of the game when running in development mode
- `#debug?` helper to easily check if the game is running in development mode; useful for custom commands
- `#mobile?` to easily check when on mobile and <kbd>M</kbd> to simulate mobile
- Reload all sprites in development using the `i` key
- Reset the game with `r` key, calls `$gtk.reset`
- Put all debug-only code in `#debug_tick`
- `#init` method that gets run once on game boot
- `#version` to get the version of your game
- Constants for various values and enums: `FPS`, `BLEND_*`, `ALIGN_*`
- Tests for the methods!
- See more in [SCALE_DOCS.md](./SCALE_DOCS.md)
## Use It
There are two main ways you can use the Scale template for your games.
[📺 Video demo showing how to get started](https://www.youtube.com/watch?v=eek3a3aO-zo)
### Download the Zip
The fastest way to get started is to download the template zip file and put it into your unzipped DragonRuby Game Toolkit folder.
1. Download and unzip the DragonRuby Game Toolkit engine zip
2. Delete the `mygame` directory
3. [Download Scale](https://github.com/DragonRidersUnite/scale/archive/refs/heads/main.zip)
4. Unzip the `scale-main.zip`
5. Move the `scale-main` folder into the DRGTK folder
6. Rename `scale-main` to `mygame`
7. Start DragonRuby, and make an awesome game!
### Use GitHub's Template System
If you're going to track your game with Git and use GitHub, the baked-in template system will get you going quickly.
1. View the project on GitHub: https://github.com/DragonRidersUnite/scale
2. Click "Use this template"
3. Click "Create a new repository"
4. Fill out the details and create the repository
5. Unzip the DragonRuby Game Toolkit engine zip
6. Delete the `mygame` directory
7. Clone your new repository into the DRGTK engine folder with the folder name `mygame`, example: `git clone git@github.com:USERNAME/REPO.git mygame`
7. Start DragonRuby, and make an awesome game!
### Updating
Because Scale is a template with all of its source as part of your game, updating the framework's source code in your game isn't an easy thing to do.
I generally would say: don't worry about it! Take ownership over the code in your game and change what Scale provides you without concern. When it comes time to start your next game, Scale will be updated and improved.
But if you do find yourself wanting to keep it updated, [watch the GitHub repo](https://github.com/DragonRidersUnite/scale) for releases. You could pull in just the changes you want. Or you could set an upstream in your repo to the template and merge the changes in.
## Documentation
Every game that uses Scale comes with the [SCALE_DOCS.md](./SCALE_DOCS.md) file. Read through that document to find a quickstart guide and information about useful methods.
## Release Approach & Versioning
Code on the `main` branch is intended to be stable because Scale is a template. When significant changes have been made, a tag and release are created. This allows progress to be tracked and previous versions to be easily downloaded.
Scale uses a simplified major.minor versioning scheme. Major version bumps means there are breaking changes to the API (the methods and structure). Minor bumps mean non-breaking additions and fixes.
## Template License
The template source code falls under the [Unlicense](https://unlicense.org/), meaning it is dedicated to the public domain and you are free to do with it what you want.
## Contribute
Conributions are welcome!
Open an issue or submit PRs if you notice something isn't working.
If you find yourself adding the same files, methods, constants, etc. to your DRGTK games, submit a PR to add it to Scale.
---
[Clear out what's above in this README out and add your own details for making your game!]
## Debug Shortcuts
- <kbd>0</kbd> — display debug details (ex: framerate)
- <kbd>i</kbd> — reload sprites from disk
- <kbd>r</kbd> — reset the entire game state
- <kbd>m</kbd> — toggle mobile simulation

View file

@ -0,0 +1,41 @@
# frozen_string_literal: true
# class to represent scenes
class SceneInstance
def initialize(_args, opts = {})
@tick_in_background = opts.tick_in_background._? false
@reset_on_pop = opts.reset_on_pop._? false
end
attr_reader :tick_in_background
attr_accessor :reset_on_pop
def screenshot(args)
screenshot_path = "../marketing-assets/screenshots/#{args.gtk.platform}"
now = Time.new
now_s = "#{now.year}-#{"#{now.month}".rjust(2, "0")}-#{"#{now.day}".rjust(2, "0")} at #{"#{now.hour}".rjust(2, "0")}.#{"#{now.min}".rjust(2, "0")}.#{"#{now.sec}".rjust(2, "0")}"
base_filename = "#{screenshot_path}/Screenshot - #{args.gtk.platform} - #{now_s}"
filename = "#{base_filename}.png"
count = 0
while !args.gtk.stat_file(filename).nil?
count += 1;
filename = "#{base_filename} (#{count}).png"
end
args.outputs.screenshots << {
x: 0, y: 0, w: args.grid.w, h: args.grid.h, # Which portion of the screen should be captured
path: filename, # Output path of PNG file (inside game directory)
# r: 255, g: 255, b: 255, a: 0 # Optional chroma key
}
args.gtk.notify!("Screenshot taken: '#{filename}'")
end
# called every tick of the game loop
def tick(args)
screenshot(args) if args.inputs.keyboard.ctrl_p
end
# custom logic to reset this scene
def reset(args) end
end

View file

@ -5,7 +5,7 @@ module Input
class << self
PRIMARY_KEYS = [:j, :z, :space]
SECONDARY_KEYS = [:k, :x, :backspace]
PAUSE_KEYS = [:escape, :p]
PAUSE_KEYS = [:escape]
BINDINGS = {
primary: {
keyboard: %i[j z space],
@ -16,7 +16,7 @@ module Input
controller_one: %i[b]
},
pause: {
keyboard: %i[escape p],
keyboard: %i[escape],
controller_one: %i[start]
},
rotate_left: {

View file

@ -123,8 +123,18 @@ class CubeTubeGame < GameplayScene
end
@bg_x %= @bg_w if @bg_x >= @bg_w
dirt = Sprite.for(:dirt)
10.times do |i|
dirt.render(@args, { x: @bg_x + (i * (dirt.w)), y: 0 - dirt.h + 1 })
dirt.render(@args, { x: @bg_x - (i * (dirt.w)), y: 0 - dirt.h + 1 })
dirt.render(@args, { x: @bg_x + (i * (dirt.w)), y: @args.grid.h })
dirt.render(@args, { x: @bg_x - (i * (dirt.w)), y: @args.grid.h })
end
Sprite.for(:tunnel_loop).render(@args, { x: @bg_x + @bg_w, y: 0, w: @bg_w, h: 720 })
Sprite.for(:tunnel_loop).render(@args, { x: @bg_x, y: 0, w: @bg_w, h: 720 })
Sprite.for(:tunnel_loop).render(@args, { x: @bg_x - @bg_w, y: 0, w: @bg_w, h: 720 })
Sprite.for(:tunnel_loop).render(@args, { x: @bg_x - (@bg_w * 2), y: 0, w: @bg_w, h: 720 })
# @grid_y = ((1280 - (@grid_h * @blocksize)) / 2) - 21
Sprite.for(:train).render(@args, { x: 0, y: @grid_x - 140.75 })

View file

@ -9,11 +9,13 @@ class Intro < GameplayScene
@train_spline = [
[1.0, 0.25, 0, 0]
]
@full_station_w = Sprite.for(:station_loop).w + Sprite.for(:station_end).w
@station_start_w = Sprite.for(:station_start).w
@full_station_start_w = Sprite.for(:station_start).w + Sprite.for(:tunnel_loop).w
@tunnel_w = Sprite.for(:tunnel_loop).w
@full_station_start_w = @station_start_w + @tunnel_w
@tracks_w = Sprite.for(:tracks).w
@leave_duration = 600
@leave_duration = 500
@leave_spline = [
[0, 0, 0.5, 1.0]
]
@ -40,7 +42,7 @@ class Intro < GameplayScene
@state += 1
end
when 1
@train_pos = 1280 * args.easing.ease_spline(@train_start, now, @train_duration, @train_spline)
@train_pos = @train_start_pos * args.easing.ease_spline(@train_start, now, @train_duration, @train_spline)
if @train_pos <= 0
@state += 1
@wait_start = now
@ -63,9 +65,18 @@ class Intro < GameplayScene
end
end
dirt = Sprite.for(:dirt)
dx = 0 - @full_station_start_w - @tunnel_w
while dx < @full_station_w
dirt.render(args, { x: @station_pos + dx, y: 0 - dirt.h + 1 })
dirt.render(args, { x: @station_pos + dx, y: args.grid.h })
dx += dirt.w
end
Sprite.for(:station_loop).render(args, { x: @station_pos })
Sprite.for(:station_start).render(args, { x: @station_pos - @station_start_w })
Sprite.for(:tunnel_loop).render(args, { x: @station_pos - @full_station_start_w })
Sprite.for(:tunnel_loop).render(args, { x: @station_pos - @full_station_start_w - @tunnel_w })
Sprite.for(:train).render(args, { y: 39.25, x: @train_pos })
Sprite.for(:screen).render(args, { x: @train_pos + 1024, y: 270 })
@ -98,7 +109,7 @@ class Intro < GameplayScene
@train_start = 0
@wait_start = 0
@leave_start = 0
@train_pos = 1280
@train_pos = @train_start_pos = 1500
@station_pos = 0
@screen_on = false
end

View file

@ -36,7 +36,7 @@ class MainMenu < MenuScene
next_sec = random(20..50)
@next_announcement = args.state.tick_count + (next_sec * 60)
sound = :"ambient#{random(1..6)}"
puts sound, Sound.for(sound).input
# puts sound, Sound.for(sound).input
Sound.play(args, sound)
end

View file

@ -39,7 +39,9 @@ class MenuScene < SceneInstance
text(option[:key])
end
if (args.state.tick_count - @first_render) < 60 * (1.5 + i) * 0.2
scramble = (args.state.tick_count - @first_render) < 60 * (1.5 + i) * 0.2
if scramble
if args.state.tick_count % 4 == 0
@rand_strings[i] = (0...(rand(text.length >= 3 ? text.length : 3) + 3)).map { ('A'..'Z').to_a[rand(26)] }.join
end
@ -73,7 +75,7 @@ class MenuScene < SceneInstance
button_border = { w: 340, h: 80, x: l.x - 170, y: l.y - 55 }.merge(WHITE)
# (args.outputs.borders << button_border) if mobile?
if args.inputs.mouse.up && args.inputs.mouse.inside_rect?(button_border)
if args.inputs.mouse.up && args.inputs.mouse.inside_rect?(button_border) && !scramble
o = @menu_options.find { |o| o[:key] == l[:key] }
Sound.play(args, :menu)
o[:on_select].call(args) if o
@ -88,7 +90,7 @@ class MenuScene < SceneInstance
super
@first_render = args.state.tick_count if @first_render.nil?
Sprite.for(:menu).render(args)
Sprite.for(:menu_l).render(args)
args.outputs.labels << label(
@title.to_s.upcase,

View file

@ -9,6 +9,10 @@ class PauseMenu < MenuScene
key: :resume,
on_select: ->(args) { Scene.pop(args) }
},
{
key: :restart,
on_select: ->(args) { Scene.switch(args, :intro, reset: true) }
},
{
key: :settings,
on_select: ->(args) { Scene.push(args, :settings, reset: true, reset_on_pop: true) }
@ -19,12 +23,12 @@ class PauseMenu < MenuScene
}
]
if args.gtk.platform?(:desktop)
menu_options << {
key: :quit,
on_select: ->(args) { args.gtk.request_quit }
}
end
# if args.gtk.platform?(:desktop)
# menu_options << {
# key: :quit,
# on_select: ->(args) { args.gtk.request_quit }
# }
# end
super args, opts, :paused, menu_options
end

View file

@ -25,8 +25,10 @@ module Sprite
screen_s3: SpriteInstance.new({ w: 250, h: 210, path: 'sprites/screen-s3.png' }),
screen_s4: SpriteInstance.new({ w: 250, h: 210, path: 'sprites/screen-s4.png' }),
menu: SpriteInstance.new({ w: 1280, h: 720, path: 'sprites/menu.png' }),
menu_l: SpriteInstance.new({ w: 2760, h: 1550, path: 'sprites/menu_l.png', x: -740, y: -415 }),
tunnel_loop: SpriteInstance.new({ w: 1358, h: 720, path: 'sprites/tunnel-loop.png' }),
tracks: SpriteInstance.new({ w: 1358, h: 55, path: 'sprites/tracks.png' }),
dirt: SpriteInstance.new({ w: 194, h: 150, path: 'sprites/dirt.png' }),
station_loop: SpriteInstance.new({ w: 1811, h: 720, path: 'sprites/station-loop.png' }),
station_start: SpriteInstance.new({ w: 618, h: 720, path: 'sprites/station-start.png' }),
station_end: SpriteInstance.new({ w: 518, h: 720, path: 'sprites/station-end.png' })

View file

@ -16,6 +16,7 @@ TEXT = {
paused: "Paused",
quit: "Quit",
resume: "Resume",
restart: "Restart",
return_to_main_menu: "Main Menu",
settings: "Settings",
sfx: "Sound Effects",

View file

@ -53,7 +53,7 @@ def debug_tick(args)
debug_label(
args, 24.from_right, 24.from_top,
"v#{version} | DR v#{$gtk.version} (#{$gtk.platform}) | Ticks: #{args.state.tick_count} | FPS: #{args.gtk.current_framerate.round}",
"v#{version} | DR v#{$gtk.version} (#{$gtk.platform}) | Ticks: #{args.state.tick_count} | FPS: #{args.gtk.current_framerate.round} | Win: #{args.grid.window_width}x#{args.grid.window_height}",
ALIGN_RIGHT)

View file

@ -23,12 +23,12 @@ module Scene
# if `scene` is not a `SceneInstance`, it's probably a symbol representing
# the scene we're switching to, so go get it.
the_scene = scene.is_a?(SceneInstance) ? scene : SCENES[scene].new(args)
puts '---'
puts 'switching to'
puts scene unless scene.is_a?(SceneInstance)
puts SCENES[scene] unless scene.is_a?(SceneInstance)
puts the_scene
puts '---'
# puts '---'
# puts 'switching to'
# puts scene unless scene.is_a?(SceneInstance)
# puts SCENES[scene] unless scene.is_a?(SceneInstance)
# puts the_scene
# puts '---'
# if the stack is empty (e.g. we just cleared it), then push this scene
args.state.scene_stack.push(the_scene) if args.state.scene_stack.empty?
@ -56,7 +56,7 @@ module Scene
scene = args.state.scene_stack.last
scene = scene._?(default(args))
reset = scene.reset_on_pop if reset.nil?
puts reset, scene, scene.reset_on_pop
# puts reset, scene, scene.reset_on_pop
switch(args, scene, reset: reset, push_or_pop: true)
end

View file

@ -2,7 +2,7 @@ devid=deathau
devtitle=death.au
gameid=cube-tube
gametitle=Cube Tube
version=0.1.0
version=0.2.1
icon=metadata/icon.png
# === Flags available at all licensing tiers ===
@ -30,7 +30,7 @@ orientation=landscape
# HD Mode: when enabled, will give you 720p, 1080p, 1440p, 4k, and 5k rendering options
# Check out the following YouTube Video for a demo of DragonRuby's HD Capabilities
# https://youtu.be/Rnc6z84zaa4
# hd=false
hd=true
# === Texture Atlases ===
@ -42,7 +42,7 @@ orientation=landscape
# All Screen Mode: when enabled, removes the letter box and lets you render outside of the 16:9 safe area
# NOTE: requires hd=true
# allscreen=false
allscreen=true
# All Screen Mode's Max Scale: You can specify the maximum scale for your game. Any resolution higher than your max scale will give more area outside of your resolutions safe area:
@ -70,4 +70,4 @@ orientation=landscape
# allscreen_max_scale=300
# 5k: scales up to 6400x2880
# allscreen_max_scale=400
allscreen_max_scale=400

Binary file not shown.

After

(image error) Size: 209 KiB

View file

Before

(image error) Size: 52 KiB

After

(image error) Size: 52 KiB

Some files were not shown because too many files have changed in this diff Show more