felflame 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. checksums.yaml +7 -0
  2. data/.byebug_history +20 -0
  3. data/.gitignore +17 -0
  4. data/.inch.yml +11 -0
  5. data/.rspec +1 -0
  6. data/.rubocop.yml +13 -0
  7. data/.yardopts +13 -0
  8. data/CHANGELOG.md +5 -0
  9. data/Gemfile +11 -0
  10. data/Gemfile.lock +87 -0
  11. data/LICENSE +21 -0
  12. data/LICENSE.txt +21 -0
  13. data/README.mdown +410 -0
  14. data/Rakefile +45 -0
  15. data/bin/console +15 -0
  16. data/bin/setup +8 -0
  17. data/codeclimate/export-coverage.rb +16 -0
  18. data/deprecated/components/00_renderable.rb +19 -0
  19. data/deprecated/components/01_sprite.rb +57 -0
  20. data/deprecated/components/02_label.rb +32 -0
  21. data/deprecated/components/03_player_control.rb +26 -0
  22. data/deprecated/components/04_map.rb +21 -0
  23. data/deprecated/components/05_interactable.rb +16 -0
  24. data/deprecated/components/06_collidable.rb +22 -0
  25. data/deprecated/components/07_battle.rb +4 -0
  26. data/deprecated/components/07_indoor.rb +4 -0
  27. data/deprecated/components/07_overworld.rb +16 -0
  28. data/deprecated/components/debug_singleton.rb +13 -0
  29. data/deprecated/helpers/00_tileset.rb +56 -0
  30. data/deprecated/helpers/01_component.rb +74 -0
  31. data/deprecated/systems/00_update_levels.rb +34 -0
  32. data/deprecated/systems/10_player.rb +41 -0
  33. data/deprecated/systems/99_render.rb +37 -0
  34. data/docs/CNAME +1 -0
  35. data/docs/FelFlame.html +317 -0
  36. data/docs/FelFlame/ComponentManager.html +1627 -0
  37. data/docs/FelFlame/Components.html +423 -0
  38. data/docs/FelFlame/Entities.html +1054 -0
  39. data/docs/FelFlame/Helper.html +142 -0
  40. data/docs/FelFlame/Helper/ComponentManager.html +1627 -0
  41. data/docs/FelFlame/Scenes.html +761 -0
  42. data/docs/FelFlame/Stage.html +598 -0
  43. data/docs/FelFlame/Systems.html +1541 -0
  44. data/docs/_index.html +173 -0
  45. data/docs/class_list.html +51 -0
  46. data/docs/css/common.css +1 -0
  47. data/docs/css/full_list.css +58 -0
  48. data/docs/css/style.css +497 -0
  49. data/docs/file.README.html +498 -0
  50. data/docs/file_list.html +56 -0
  51. data/docs/frames.html +17 -0
  52. data/docs/index.html +498 -0
  53. data/docs/js/app.js +314 -0
  54. data/docs/js/full_list.js +216 -0
  55. data/docs/js/jquery.js +4 -0
  56. data/docs/method_list.html +475 -0
  57. data/docs/top-level-namespace.html +137 -0
  58. data/felflame.gemspec +45 -0
  59. data/lib/felflame.rb +59 -0
  60. data/lib/felflame/component_manager.rb +245 -0
  61. data/lib/felflame/entity_manager.rb +135 -0
  62. data/lib/felflame/scene_manager.rb +58 -0
  63. data/lib/felflame/stage_manager.rb +70 -0
  64. data/lib/felflame/system_manager.rb +213 -0
  65. data/lib/felflame/version.rb +5 -0
  66. data/logos/felflame-logo-text.png +0 -0
  67. data/logos/felflame-logo-text.svg +172 -0
  68. data/logos/felflame-logo.png +0 -0
  69. data/logos/felflame-logo.svg +97 -0
  70. metadata +239 -0
data/Rakefile ADDED
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ require 'rubygems'
4
+ require 'bundler/setup'
5
+ require 'rspec/core/rake_task'
6
+ require 'yard'
7
+ require_relative './codeclimate/export-coverage'
8
+ require "bundler/gem_tasks"
9
+ require "rubocop/rake_task"
10
+
11
+ task :default => [:spec, :yard, 'coverage:format']
12
+ #task default: :rubocop
13
+
14
+ RuboCop::RakeTask.new
15
+
16
+ namespace :coverage do
17
+ desc 'format coverage so it can be exported to codeclimate'
18
+ task :format do
19
+ ReportCoverage.format
20
+ end
21
+
22
+ desc 'upload coverage using your key'
23
+ task :upload do
24
+ ReportCoverage.upload
25
+ end
26
+ end
27
+
28
+ YARD::Rake::YardocTask.new do |t|
29
+ t.files = ['system_manager.rb', 'component_manager.rb', 'entity_manager.rb', 'scene_manager.rb', 'stage_manager.rb', 'felflame.rb']
30
+ t.options = ['--output-dir', './docs', 'yardoc --markup=markdown|textile|rdoc(default)']
31
+ t.stats_options = ['--list-undoc']
32
+ end
33
+
34
+ #Rake::TestTask.new do |t|
35
+ # t.pattern = "tests/**/*_test.rb"
36
+ #end
37
+
38
+ RSpec::Core::RakeTask.new :spec
39
+
40
+ # For installing FelPacks
41
+ #Gem::Specification.find_all.each do |a_gem|
42
+ # next unless a_gem.name.include? 'felpack-'
43
+ #
44
+ # Dir.glob("#{a_gem.gem_dir}/lib/#{a_gem.name.gsub('-', '/')}/tasks/*.rake").each { |r| load r }
45
+ #end
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "felflame"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,16 @@
1
+ require_relative 'env'
2
+
3
+
4
+ class ReportCoverage
5
+ class <<self
6
+ def format
7
+ puts
8
+ puts 'Formatting Coverage...'
9
+ puts `./codeclimate/test-reporter-latest-linux-amd64 format-coverage -t simplecov`
10
+ end
11
+
12
+ def upload
13
+ puts `./codeclimate/test-reporter-latest-linux-amd64 upload-coverage --id #{ENV['CC_TEST_REPORTER_ID']}`
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,19 @@
1
+ FelFlame::Components.new('Renderable', z: 0)
2
+ =begin
3
+ class Components
4
+ # If an entity can be rendered on screen
5
+ class Renderable < Helper::BaseComponent
6
+ attr_accessor :z
7
+
8
+ def initialize
9
+ @z = 0
10
+ end
11
+
12
+ def set(**opts)
13
+ opts.each do |key, value|
14
+ self.send "#{key}=", value
15
+ end
16
+ end
17
+ end
18
+ end
19
+ =end
@@ -0,0 +1,57 @@
1
+
2
+ FelFlame::Components.new('Sprite', :x, :y, :w, :h, :path, :angle, :a, :r, :g, :b,
3
+ :source_x, :source_y, :source_w, :source_h,
4
+ :tile_x, :tile_y, :tile_w, :tile_h,
5
+ :flip_horizontally, :flip_vertically,
6
+ :angle_anchor_x, :angle_anchor_y, primative_marker: :sprite)
7
+
8
+ #Components::Sprite.define_method('primative_marker') do
9
+ # :sprite
10
+ #end
11
+
12
+ =begin
13
+ class Components
14
+ # If an entity can be rendered on screen
15
+ class Sprite < Helper::BaseComponent
16
+
17
+ attr_accessor :x, :y, :w, :h, :path, :angle, :a, :r, :g, :b,
18
+ :source_x, :source_y, :source_w, :source_h,
19
+ :tile_x, :tile_y, :tile_w, :tile_h,
20
+ :flip_horizontally, :flip_vertically,
21
+ :angle_anchor_x, :angle_anchor_y
22
+
23
+ def set(x: @x, y: @y, w: @w, h: @h, path: @path, angle: @angle, a: @a, r: @r, g: @g, b: @b,
24
+ source_x: @source_x, source_y: @source_y, source_w: @source_w, source_h: @source_h,
25
+ tile_x: @tile_x, tile_y: @tile_y, tile_w: @tile_w, tile_h: @tile_h,
26
+ flip_horizontally: @flip_horizontally, flip_vertically: @flip_vertically,
27
+ angle_anchor_x: @angle_anchor_x, angle_anchor_y: @angle_anchor_y)
28
+ {x: @x = x,
29
+ y: @y = y,
30
+ w: @w = w,
31
+ h: @h = h,
32
+ path: @path = path,
33
+ angle: @angle = angle,
34
+ a: @a = a,
35
+ r: @r = r,
36
+ g: @g = g,
37
+ b: @b = b,
38
+ source_x: @source_x = source_x,
39
+ source_y: @source_y = source_y,
40
+ source_w: @source_w = source_w,
41
+ source_h: @source_h = source_h,
42
+ tile_x: @tile_x = tile_x,
43
+ tile_y: @tile_y = tile_y,
44
+ tile_w: @tile_w = tile_w,
45
+ tile_h: @tile_h = tile_h,
46
+ flip_horizontally: @flip_horizontally = flip_horizontally,
47
+ flip_vertically: @flip_vertically = flip_vertically,
48
+ angle_anchor_x: @angle_anchor_x = angle_anchor_x,
49
+ angle_anchor_y: @angle_anchor_y = angle_anchor_y}
50
+ end
51
+
52
+ def primative_marker
53
+ :sprite
54
+ end
55
+ end
56
+ end
57
+ =end
@@ -0,0 +1,32 @@
1
+
2
+ FelFlame::Components.new :Label, :x, :y, :text, :size_enum, :alignment_enum,
3
+ :a, :r, :g, :b, :font, :vertical_alignment_enum, primative_marker: :label
4
+ =begin
5
+ class Components
6
+ # A dragonruby label wrapper
7
+ class Label < Helper::BaseComponent
8
+
9
+ attr_accessor :x, :y, :text, :size_enum, :alignment_enum,
10
+ :a, :r, :g, :b, :font, :vertical_alignment_enum
11
+
12
+ def set(x: @x, y: @y, text: @text, size_enum: @size_enum, alignment_enum: @alignment_enum,
13
+ a: @a, r: @r, g: @g, b: @b, font: @font, vertical_alignment_enum: @vertical_alignment_enum)
14
+ {x: @x = x,
15
+ y: @y = y,
16
+ text: @text = text,
17
+ size_enum: @size_enum = size_enum,
18
+ alignment_enum: @alignment_enum = alignment_enum,
19
+ r: @r = r,
20
+ g: @g = g,
21
+ b: @b = b,
22
+ a: @a = a,
23
+ font: @font = font,
24
+ vertical_alignment_enum: @vertical_alignment_enum = vertical_alignment_enum }
25
+ end
26
+
27
+ def primative_marker
28
+ :label
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,26 @@
1
+
2
+ FelFlame::Components.new :PlayerControl, north: 'up', south: 'down', east: 'right',
3
+ west: 'left', interact: 'space', menu: 'enter'
4
+ =begin
5
+ class Components
6
+ # Gives control(keyboard or otherwise) over an object
7
+ class PlayerControl < Helper::BaseComponent
8
+ attr_accessor :north, :south, :east, :west, :interact, :menu
9
+
10
+ def initialize
11
+ @north = 'up'
12
+ @south = 'down'
13
+ @east = 'right'
14
+ @west = 'left'
15
+ @interact = 'space'
16
+ @menu = 'enter'
17
+ end
18
+
19
+ def set(**opts)
20
+ opts.each do |key, value|
21
+ send "#{key}=", value
22
+ end
23
+ end
24
+ end
25
+ end
26
+ =end
@@ -0,0 +1,21 @@
1
+ class Components
2
+ # dragonruby label wrapper
3
+ class Map < Helper::BaseComponent
4
+
5
+ attr_accessor :json_name, :json, :x, :y, :tilewidth, :tileheight, :a, :r, :g, :b
6
+
7
+ def set(json_name: @json_name, x: @x, y: @y, tilewidth: @tilewidth,
8
+ tileheight: @tileheight, a: @a, r: @r, g: @g, b: @b)
9
+ { json_name: @json_name = json_name,
10
+ json: @json = Helper.get_json_tiles(json_name),
11
+ x: @x = x,
12
+ y: @y = y,
13
+ tilewidth: @tilewidth = tilewidth,
14
+ tileheight: @tileheight = tileheight,
15
+ r: @r = r,
16
+ g: @g = g,
17
+ b: @b = b,
18
+ a: @a = a }
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,16 @@
1
+ class Components
2
+ # If an entity can be rendered on screen
3
+ class Interactable < Helper::BaseComponent
4
+ attr_accessor :z
5
+
6
+ def initialize
7
+ @z = z
8
+ end
9
+
10
+ def set(**opts)
11
+ opts.each do |key, value|
12
+ self.send "#{key}=", value
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,22 @@
1
+ class Components
2
+ # If an entity can be rendered on screen
3
+ class Collidable < Helper::BaseComponent
4
+ class <<self
5
+ def add(entity_id)
6
+ super(entity_id)
7
+ #add to grid?
8
+ end
9
+ end
10
+ attr_accessor :grid
11
+
12
+ def initialize
13
+ @grid = [[]]
14
+ end
15
+
16
+ def set(**opts)
17
+ opts.each do |key, value|
18
+ self.send "#{key}=", value
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,4 @@
1
+ class Components
2
+ class Battle < Helper::Level
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ class Components
2
+ class Indoor < Helper::Level
3
+ end
4
+ end
@@ -0,0 +1,16 @@
1
+ class Components
2
+ class Overworld < Helper::Level
3
+ attr_accessor :x, :y
4
+
5
+ def initialize
6
+ @x = 0
7
+ @y = 0
8
+ end
9
+
10
+ def set(**opts)
11
+ opts.each do |key, value|
12
+ self.send "#{key}=", value
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ class Components
2
+ # If an entity can be rendered on screen
3
+ class DebugSingleton
4
+ class <<self
5
+ @data = false
6
+ attr_accessor :data
7
+
8
+ def id
9
+ 0
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,56 @@
1
+ # Coverage Ignored because the functionality of this
2
+ # code will not be used for the core of FelFlame.
3
+ # It will most likely be released as a seperate package
4
+ # The code will most likely be kept here until it
5
+ # eventually will be migrated to a new git repo
6
+ # :nocov:
7
+ class Helper
8
+ # Returns a loaded map and its dependecies(images,json)
9
+ # If any are missing then it will load them from files
10
+
11
+ @json_data = {}
12
+ class <<self
13
+ attr_accessor :json_data
14
+
15
+ def get_json_tiles(json_name, hitbox: false)
16
+ unless hitbox
17
+ return nil if json_name == 'hitbox' && !Components::DebugSingleton.data
18
+ end
19
+
20
+ if self.json_data[json_name].nil?
21
+ self.json_data[json_name] = $gtk.parse_json_file "assets/json/#{json_name}.json"
22
+ raise Exception.new "#{json_name} is null and not loaded. Cannot get json tile" if self.json_data[json_name].nil?
23
+
24
+ if self.json_data[json_name]['type'] == 'map' #json_name.split("_").first == 'map'
25
+ self.json_data[json_name]['tilesets'].each do |tileset|
26
+ tileset = Helper.get_json_tiles(tileset['source'].split('/').last.delete_suffix('.tsx'))
27
+ # download tileset here
28
+ # $gtk.args.gtk.http_get 'https://mysite.net/#{tileset['name']}.png'
29
+ end
30
+ end
31
+ end
32
+ self.json_data[json_name]
33
+ end
34
+
35
+ def get_tile(json_name:, tile_index:)
36
+ if json_name == 'hitbox' && !Components::DebugSingleton.data
37
+ return tile_index - 1 if tile_index > 1
38
+ return {}
39
+ end
40
+
41
+ json_tiles = self.get_json_tiles(json_name)
42
+ raise Exception.new "Error, json file not a tileset" unless json_tiles['type'] == 'tileset'
43
+ return tile_index - json_tiles['tilecount'] if tile_index > json_tiles['tilecount']
44
+ source_height_tiles = (tile_index.to_i / json_tiles['columns'].to_i).to_i# * json_tiles['tileheight']
45
+ { w: json_tiles['tilewidth'],
46
+ h: json_tiles['tileheight'],
47
+ path: json_tiles['image'].split('mygame/').last.delete('\\'),
48
+ source_x: [((tile_index % json_tiles['columns']) - 1) * json_tiles['tilewidth'], 0].max,
49
+ # source_y gets special treatment
50
+ source_y: [json_tiles['imageheight'] - ((source_height_tiles + 1) * json_tiles['tileheight']), 0].max,
51
+ source_w: json_tiles['tilewidth'],
52
+ source_h: json_tiles['tileheight'] }
53
+ end
54
+ end
55
+ end
56
+ # :nocov:
@@ -0,0 +1,74 @@
1
+ class FelFlame
2
+ class Helper
3
+
4
+ =begin
5
+ # Unused:
6
+ class Level < FelFlame::Helper::ComponentManager
7
+ class <<self
8
+ def data
9
+ @data ||= { add: [], remove: [], grid: FelFlame::Helper::Array2D.new }
10
+ end
11
+
12
+ def add(entity_id)
13
+ super
14
+ data[:add].push entity_id
15
+ end
16
+
17
+ def remove(entity_id)
18
+ data[:remove].push entity_id
19
+ super
20
+ end
21
+ end
22
+ end
23
+ =end
24
+ =begin
25
+ class Array2D < Array
26
+ def [](val)
27
+ unless val.nil?
28
+ return self[val] = [] if super.nil?
29
+ end
30
+ super
31
+ end
32
+ end
33
+ =end
34
+ =begin
35
+ class ArrayOfHashes < Array
36
+ def [](val)
37
+ unless val.nil?
38
+ return self[val] = {} if super.nil?
39
+ end
40
+ super
41
+ end
42
+ end
43
+ =end
44
+
45
+ =begin
46
+ module ComponentHelper
47
+ class <<self
48
+ def up? char
49
+ char == char.upcase
50
+ end
51
+
52
+ def down? char
53
+ char == char.downcase
54
+ end
55
+
56
+ def underscore(input)
57
+ output = input[0].downcase
58
+ (1...(input.length - 1)).each do |iter|
59
+ if down?(input[iter]) && up?(input[iter + 1])
60
+ output += "#{input[iter].downcase}_"
61
+ elsif up?(input[iter - 1]) && up?(input[iter]) && down?(input[iter + 1])
62
+ output += "_#{input[iter].downcase}"
63
+ else
64
+ output += input[iter].downcase
65
+ end
66
+ end
67
+ output += input[-1].downcase unless input.length == 1
68
+ output
69
+ end
70
+ end
71
+ end
72
+ =end
73
+ end
74
+ end