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