mirror of
https://github.com/cyberarm/i-mic-rts.git
synced 2025-12-14 07:12:34 +00:00
Orders are now de/serializable, and scheduleable, Entities now show a circle around themselves when selected and draw a line to their target
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
class IMICRTS
|
||||
class Entity
|
||||
attr_reader :id, :position, :angle, :radius
|
||||
def initialize(id:, manifest: nil, images:, position:, angle:)
|
||||
attr_reader :player, :id, :position, :angle, :radius, :target, :state
|
||||
def initialize(player:, id:, manifest: nil, images:, position:, angle:)
|
||||
@player = player
|
||||
@id = id
|
||||
@manifest = manifest
|
||||
@images = images
|
||||
@@ -9,6 +10,23 @@ class IMICRTS
|
||||
@angle = angle
|
||||
|
||||
@radius = 32 / 2
|
||||
@target = nil
|
||||
@state = :idle
|
||||
|
||||
# process_manifest
|
||||
|
||||
@goal_color = Gosu::Color.argb(175, 25, 200, 25)
|
||||
@target_color = Gosu::Color.argb(175, 200, 25, 25)
|
||||
end
|
||||
|
||||
def serialize
|
||||
end
|
||||
|
||||
def deserialize
|
||||
end
|
||||
|
||||
def target=(entity)
|
||||
@target = entity
|
||||
end
|
||||
|
||||
def hit?(x_or_vector, y = nil)
|
||||
@@ -27,16 +45,27 @@ class IMICRTS
|
||||
@images.draw_rot(@position.x, @position.y, @position.z, @angle)
|
||||
end
|
||||
|
||||
def update
|
||||
rotate_towards(@target) if @target
|
||||
end
|
||||
|
||||
def selected_draw
|
||||
draw_bounding_box
|
||||
draw_radius
|
||||
draw_gizmos
|
||||
end
|
||||
|
||||
def draw_bounding_box
|
||||
def draw_radius
|
||||
Gosu.draw_circle(@position.x, @position.y, @radius, ZOrder::ENTITY_RADIUS, @player.color)
|
||||
end
|
||||
|
||||
def draw_gizmos
|
||||
Gosu.draw_rect(@position.x - @radius, @position.y - (@radius + 2), @radius * 2, 2, Gosu::Color::GREEN, ZOrder::ENTITY_GIZMOS)
|
||||
|
||||
if @target.is_a?(IMICRTS::Entity)
|
||||
Gosu.draw_line(@position.x, @position.y, @target_color, @target.position.x, @target.position.y, @target_color, ZOrder::ENTITY_GIZMOS) if @target
|
||||
else
|
||||
Gosu.draw_line(@position.x, @position.y, @goal_color, @target.x, @target.y, @goal_color, ZOrder::ENTITY_GIZMOS) if @target
|
||||
end
|
||||
end
|
||||
|
||||
def rotate_towards(vector)
|
||||
|
||||
Reference in New Issue
Block a user