mirror of
https://github.com/cyberarm/cyberarm_engine.git
synced 2025-12-17 13:32:34 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 002a01abfc | |||
| 6f7bac3880 | |||
| 993e59aa94 | |||
| e30ed7c6be | |||
| a172c24d97 | |||
| 003715f685 |
@@ -5,7 +5,7 @@ module CyberarmEngine
|
|||||||
SONGS = {}
|
SONGS = {}
|
||||||
|
|
||||||
attr_accessor :show_cursor
|
attr_accessor :show_cursor
|
||||||
attr_reader :current_state, :last_frame_time
|
attr_reader :last_frame_time
|
||||||
|
|
||||||
def self.now
|
def self.now
|
||||||
Gosu.milliseconds
|
Gosu.milliseconds
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ module CyberarmEngine
|
|||||||
include Common
|
include Common
|
||||||
|
|
||||||
attr_accessor :image, :angle, :position, :velocity, :center_x, :center_y, :scale_x, :scale_y,
|
attr_accessor :image, :angle, :position, :velocity, :center_x, :center_y, :scale_x, :scale_y,
|
||||||
:color, :alpha, :mode, :options, :paused, :radius, :last_position
|
:color, :mode, :options, :paused, :radius, :last_position
|
||||||
|
attr_reader :alpha
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
if options[:auto_manage] || options[:auto_manage] == nil
|
if options[:auto_manage] || options[:auto_manage] == nil
|
||||||
$window.current_state.add_game_object(self)
|
$window.current_state.add_game_object(self)
|
||||||
@@ -141,7 +142,7 @@ module CyberarmEngine
|
|||||||
self.angle%=360
|
self.angle%=360
|
||||||
end
|
end
|
||||||
|
|
||||||
def alpha=int # 0-255
|
def alpha=(int) # 0-255
|
||||||
@alpha = int
|
@alpha = int
|
||||||
@alpha = 255 if @alpha > 255
|
@alpha = 255 if @alpha > 255
|
||||||
@color = Gosu::Color.rgba(@color.red, @color.green, @color.blue, int)
|
@color = Gosu::Color.rgba(@color.red, @color.green, @color.blue, int)
|
||||||
|
|||||||
@@ -49,11 +49,17 @@ module CyberarmEngine
|
|||||||
return temp
|
return temp
|
||||||
end
|
end
|
||||||
|
|
||||||
# returns whether both bounding boxes intersect
|
# returns whether bounding box intersects other
|
||||||
def intersect?(other)
|
def intersect?(other)
|
||||||
|
if other.is_a?(Ray)
|
||||||
|
other.intersect?(self)
|
||||||
|
elsif other.is_a?(BoundingBox)
|
||||||
(@min.x <= other.max.x && @max.x >= other.min.x) &&
|
(@min.x <= other.max.x && @max.x >= other.min.x) &&
|
||||||
(@min.y <= other.max.y && @max.y >= other.min.y) &&
|
(@min.y <= other.max.y && @max.y >= other.min.y) &&
|
||||||
(@min.z <= other.max.z && @max.z >= other.min.z)
|
(@min.z <= other.max.z && @max.z >= other.min.z)
|
||||||
|
else
|
||||||
|
raise "Unknown collider: #{other.class}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# does this bounding box envelop other bounding box? (inclusive of border)
|
# does this bounding box envelop other bounding box? (inclusive of border)
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ module CyberarmEngine
|
|||||||
# Ref: https://github.com/vaiorabbit/ruby-opengl/blob/master/sample/OrangeBook/brick.rb
|
# Ref: https://github.com/vaiorabbit/ruby-opengl/blob/master/sample/OrangeBook/brick.rb
|
||||||
class Shader
|
class Shader
|
||||||
include OpenGL
|
include OpenGL
|
||||||
|
@@shaders = {}
|
||||||
|
|
||||||
def self.add(name, instance)
|
def self.add(name, instance)
|
||||||
@shaders ||= {}
|
@@shaders[name] = instance
|
||||||
@shaders[name] = instance
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.use(name, &block)
|
def self.use(name, &block)
|
||||||
shader = @shaders.dig(name)
|
shader = @@shaders.dig(name)
|
||||||
if shader
|
if shader
|
||||||
shader.use(&block)
|
shader.use(&block)
|
||||||
else
|
else
|
||||||
@@ -17,6 +17,14 @@ module CyberarmEngine
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.available?(name)
|
||||||
|
@@shaders.dig(name).is_a?(Shader)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.get(name)
|
||||||
|
@@shaders.dig(name)
|
||||||
|
end
|
||||||
|
|
||||||
def self.active_shader
|
def self.active_shader
|
||||||
@active_shader
|
@active_shader
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
module CyberarmEngine
|
module CyberarmEngine
|
||||||
NAME = "InDev"
|
NAME = "InDev"
|
||||||
VERSION = "0.10.0"
|
VERSION = "0.10.2"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user