mirror of
https://github.com/cyberarm/i-mic-rts.git
synced 2025-12-15 15:52:34 +00:00
Tanks turret is now centered on its body
This commit is contained in:
@@ -10,8 +10,8 @@ class IMICRTS
|
|||||||
a = (360.0 + (_angle - @parent.angle)) % 360.0
|
a = (360.0 + (_angle - @parent.angle)) % 360.0
|
||||||
|
|
||||||
# FIXME: Fails if vector is directly behind entity
|
# FIXME: Fails if vector is directly behind entity
|
||||||
if @parent.angle.between?(_angle - 3, _angle + 3)
|
if a.round == 180
|
||||||
@parent.angle = _angle
|
@parent.angle = (_angle + 180.0) % 360.0
|
||||||
elsif a < 180
|
elsif a < 180
|
||||||
@parent.angle -= 1.0
|
@parent.angle -= 1.0
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class IMICRTS
|
|||||||
def draw
|
def draw
|
||||||
render unless @render
|
render unless @render
|
||||||
@angle += 0.1
|
@angle += 0.1
|
||||||
@render.draw_rot(@parent.position.x + @center.x, @parent.position.y + @center.y, @parent.position.z, @angle)
|
@render.draw_rot(@parent.position.x, @parent.position.y, @parent.position.z, @angle, @center.x, @center.y)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -5,11 +5,12 @@ IMICRTS::Entity.define_entity(:tank, :unit, 800, "Attacks ground targets") do |e
|
|||||||
entity.radius = 14
|
entity.radius = 14
|
||||||
entity.movement = :ground
|
entity.movement = :ground
|
||||||
entity.max_health = 100.0
|
entity.max_health = 100.0
|
||||||
|
entity.center.y = 0.3125
|
||||||
|
|
||||||
entity.shell_image = "vehicles/tank/tank_shell.png"
|
entity.shell_image = "vehicles/tank/tank_shell.png"
|
||||||
|
|
||||||
entity.component(:turret).shell_image = "vehicles/tank/tank_turret_shell.png"
|
entity.component(:turret).shell_image = "vehicles/tank/tank_turret_shell.png"
|
||||||
entity.component(:turret).center.y = 0.4
|
entity.component(:turret).center.y = 0.3125
|
||||||
|
|
||||||
entity.on_tick do
|
entity.on_tick do
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class IMICRTS
|
|||||||
attr_reader :player, :id, :name, :type, :speed
|
attr_reader :player, :id, :name, :type, :speed
|
||||||
attr_accessor :position, :angle, :radius, :target, :state,
|
attr_accessor :position, :angle, :radius, :target, :state,
|
||||||
:movement, :health, :max_health,
|
:movement, :health, :max_health,
|
||||||
:turret
|
:turret, :center
|
||||||
def initialize(name:, player:, id:, position:, angle:, director:)
|
def initialize(name:, player:, id:, position:, angle:, director:)
|
||||||
@player = player
|
@player = player
|
||||||
@id = id
|
@id = id
|
||||||
@@ -30,6 +30,7 @@ class IMICRTS
|
|||||||
@radius = 32 / 2
|
@radius = 32 / 2
|
||||||
@target = nil
|
@target = nil
|
||||||
@state = :idle
|
@state = :idle
|
||||||
|
@center = CyberarmEngine::Vector.new(0.5, 0.5)
|
||||||
|
|
||||||
@components = {}
|
@components = {}
|
||||||
|
|
||||||
@@ -109,7 +110,7 @@ class IMICRTS
|
|||||||
|
|
||||||
def draw
|
def draw
|
||||||
render unless @render
|
render unless @render
|
||||||
@render.draw_rot(@position.x, @position.y, @position.z, @angle)
|
@render.draw_rot(@position.x, @position.y, @position.z, @angle, @center.x, @center.y)
|
||||||
|
|
||||||
component(:turret).draw if component(:turret)
|
component(:turret).draw if component(:turret)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user