Skip to content

Commit

Permalink
Align scripts to the guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
Scony committed Dec 29, 2024
1 parent 13f4cee commit 4f9a146
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 23 deletions.
8 changes: 4 additions & 4 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,14 @@ unit_groups_access_9={
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":57,"key_label":0,"unicode":57,"location":0,"echo":false,"script":null)
]
}
rotate_map_clock={
rotate_map_clockwise={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":81,"key_label":0,"unicode":113,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":81,"key_label":0,"unicode":113,"location":0,"echo":false,"script":null)
]
}
rotate_map_counterclock={
rotate_map_counterclockwise={
"deadzone": 0.5,
"events": [null, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":101,"echo":false,"script":null)
"events": [null, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":101,"location":0,"echo":false,"script":null)
]
}

Expand Down
41 changes: 30 additions & 11 deletions source/match/IsometricCamera3D.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
extends Camera3D

# TODO: perform rotation calculations in 3D space
# TODO: introduce _rotate_by() and simplify arrowkey rotation

const EXPECTED_X_ROTATION_DEGREES = -30.0
const EXPECTED_PROJECTION = PROJECTION_ORTHOGONAL
Expand Down Expand Up @@ -28,6 +29,7 @@ var _camera_point_3d = null
var _rotation_pos = Vector2.ZERO
var _arrowkey_rotation = false


func _ready():
assert(projection == EXPECTED_PROJECTION, "unexpected projection")
assert(
Expand All @@ -54,24 +56,33 @@ func _physics_process(delta):


func _process(_delta):
if !_is_rotating():
if not _is_rotating():
_move()
elif _arrowkey_rotation:
if (Input.is_action_pressed("rotate_map_clock")):
if Input.is_action_pressed("rotate_map_clockwise"):
_rotation_pos.x += _delta * arrowkey_rotation_speed
if (Input.is_action_pressed("rotate_map_counterclock")):
if Input.is_action_pressed("rotate_map_counterclockwise"):
_rotation_pos.x -= _delta * arrowkey_rotation_speed
_rotate(_rotation_pos)


func _unhandled_input(event):
if !_is_rotating():
if Input.is_action_just_pressed("rotate_map_clock") or Input.is_action_just_pressed("rotate_map_counterclock"):
if not _is_rotating():
if (
Input.is_action_just_pressed("rotate_map_clockwise")
or Input.is_action_just_pressed("rotate_map_counterclockwise")
):
_arrowkey_rotation = true
_start_rotation(event)
else:
if Input.is_action_just_released("rotate_map_clock") or Input.is_action_just_released("rotate_map_counterclock") :
if not (Input.is_action_pressed("rotate_map_clock") or Input.is_action_pressed("rotate_map_counterclock")):
if (
Input.is_action_just_released("rotate_map_clockwise")
or Input.is_action_just_released("rotate_map_counterclockwise")
):
if not (
Input.is_action_pressed("rotate_map_clockwise")
or Input.is_action_pressed("rotate_map_counterclockwise")
):
_arrowkey_rotation = false
_stop_rotation()
if event is InputEventMouseButton:
Expand All @@ -83,13 +94,21 @@ func _unhandled_input(event):
event.is_pressed() and event.button_index == MOUSE_BUTTON_MIDDLE and event.double_click
):
_reset_rotation()
elif event.is_pressed() and event.button_index == MOUSE_BUTTON_MIDDLE and !_arrowkey_rotation:
elif (
event.is_pressed()
and event.button_index == MOUSE_BUTTON_MIDDLE
and not _arrowkey_rotation
):
_start_rotation(event)
elif not event.is_pressed() and event.button_index == MOUSE_BUTTON_MIDDLE and !_arrowkey_rotation:
elif (
not event.is_pressed()
and event.button_index == MOUSE_BUTTON_MIDDLE
and not _arrowkey_rotation
):
_stop_rotation()
elif event is InputEventMouseMotion:
var rotation_pos = event.position #the mouse position
if !_arrowkey_rotation and _is_rotating():
var rotation_pos = event.position #the mouse position
if not _arrowkey_rotation and _is_rotating():
_rotate(rotation_pos)


Expand Down
24 changes: 16 additions & 8 deletions source/match/debug/DiagnosticHud.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,19 @@ func _unhandled_input(event):


func _physics_process(_delta):
_fps_label.text = "{0} FPS \n".format(["%0.1f" % (Performance.get_monitor(Performance.TIME_FPS))])
_fps_label.text += str(OS.get_processor_name()) + " \n"
_fps_label.text += str(OS.get_processor_count()) + " Threads Used \n"
var MBs = OS.get_static_memory_usage()/int(1000000)
_fps_label.text += str(MBs) + " MBs of Memory Used \n"
_fps_label.text += str(RenderingServer.get_video_adapter_name()) + " "
_fps_label.text += str(RenderingServer.get_video_adapter_vendor()) + " \n"
_fps_label.text += "Using " + str(OS.get_name()) + " Operating System"
_fps_label.text = (
"{0} FPS \n".format(["%0.1f" % (Performance.get_monitor(Performance.TIME_FPS))])
+ str(OS.get_processor_name())
+ " \n"
+ str(OS.get_processor_count())
+ " Threads Used \n"
+ str(OS.get_static_memory_usage() / int(1000000))
+ " MBs of Memory Used \n"
+ str(RenderingServer.get_video_adapter_name())
+ " "
+ str(RenderingServer.get_video_adapter_vendor())
+ " \n"
+ "Using "
+ str(OS.get_name())
+ " Operating System"
)

0 comments on commit 4f9a146

Please sign in to comment.