Cube & Scoring Logic Part 1
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
extends Area2D
|
||||
@onready var Cursor = $Cursor
|
||||
@onready var MouseOn = true
|
||||
@export var ShowMouse = false
|
||||
var old_mouse_pos = Vector2.ZERO
|
||||
var mouse_velocity = Vector2.ZERO
|
||||
@export var vector_length = 100
|
||||
@export var vector_length = 360
|
||||
@export var vector_width = 5
|
||||
|
||||
|
||||
var line_2d : Line2D
|
||||
var is_touchingCube = false
|
||||
var collision_normal = Vector2.ZERO
|
||||
@@ -39,30 +41,32 @@ func _ready() -> void:
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
if is_touchingCube:
|
||||
draw_vector()
|
||||
# draw_vector()
|
||||
pass
|
||||
else:
|
||||
line_2d.clear_points()
|
||||
|
||||
|
||||
var current_mouse_pos = get_viewport().get_mouse_position()
|
||||
|
||||
mouse_velocity = current_mouse_pos - old_mouse_pos
|
||||
|
||||
if mouse_velocity.length_squared()>0.1:
|
||||
rotation = lerp_angle(rotation, mouse_velocity.angle(), 80 * delta)
|
||||
|
||||
if MouseOn:
|
||||
var current_mouse_pos = get_viewport().get_mouse_position()
|
||||
|
||||
var direction_to_mouse = (current_mouse_pos - global_position).normalized()
|
||||
global_position = current_mouse_pos
|
||||
|
||||
old_mouse_pos = current_mouse_pos
|
||||
mouse_velocity = current_mouse_pos - old_mouse_pos
|
||||
|
||||
if mouse_velocity.length_squared()>0.1:
|
||||
rotation = lerp_angle(rotation, mouse_velocity.angle(), 80 * delta)
|
||||
|
||||
|
||||
var direction_to_mouse = (current_mouse_pos - global_position).normalized()
|
||||
global_position = current_mouse_pos
|
||||
|
||||
old_mouse_pos = current_mouse_pos
|
||||
pass
|
||||
|
||||
|
||||
func _on_area_entered(area: Area2D) -> void:
|
||||
print("AAAA " + str(area.name))
|
||||
# print("AAAA " + str(area.name))
|
||||
if area.name == "Node2D":
|
||||
|
||||
#freeze cursor on touch block
|
||||
MouseOn = true
|
||||
is_touchingCube = true
|
||||
draw_vector()
|
||||
|
||||
@@ -92,5 +96,5 @@ func draw_vector():
|
||||
line_2d.add_point(start_point,1)
|
||||
line_2d.add_point(end_point,2)
|
||||
|
||||
print("Draws the vector\nStart %s\nEnd: %s\nDirection %s" % [start_point, end_point, vector_direction])
|
||||
#print("Draws the vector\nStart %s\nEnd: %s\nDirection %s" % [start_point, end_point, vector_direction])
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user