Added support for passing flags to get_image, aliased Vector#weight/= to Vector#w/=

This commit is contained in:
2019-10-08 08:53:37 -05:00
parent 51dd3803fa
commit 5d16500edd
3 changed files with 12 additions and 9 deletions

View File

@@ -54,7 +54,7 @@ module CyberarmEngine
return Gosu::Color.rgba(color.red, color.green, color.blue, alpha)
end
def get_asset(path, hash, klass)
def get_asset(path, hash, klass, retro = false, tileable = false)
asset = nil
hash.detect do |_asset, instance|
if _asset == path
@@ -64,7 +64,12 @@ module CyberarmEngine
end
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
asset = instance
end
@@ -72,8 +77,8 @@ module CyberarmEngine
return asset
end
def get_image(path)
get_asset(path, Engine::IMAGES, Gosu::Image)
def get_image(path, retro: false, tileable: false)
get_asset(path, Engine::IMAGES, Gosu::Image, retro, tileable)
end
def get_sample(path)

View File

@@ -7,11 +7,6 @@ module CyberarmEngine
raise "Transform is wrong size! Got #{@elements.size}, expected 16" if 16 != @elements.size
end
def error(pos)
p @elements
Vector.new(@elements[3], @elements[7]) - pos
end
def self.rotate(angle, rotate_around = nil)
double c = Math.cos(angle).degrees_to_radians
double s = Math.sin(angle).degrees_to_radians

View File

@@ -40,6 +40,9 @@ module CyberarmEngine
def weight; @weight; end
def weight=(n); @weight = n; end
alias w weight
alias w= weight=
def ==(other)
if other.is_a?(Numeric)
@x == other &&