mirror of
https://github.com/cyberarm/cyberarm_engine.git
synced 2025-12-16 21:22:33 +00:00
Added support for passing flags to get_image, aliased Vector#weight/= to Vector#w/=
This commit is contained in:
@@ -54,7 +54,7 @@ module CyberarmEngine
|
|||||||
return Gosu::Color.rgba(color.red, color.green, color.blue, alpha)
|
return Gosu::Color.rgba(color.red, color.green, color.blue, alpha)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_asset(path, hash, klass)
|
def get_asset(path, hash, klass, retro = false, tileable = false)
|
||||||
asset = nil
|
asset = nil
|
||||||
hash.detect do |_asset, instance|
|
hash.detect do |_asset, instance|
|
||||||
if _asset == path
|
if _asset == path
|
||||||
@@ -64,7 +64,12 @@ module CyberarmEngine
|
|||||||
end
|
end
|
||||||
|
|
||||||
unless asset
|
unless asset
|
||||||
instance = klass.new(path)
|
instance = nil
|
||||||
|
if klass == Gosu::Image
|
||||||
|
instance = klass.new(path, retro: retro, tileable: tileable)
|
||||||
|
else
|
||||||
|
instance = klass.new(path)
|
||||||
|
end
|
||||||
hash[path] = instance
|
hash[path] = instance
|
||||||
asset = instance
|
asset = instance
|
||||||
end
|
end
|
||||||
@@ -72,8 +77,8 @@ module CyberarmEngine
|
|||||||
return asset
|
return asset
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_image(path)
|
def get_image(path, retro: false, tileable: false)
|
||||||
get_asset(path, Engine::IMAGES, Gosu::Image)
|
get_asset(path, Engine::IMAGES, Gosu::Image, retro, tileable)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_sample(path)
|
def get_sample(path)
|
||||||
|
|||||||
@@ -7,11 +7,6 @@ module CyberarmEngine
|
|||||||
raise "Transform is wrong size! Got #{@elements.size}, expected 16" if 16 != @elements.size
|
raise "Transform is wrong size! Got #{@elements.size}, expected 16" if 16 != @elements.size
|
||||||
end
|
end
|
||||||
|
|
||||||
def error(pos)
|
|
||||||
p @elements
|
|
||||||
Vector.new(@elements[3], @elements[7]) - pos
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.rotate(angle, rotate_around = nil)
|
def self.rotate(angle, rotate_around = nil)
|
||||||
double c = Math.cos(angle).degrees_to_radians
|
double c = Math.cos(angle).degrees_to_radians
|
||||||
double s = Math.sin(angle).degrees_to_radians
|
double s = Math.sin(angle).degrees_to_radians
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ module CyberarmEngine
|
|||||||
def weight; @weight; end
|
def weight; @weight; end
|
||||||
def weight=(n); @weight = n; end
|
def weight=(n); @weight = n; end
|
||||||
|
|
||||||
|
alias w weight
|
||||||
|
alias w= weight=
|
||||||
|
|
||||||
def ==(other)
|
def ==(other)
|
||||||
if other.is_a?(Numeric)
|
if other.is_a?(Numeric)
|
||||||
@x == other &&
|
@x == other &&
|
||||||
|
|||||||
Reference in New Issue
Block a user