-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into add-i18n-support
- Loading branch information
Showing
23 changed files
with
515 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'goby' | ||
Goby::Scaffold::simple "goby-project" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require 'goby' | ||
|
||
module Goby | ||
|
||
# A chest containing gold and/or items. | ||
class Chest < Event | ||
|
||
# @param [Integer] mode convenient way for a chest to have multiple actions. | ||
# @param [Boolean] visible whether the chest can be seen/activated. | ||
# @param [Integer] gold the amount of gold in this chest. | ||
# @param [[Item]] treasures the items found in this chest. | ||
def initialize(mode: 0, visible: true, gold: 0, treasures: []) | ||
super(mode: mode, visible: visible) | ||
@command = "open" | ||
@gold = gold | ||
@treasures = treasures | ||
end | ||
|
||
# The function that runs when the player opens the chest. | ||
# | ||
# @param [Player] player the one opening the chest. | ||
def run(player) | ||
type("You open the treasure chest...\n\n") | ||
sleep(1) unless ENV['TEST'] | ||
player.add_loot(@gold, @treasures) | ||
@visible = false | ||
end | ||
|
||
attr_reader :gold, :treasures | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
module Goby | ||
|
||
# Methods for playing/stopping background music (BGM). | ||
module Music | ||
|
||
# Specify the program that should play the music. | ||
# Without overwriting, it is set to a default (see @@program). | ||
# | ||
# @param [String] name the name of the music-playing program. | ||
def set_program(name) | ||
@@program = name | ||
end | ||
|
||
# Specify if music should play or not. | ||
# May be useful to stop/start music for dramatic effect. | ||
# | ||
# @param [Boolean] flag true iff music should play. | ||
def set_playback(flag) | ||
@@playback = flag | ||
end | ||
|
||
# Starts playing the music from the specified file. | ||
# This has only been tested on Ubuntu w/ .mid files. | ||
# | ||
# @param [String] filename the file containing the music. | ||
def play_music(filename) | ||
return unless @@playback | ||
|
||
if (filename != @@file) | ||
stop_music | ||
@@file = filename | ||
|
||
# This thread loops the music until one calls #stop_music. | ||
@@thread = Thread.new { | ||
while (true) | ||
Process.wait(@@pid) if @@pid | ||
@@pid = Process.spawn("#{@@program} #{filename}", :out=>"/dev/null") | ||
end | ||
} | ||
end | ||
end | ||
|
||
# Kills the music process and the looping thread. | ||
def stop_music | ||
return unless @@playback | ||
|
||
Process.kill("SIGKILL", @@pid) if @@pid | ||
@@pid = nil | ||
|
||
@@thread.kill if @@thread | ||
@@thread = nil | ||
|
||
@@file = nil | ||
end | ||
|
||
@@file = nil | ||
@@pid = nil | ||
@@playback = false | ||
@@program = "timidity" | ||
@@thread = nil | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module Goby | ||
|
||
# Functions for scaffolding starter projects. | ||
module Scaffold | ||
|
||
# Simple starter project w/o testing. | ||
# | ||
# @param [String] project the project name. | ||
def self.simple(project) | ||
|
||
# TODO: detect existence of project folder. | ||
|
||
# Make the directory structure. | ||
Dir.mkdir project | ||
dirs = [ '', 'battle', 'entity', | ||
'event', 'item', 'map' ] | ||
dirs.each do |dir| | ||
Dir.mkdir "#{project}/src/#{dir}" | ||
end | ||
|
||
# Create the source files. | ||
gem_location = %x[gem which goby].chomp "/lib/goby.rb\n" | ||
files = { '.gitignore': '../gitignore', | ||
'src/main.rb': 'main.rb', | ||
'src/map/farm.rb': 'farm.rb' } | ||
files.each do |dest, source| | ||
File.open("#{project}/#{dest.to_s}", 'w') do |w| | ||
w.write(File.read "#{gem_location}/res/scaffold/simple/#{source}") | ||
end | ||
end | ||
|
||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
*.gem | ||
*.rbc | ||
/.config | ||
/coverage/ | ||
/InstalledFiles | ||
/pkg/ | ||
/spec/reports/ | ||
/spec/examples.txt | ||
/test/tmp/ | ||
/test/version_tmp/ | ||
/tmp/ | ||
|
||
# Used by dotenv library to load environment variables. | ||
# .env | ||
|
||
## Specific to RubyMotion: | ||
.dat* | ||
.repl_history | ||
build/ | ||
*.bridgesupport | ||
build-iPhoneOS/ | ||
build-iPhoneSimulator/ | ||
|
||
## Specific to RubyMotion (use of CocoaPods): | ||
# | ||
# We recommend against adding the Pods directory to your .gitignore. However | ||
# you should judge for yourself, the pros and cons are mentioned at: | ||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control | ||
# | ||
# vendor/Pods/ | ||
|
||
## Documentation cache and generated files: | ||
/.yardoc/ | ||
/_yardoc/ | ||
/doc/ | ||
/rdoc/ | ||
|
||
## Environment normalization: | ||
/.bundle/ | ||
/vendor/bundle | ||
/lib/bundler/man/ | ||
|
||
# for a library or gem, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# Gemfile.lock | ||
# .ruby-version | ||
# .ruby-gemset | ||
|
||
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: | ||
.rvmrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# This is an example of how to create a Map. You can | ||
# define the name, where to respawn, and the 2D display of | ||
# the Map - each point is referred to as a Tile. | ||
class Farm < Map | ||
def initialize | ||
super(name: "Farm", regen_location: Couple.new(2,2)) | ||
|
||
# Define the main tiles on this map. | ||
grass = Tile.new(description: "You are standing on some grass.") | ||
|
||
# Fill the map with "grass." | ||
@tiles = Array.new(5) { Array.new(5) { grass.clone } } | ||
|
||
end | ||
end |
Oops, something went wrong.