mirror of
https://github.com/mightypanders/GMTKJam2021.git
synced 2025-01-30 21:59:55 +01:00
do rope things
This commit is contained in:
parent
b6234e082a
commit
d7747b4979
33
Rope.gd
Normal file
33
Rope.gd
Normal file
@ -0,0 +1,33 @@
|
||||
extends RigidBody2D
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
|
||||
var anchor_ahead
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
mode = RigidBody2D.MODE_STATIC
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
func start():
|
||||
mode = RigidBody2D.MODE_KINEMATIC
|
||||
|
||||
func _physics_process(delta):
|
||||
if mode == RigidBody2D.MODE_STATIC:
|
||||
if anchor_ahead != null:
|
||||
var rot_dir = get_angle_to(anchor_ahead.global_position)
|
||||
rotation += (rot_dir)
|
||||
global_position = (anchor_ahead.global_position + Vector2(10,0))
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
if mode == RigidBody2D.MODE_STATIC:
|
||||
if anchor_ahead != null:
|
||||
var rot_dir = get_angle_to(anchor_ahead.global_position)
|
||||
rotation += (rot_dir)
|
||||
global_position = (anchor_ahead.global_position + Vector2(10,0))
|
||||
pass
|
@ -1,12 +1,14 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://assets/placeholder_white.png" type="Texture" id=1]
|
||||
[ext_resource path="res://Rope.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 1, 10 )
|
||||
|
||||
[node name="Rope" type="RigidBody2D"]
|
||||
position = Vector2( 0, 6 )
|
||||
position = Vector2( 0, 10 )
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
modulate = Color( 0.423529, 0.176471, 0, 1 )
|
||||
|
Loading…
Reference in New Issue
Block a user