Created
July 2, 2016 05:03
-
-
Save YeOldeDM/6b3479aa18445dd43839634468fc9788 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends Position2D | |
onready var main = get_node('/root/Main') | |
func _ready(): | |
set_process(true) | |
func _process(delta): | |
# apply ship rotation to radar rotation | |
set_rot(-main.ship.get_rot()) | |
update() | |
func _draw(): | |
for body in main.get_node('Bodies').get_children(): | |
# get body position relative to ship | |
var pos = (main.ship.get_global_pos() - body.get_global_pos())*0.05 | |
# get opacity based on distance | |
var O = clamp(pos.length()/200, 0.0, 1.0) | |
# draw a circle in radar space | |
draw_circle(pos, 2, Color(1,1,1,1.0-O)) | |
# draw a circle for the radar center (you are here) | |
draw_circle(Vector2(0,0), 3, Color(0,1,0)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment