-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- tail that follows you - grows as you eat dots - uses tweening - is pretty cool
- Loading branch information
1 parent
a25a0a8
commit 98bfa69
Showing
10 changed files
with
146 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[gd_scene load_steps=3 format=2] | ||
|
||
[ext_resource path="res://Scripts/Tail.gd" type="Script" id=1] | ||
[ext_resource path="res://Textures/temp_pickup.png" type="Texture" id=2] | ||
|
||
[node name="Tail" type="Node2D"] | ||
script = ExtResource( 1 ) | ||
|
||
[node name="Sprite" type="Sprite" parent="."] | ||
modulate = Color( 0.313726, 1, 0.356863, 1 ) | ||
scale = Vector2( 0.3, 0.3 ) | ||
texture = ExtResource( 2 ) |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
extends Sprite | ||
|
||
export (float) var return_time | ||
var tween | ||
|
||
func _ready(): | ||
tween = get_node("Tween") | ||
|
||
func return_to_zero(): | ||
var tau = 6.283185 | ||
|
||
# setting it back to zero | ||
var rots = rotation / tau | ||
var floored_rotation = float(int(rots)) * tau | ||
var scaled_rot = rotation - floored_rotation | ||
set_rotation(scaled_rot) | ||
|
||
# choose which way to turn | ||
rots = rotation / tau | ||
var desired_radians | ||
if rots > 1 or rots < -1: | ||
print("oh shit my guy, rotations for the player sprite was greater than one! was: ", rots) | ||
if rots > 0.5 or rots < -0.5: | ||
desired_radians = tau | ||
else: | ||
desired_radians = 0 | ||
|
||
# tween there | ||
tween.interpolate_property(self, "rotation", rotation, desired_radians, return_time, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT) | ||
tween.start() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
extends Node2D | ||
|
||
const SMOOTH_SPEED = 10 | ||
|
||
var follow_node | ||
var offset | ||
var speed_multiplier | ||
|
||
func set_tail(player_node, player_offset, index): | ||
follow_node = player_node | ||
offset = player_offset | ||
speed_multiplier = index | ||
|
||
func _physics_process(delta): | ||
#var length = follow_node.linear_velocity.normalized().length() | ||
var forward = follow_node.global_transform.basis_xform(Vector2(-1,0)) | ||
var pos = follow_node.position + forward * offset | ||
|
||
var position_difference = pos - position | ||
var smoothed_velocity = (position_difference * SMOOTH_SPEED * delta) / speed_multiplier | ||
|
||
position += smoothed_velocity |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
extends Node2D | ||
|
||
var tails = [] | ||
onready var tail = preload("res://Nodes/Tail.tscn") | ||
export (int) var offset | ||
var player | ||
|
||
# maybe apply impulse?? | ||
|
||
func _ready(): | ||
player = get_parent().get_node("Player") | ||
|
||
func _process(delta): | ||
# totalscore / (points * pickup) | ||
var tail_points = int(player.total_score / (player.pickup_points * player.pickups_per_tail)) | ||
if tails.size() < tail_points: | ||
add_tail() | ||
|
||
func add_tail(): | ||
var inst = tail.instance() | ||
tails.append(inst) | ||
inst.position = player.position | ||
inst.set_tail(player, offset * tails.size(), tails.size()) | ||
add_child(inst) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="StreamTexture" | ||
path="res://.import/temp_player.png-e2d962cc47d0441e13206b3b1d4b953c.stex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://Textures/temp_player.png" | ||
dest_files=[ "res://.import/temp_player.png-e2d962cc47d0441e13206b3b1d4b953c.stex" ] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/lossy_quality=0.7 | ||
compress/hdr_mode=0 | ||
compress/bptc_ldr=0 | ||
compress/normal_map=0 | ||
flags/repeat=0 | ||
flags/filter=true | ||
flags/mipmaps=false | ||
flags/anisotropic=false | ||
flags/srgb=2 | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/HDR_as_SRGB=false | ||
process/invert_color=false | ||
stream=false | ||
size_limit=0 | ||
detect_3d=true | ||
svg/scale=1.0 |