diff --git a/.gitea/template b/.gitea/template new file mode 100644 index 0000000..5b4dacc --- /dev/null +++ b/.gitea/template @@ -0,0 +1,4 @@ +*.md +LICENSE +Smaug.toml +app/main.rb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..92ffbce --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +builds/ +logs/ +exceptions/ +last_replay.txt +replay.txt +.DS_Store diff --git a/.smaugignore b/.smaugignore new file mode 100644 index 0000000..a1fd452 --- /dev/null +++ b/.smaugignore @@ -0,0 +1,23 @@ +.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 diff --git a/LICENSE b/LICENSE index 2071b23..0d7f428 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) +Copyright (c) 2022 ${REPO_OWNER} 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: diff --git a/README.md b/README.md index c7854f9..7d0f06b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ -# smaug_project_template +# ${REPO_NAME} -Template repo for a Smaug project \ No newline at end of file +> ${REPO_DESCRIPTION} + +--- diff --git a/Smaug.toml b/Smaug.toml new file mode 100644 index 0000000..7745c1d --- /dev/null +++ b/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 = "${REPO_NAME_SNAKE}" +# The game's title. This will show up in the tile bar of your executable. +title = "${REPO_NAME_TITLE}" +version = "0.1.0" +authors = ["TODO: ${REPO_OWNER} "] +icon = "metadata/icon.png" +compile_ruby = false + +[dragonruby] +version = "3.0" +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" diff --git a/app/main.rb b/app/main.rb new file mode 100644 index 0000000..3cf3345 --- /dev/null +++ b/app/main.rb @@ -0,0 +1,7 @@ +require 'smaug.rb' + +def tick args + args.outputs.labels << [640, 500, '${REPO_NAME_TITLE}', 5, 1] + args.outputs.labels << [640, 460, '${REPO_DESCRIPTION}', 5, 1] + args.outputs.sprites << [576, 280, 128, 101, 'dragonruby.png'] +end diff --git a/app/repl.rb b/app/repl.rb new file mode 100644 index 0000000..56390c1 --- /dev/null +++ b/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 diff --git a/app/tests.rb b/app/tests.rb new file mode 100644 index 0000000..db71ff6 --- /dev/null +++ b/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 diff --git a/data/.gitkeep b/data/.gitkeep new file mode 100644 index 0000000..c1ffee3 --- /dev/null +++ b/data/.gitkeep @@ -0,0 +1 @@ +Put level data and other txt files here. \ No newline at end of file diff --git a/fonts/.gitkeep b/fonts/.gitkeep new file mode 100644 index 0000000..a03e35e --- /dev/null +++ b/fonts/.gitkeep @@ -0,0 +1 @@ +Put your custom fonts here. \ No newline at end of file diff --git a/metadata/game_metadata.txt b/metadata/game_metadata.txt new file mode 100644 index 0000000..b5fa83c --- /dev/null +++ b/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} <todo@example.com> +gameid=${REPO_NAME_SNAKE} +gametitle=${REPO_NAME_TITLE} +version=0.1.0 +icon=metadata/icon.png +compile_ruby=false diff --git a/metadata/icon.png b/metadata/icon.png new file mode 100644 index 0000000..e20e8c2 Binary files /dev/null and b/metadata/icon.png differ diff --git a/metadata/ios_metadata.txt b/metadata/ios_metadata.txt new file mode 100644 index 0000000..8782cfc --- /dev/null +++ b/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= diff --git a/smaug.rb b/smaug.rb new file mode 100644 index 0000000..209d398 --- /dev/null +++ b/smaug.rb @@ -0,0 +1,4 @@ +# This file was automatically @generated by Smaug. +# Do not manually edit this file. Edit Smaug.toml instead. + + diff --git a/sounds/.gitkeep b/sounds/.gitkeep new file mode 100644 index 0000000..a99ec00 --- /dev/null +++ b/sounds/.gitkeep @@ -0,0 +1 @@ +Put your sounds here. \ No newline at end of file diff --git a/sprites/misc/dragon-0.png b/sprites/misc/dragon-0.png new file mode 100644 index 0000000..fb179af Binary files /dev/null and b/sprites/misc/dragon-0.png differ diff --git a/sprites/misc/dragon-1.png b/sprites/misc/dragon-1.png new file mode 100644 index 0000000..8cfe531 Binary files /dev/null and b/sprites/misc/dragon-1.png differ diff --git a/sprites/misc/dragon-2.png b/sprites/misc/dragon-2.png new file mode 100644 index 0000000..cb462e1 Binary files /dev/null and b/sprites/misc/dragon-2.png differ diff --git a/sprites/misc/dragon-3.png b/sprites/misc/dragon-3.png new file mode 100644 index 0000000..04c4977 Binary files /dev/null and b/sprites/misc/dragon-3.png differ diff --git a/sprites/misc/dragon-4.png b/sprites/misc/dragon-4.png new file mode 100644 index 0000000..b29fa3d Binary files /dev/null and b/sprites/misc/dragon-4.png differ diff --git a/sprites/misc/dragon-5.png b/sprites/misc/dragon-5.png new file mode 100644 index 0000000..99f4e74 Binary files /dev/null and b/sprites/misc/dragon-5.png differ diff --git a/sprites/misc/explosion-0.png b/sprites/misc/explosion-0.png new file mode 100644 index 0000000..f48636f Binary files /dev/null and b/sprites/misc/explosion-0.png differ diff --git a/sprites/misc/explosion-1.png b/sprites/misc/explosion-1.png new file mode 100644 index 0000000..b4018d9 Binary files /dev/null and b/sprites/misc/explosion-1.png differ diff --git a/sprites/misc/explosion-2.png b/sprites/misc/explosion-2.png new file mode 100644 index 0000000..3abaedd Binary files /dev/null and b/sprites/misc/explosion-2.png differ diff --git a/sprites/misc/explosion-3.png b/sprites/misc/explosion-3.png new file mode 100644 index 0000000..fe94a5a Binary files /dev/null and b/sprites/misc/explosion-3.png differ diff --git a/sprites/misc/explosion-4.png b/sprites/misc/explosion-4.png new file mode 100644 index 0000000..ed04237 Binary files /dev/null and b/sprites/misc/explosion-4.png differ diff --git a/sprites/misc/explosion-5.png b/sprites/misc/explosion-5.png new file mode 100644 index 0000000..2cd8f06 Binary files /dev/null and b/sprites/misc/explosion-5.png differ diff --git a/sprites/misc/explosion-6.png b/sprites/misc/explosion-6.png new file mode 100644 index 0000000..e55909c Binary files /dev/null and b/sprites/misc/explosion-6.png differ diff --git a/sprites/misc/explosion-sheet.png b/sprites/misc/explosion-sheet.png new file mode 100644 index 0000000..8559a5c Binary files /dev/null and b/sprites/misc/explosion-sheet.png differ