Added construction complete order, added jeep overlay image to show windscreen, added rotors component for helicopter; more work needed, replaced all build and vehicle assets with ones that are 6x larger to prevent pixelization when zoomed in, misc.

This commit is contained in:
2021-01-08 12:41:04 -06:00
parent 0d449b9375
commit a3c3939f50
45 changed files with 149 additions and 66 deletions

View File

@@ -3,6 +3,8 @@ class IMICRTS
def setup
data.construction_progress ||= 0
data.construction_goal ||= Entity.get(@parent.name).build_steps
data.construction_complete ||= false
data.construction_complete_ordered ||= false
@text = CyberarmEngine::Text.new("", y: @parent.position.y, z: Float::INFINITY, size: 12)
data.state = :construct # deconstruct, building, idle
@@ -32,7 +34,7 @@ class IMICRTS
end
def construction_complete?
data.construction_progress >= data.construction_goal
data.construction_progress >= data.construction_goal && data.construction_complete
end
# WARNING: returns a floating point number, not network safe!
@@ -44,7 +46,14 @@ class IMICRTS
raise TypeError, "Got a non integer value!" unless work.is_a?(Integer)
data.construction_progress += work
data.construction_progress = data.construction_goal if construction_complete?
return unless data.construction_progress > data.construction_goal
data.construction_progress = data.construction_goal
unless data.construction_complete_ordered
@parent.director.schedule_order(IMICRTS::Order::CONSTRUCTION_COMPLETE, @parent.player.id, @parent.id)
data.construction_complete_ordered = true
end
end
def draw_construction

42
lib/components/rotors.rb Normal file
View File

@@ -0,0 +1,42 @@
class IMICRTS
class Rotors < Component
attr_accessor :angle, :speed, :center
def setup
@angle = 0
@speed = 1
@center = CyberarmEngine::Vector.new(0.5, 0.5)
end
def body_image=(image)
@body_image = get_image("#{IMICRTS::ASSETS_PATH}/#{image}", retro: true)
end
def shell_image=(image)
@shell_image = get_image("#{IMICRTS::ASSETS_PATH}/#{image}", retro: true)
end
def overlay_image=(image)
@overlay_image = get_image("#{IMICRTS::ASSETS_PATH}/#{image}", retro: true)
end
def render
image = @shell_image || @body_image || @overlay_image
@render = Gosu.render(image.width, image.height, retro: true) do
@body_image&.draw(0, 0, 0)
@shell_image&.draw_rot(0, 0, 0, 0, 0, 0, 1, 1, @parent.player.color)
@overlay_image&.draw(0, 0, 0)
end
end
def draw
render unless @render
@render.draw_rot(@parent.position.x, @parent.position.y, @parent.position.z, @angle, @center.x, @center.y, @parent.scale.x, @parent.scale.y)
end
def update
@angle += @speed
end
end
end

View File

@@ -1,6 +1,7 @@
class IMICRTS
class Turret < Component
attr_accessor :angle, :center
def setup
@angle = 0
@center = CyberarmEngine::Vector.new(0.5, 0.5)
@@ -19,16 +20,18 @@ class IMICRTS
end
def render
@render = Gosu.render(32, 32, retro: true) do
@body_image.draw(0, 0, 0) if @body_image
@shell_image.draw_rot(0, 0, 0, 0, 0, 0, 1, 1, @parent.player.color) if @shell_image
@overlay_image.draw(0, 0, 0) if @overlay_image
image = @shell_image || @body_image || @overlay_image
@render = Gosu.render(image.width, image.height, retro: true) do
@body_image&.draw(0, 0, 0)
@shell_image&.draw_rot(0, 0, 0, 0, 0, 0, 1, 1, @parent.player.color)
@overlay_image&.draw(0, 0, 0)
end
end
def draw
render unless @render
@render.draw_rot(@parent.position.x, @parent.position.y, @parent.position.z, @angle, @center.x, @center.y)
@render.draw_rot(@parent.position.x, @parent.position.y, @parent.position.z, @angle, @center.x, @center.y, @parent.scale.x, @parent.scale.y)
end
def update