19928/jj_vitp/Implementation/support/vitp_position.e
Jocelyn Fiat 6dde6425c2 init
2024-06-17 09:09:33 +02:00

73 lines
1.6 KiB
Plaintext

note
description: "[
Used by each {ATTACK_UNIT} to place it at some position on the board.
This is used for interfacing with a GUI. The position is stored as
a percentage of the size of the space in which a unit can move (i.e.
the size of a board).
]"
author: "Jimmy J. Johnson"
class
VITP_POSITION
inherit
POSITION_CONSTANTS
redefine
out
end
create
default_create,
set_xy,
from_tuple
convert
from_tuple ({TUPLE [lat: INTEGER_32; long: INTEGER_32]})
feature {NONE} -- Initialization
from_tuple (a_position: TUPLE [long: INTEGER_32; lat: INTEGER_32])
-- Set Current to `a_position'
do
longitude := a_position.long
latitude := a_position.lat
end
feature -- Access
longitude: INTEGER_32
-- The position east or west of the logical center (0, 0) of the board.
latitude: INTEGER_32
-- The position north or south of the logical center (0,0) of the board.
out: STRING
-- String representation of Current
do
Result := "(" + longitude.out + ", " + latitude.out + ")"
end
feature -- Element change
set_xy (a_x, a_y: INTEGER_32)
-- Set the value of x and y
require
-- x_big_enough: a_x >= Minimum_longitude
-- x_small_enough: a_x <= Maximum_longitude
-- y_big_enough: a_y >= Minimum_latitude
-- y_small_enough: a_y <= Maximum_latitude
do
longitude := a_x
latitude := a_y
end
invariant
-- longitude_big_enough: longitude >= Minimum_longitude
-- longitude_small_enough: longitude <= Maximum_longitude
-- latitude_big_enough: latitude >= Minimum_latitude
-- latitude_small_enough: latitude <= Maximum_latitude
end