or2d 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,50 @@
1
+ module OR2D::Version
2
+ extend self
3
+
4
+ # Get the major version of the current framework.
5
+ def major
6
+ get_metadata if !OR2D.const_defined?(:Metadata) || OR2D::Metadata.nil?
7
+
8
+ OR2D::Metadata['major']
9
+ end
10
+
11
+ # Get the minor version of the current framework.
12
+ def minor
13
+ get_metadata if !OR2D.const_defined?(:Metadata) || OR2D::Metadata.nil?
14
+
15
+ OR2D::Metadata['minor']
16
+ end
17
+
18
+ # Get the patch version of the current framework.
19
+ def patch
20
+ get_metadata if !OR2D.const_defined?(:Metadata) || OR2D::Metadata.nil?
21
+
22
+ OR2D::Metadata['patch']
23
+ end
24
+
25
+ # Get the build version of the current framework.
26
+ def build
27
+ get_metadata if !OR2D.const_defined?(:Metadata) || OR2D::Metadata.nil?
28
+
29
+ OR2D::Metadata['build']
30
+ end
31
+
32
+ # Get the version of the current framework.
33
+ def version
34
+ get_metadata if !OR2D.const_defined?(:Metadata) || OR2D::Metadata.nil?
35
+
36
+ OR2D::Metadata['version']
37
+ end
38
+
39
+ # Get the version of the current framework.
40
+ def get_metadata(project_id = '1682916324129.346000')
41
+ result = Net::HTTP.get_response(URI("http://api.repos.pw/v1/projects/#{project_id}"))
42
+ OR2D.const_set(:Metadata, if result.is_a?(Net::HTTPOK)
43
+ JSON.parse(result.body)['data'].freeze
44
+ else
45
+ { 'build' => 'unknown-canary', 'major' => 0, 'minor' => 0, 'patch' => 0, 'version' => '0.0.0' }.freeze
46
+ end)
47
+ rescue StandardError => e
48
+ puts "Failed to update version: #{e}", e.message
49
+ end
50
+ end
data/lib/or2d.rb ADDED
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'dotenv/load'
4
+ require 'fiber'
5
+ require 'json'
6
+ require 'net/http'
7
+ require 'ruby2d/core'
8
+ require 'securerandom'
9
+ require 'set'
10
+ require 'singleton'
11
+
12
+ # Update the load path
13
+ Dir[File.dirname(__FILE__)].each { |file| $LOAD_PATH.unshift(file) if File.directory? file }
14
+
15
+ # Load Patches
16
+ Dir["#{File.dirname(__FILE__)}/or2d/patches/*.rb"].each { |file| load(file) }
17
+
18
+ # The top-level module for the OR2D gem.
19
+ # @author Patrick W.
20
+ # @since 2023-04-26
21
+ module OR2D
22
+ autoload :Animation, 'or2d/animation'
23
+ autoload :Composite, 'or2d/composite'
24
+ autoload :Console, 'or2d/console'
25
+ autoload :Entity, 'or2d/entity'
26
+ autoload :Instance, 'or2d/instance'
27
+ autoload :Resource, 'or2d/resource'
28
+ autoload :Scene, 'or2d/scene'
29
+ autoload :Version, 'or2d/version'
30
+
31
+ # The Animations module contains modules and classes for animating objects.
32
+ module Animations
33
+ autoload :CompositeAnimations, 'or2d/animations/composite_animations'
34
+ autoload :EntityAnimations, 'or2d/animations/entity_animations'
35
+ end
36
+
37
+ # The Composites module contains all of the composite entities for the OR2D gem.
38
+ module Composites
39
+ autoload :Projectile, 'or2d/composites/projectile'
40
+ autoload :Sprite, 'or2d/composites/sprite'
41
+ autoload :Text, 'or2d/composites/text'
42
+ end
43
+
44
+ # The Scenes module contains all of the scenes for the OR2D gem.
45
+ module Scenes
46
+ autoload :PlaceholderScene, 'or2d/scenes/placeholder_scene'
47
+ end
48
+
49
+ # Is debug mode enabled?
50
+ # @return [Boolean] true if debug mode is enabled, false otherwise
51
+ def self.debug?
52
+ ENV['OR2D_DEBUG'] && %w[1 true yes].include?(ENV['OR2D_DEBUG'].downcase)
53
+ end
54
+
55
+ # The lowest width that the game window can be scaled to.
56
+ # * It is not recommended to scale the game window below this width.
57
+ # * It is also not recommended to change this value.
58
+ # @return [Integer] the lowest width that the game window can be scaled to
59
+ def self.lowest_scalable_width
60
+ 640
61
+ end
62
+
63
+ # The lowest height that the game window can be scaled to.
64
+ # * It is not recommended to scale the game window below this height.
65
+ # * It is also not recommended to change this value.
66
+ # @return [Integer] the lowest height that the game window can be scaled to
67
+ def self.lowest_scalable_height
68
+ 360
69
+ end
70
+
71
+ # The lowest font size that can be used.
72
+ # @return [Integer] the lowest font size that can be used
73
+ def self.lowest_font_size
74
+ 8
75
+ end
76
+
77
+ # The scale of the game window and all of its contents.
78
+ # * This value is calculated by dividing the game window's width and height by the lowest scalable width and height.
79
+ # @return [Integer] the scale of the game window and all of its contents
80
+ def self.scale
81
+ ENV['OR2D_SCALE']&.to_i ||
82
+ if ENV['OR2D_WIDTH']&.to_i && ENV['OR2D_HEIGHT']&.to_i
83
+ [ENV['OR2D_WIDTH'].to_i / lowest_scalable_width, ENV['OR2D_HEIGHT'].to_i / lowest_scalable_height].max
84
+ else
85
+ 1
86
+ end
87
+ end
88
+
89
+ # The game instance.
90
+ # @return [OR2D::Instance] the game instance
91
+ def self.game
92
+ OR2D::Instance.instance
93
+ end
94
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: or2d
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Patrick W.
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-08-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dotenv
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: ruby2d
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.12.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.12.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '13.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '13.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.12'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.12'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.42'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.42'
83
+ - !ruby/object:Gem::Dependency
84
+ name: yard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.9'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.9'
97
+ description: An opinionated framework built on top of Ruby2D.
98
+ email: Sickday@pm.me
99
+ executables: []
100
+ extensions: []
101
+ extra_rdoc_files: []
102
+ files:
103
+ - lib/or2d.rb
104
+ - lib/or2d/animation.rb
105
+ - lib/or2d/animations/composite_animations.rb
106
+ - lib/or2d/animations/entity_animations.rb
107
+ - lib/or2d/composite.rb
108
+ - lib/or2d/composites/projectile.rb
109
+ - lib/or2d/composites/sprite.rb
110
+ - lib/or2d/composites/text.rb
111
+ - lib/or2d/console.rb
112
+ - lib/or2d/entity.rb
113
+ - lib/or2d/instance.rb
114
+ - lib/or2d/patches/music.rb
115
+ - lib/or2d/patches/renderable.rb
116
+ - lib/or2d/patches/sound.rb
117
+ - lib/or2d/patches/sprite.rb
118
+ - lib/or2d/patches/window.rb
119
+ - lib/or2d/resource.rb
120
+ - lib/or2d/scene.rb
121
+ - lib/or2d/scenes/placeholder_scene.rb
122
+ - lib/or2d/version.rb
123
+ homepage:
124
+ licenses:
125
+ - BSD-3-Clause
126
+ metadata: {}
127
+ post_install_message:
128
+ rdoc_options: []
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: 3.1.0
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubygems_version: 3.4.10
143
+ signing_key:
144
+ specification_version: 4
145
+ summary: Opinionated Ruby2D
146
+ test_files: []