Skip to content

Commit

Permalink
animated cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbrain committed Jan 27, 2024
1 parent 8ddb93b commit 8dd4df5
Show file tree
Hide file tree
Showing 8 changed files with 190 additions and 19 deletions.
4 changes: 2 additions & 2 deletions godot/scenes/ingame_scene.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ extends Node2D

@onready var fade_overlay = %FadeOverlay
@onready var pause_overlay = %PauseOverlay
@onready var receptors: Array[Node] = $Receptors.get_children()
@onready var spawner: PointSpawner = $Emotions
@onready var receptors: Array[Node] = %Receptors.get_children()
@onready var spawner: PointSpawner = %Emotions


var emotional_state := 0
Expand Down
39 changes: 22 additions & 17 deletions godot/scenes/ingame_scene.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -13,57 +13,62 @@
script = ExtResource("1_objyc")

[node name="PlayerController" parent="." node_paths=PackedStringArray("player") instance=ExtResource("2_ekgim")]
player = NodePath("../Player")
player = NodePath("../Entities/Player")

[node name="Map" parent="." instance=ExtResource("2_8eyxl")]

[node name="Receptors" type="Node2D" parent="."]
[node name="Entities" type="Node2D" parent="."]
y_sort_enabled = true

[node name="Receptor" parent="Receptors" instance=ExtResource("4_x8auc")]
[node name="Receptors" type="Node2D" parent="Entities"]
unique_name_in_owner = true

[node name="Receptor" parent="Entities/Receptors" instance=ExtResource("4_x8auc")]
position = Vector2(-510, 96)

[node name="Receptor2" parent="Receptors" instance=ExtResource("4_x8auc")]
[node name="Receptor2" parent="Entities/Receptors" instance=ExtResource("4_x8auc")]
position = Vector2(401, -577)

[node name="Emotions" parent="." instance=ExtResource("4_21hy4")]
[node name="Emotions" parent="Entities" instance=ExtResource("4_21hy4")]
unique_name_in_owner = true

[node name="SpawnPosition1" type="Marker2D" parent="Emotions"]
[node name="SpawnPosition1" type="Marker2D" parent="Entities/Emotions"]
position = Vector2(-694, -689)

[node name="SpawnPosition2" type="Marker2D" parent="Emotions"]
[node name="SpawnPosition2" type="Marker2D" parent="Entities/Emotions"]
position = Vector2(-227, -389)

[node name="SpawnPosition3" type="Marker2D" parent="Emotions"]
[node name="SpawnPosition3" type="Marker2D" parent="Entities/Emotions"]
position = Vector2(-556, 187)

[node name="SpawnPosition4" type="Marker2D" parent="Emotions"]
[node name="SpawnPosition4" type="Marker2D" parent="Entities/Emotions"]
position = Vector2(430, 19)

[node name="SpawnPosition5" type="Marker2D" parent="Emotions"]
[node name="SpawnPosition5" type="Marker2D" parent="Entities/Emotions"]
position = Vector2(302, -596)

[node name="SpawnPosition6" type="Marker2D" parent="Emotions"]
[node name="SpawnPosition6" type="Marker2D" parent="Entities/Emotions"]
position = Vector2(-317, 401)

[node name="SpawnPosition7" type="Marker2D" parent="Emotions"]
[node name="SpawnPosition7" type="Marker2D" parent="Entities/Emotions"]
position = Vector2(-602, 497)

[node name="SpawnPosition8" type="Marker2D" parent="Emotions"]
[node name="SpawnPosition8" type="Marker2D" parent="Entities/Emotions"]
position = Vector2(462, 416)

[node name="SpawnPosition9" type="Marker2D" parent="Emotions"]
[node name="SpawnPosition9" type="Marker2D" parent="Entities/Emotions"]
position = Vector2(-392, 820)

[node name="SpawnPosition10" type="Marker2D" parent="Emotions"]
[node name="SpawnPosition10" type="Marker2D" parent="Entities/Emotions"]
position = Vector2(72, 761)

[node name="Player" parent="." instance=ExtResource("2_rkgs6")]
[node name="Player" parent="Entities" instance=ExtResource("2_rkgs6")]
position = Vector2(-377, 59)
collision_layer = 2
CHARGING_ACCELERATION = 3100
MAX_SPEED = 350

[node name="Camera2D" type="Camera2D" parent="Player"]
[node name="Camera2D" type="Camera2D" parent="Entities/Player"]
limit_left = -1024
limit_top = -1024
limit_right = 1024
Expand Down
Binary file added godot/world/cursor/world-cursor.aseprite
Binary file not shown.
Binary file added godot/world/cursor/world-cursor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions godot/world/cursor/world-cursor.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://bxfiovujaysye"
path="res://.godot/imported/world-cursor.png-aa99e8044ff46818db60db9b3af5abce.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://world/cursor/world-cursor.png"
dest_files=["res://.godot/imported/world-cursor.png-aa99e8044ff46818db60db9b3af5abce.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
8 changes: 8 additions & 0 deletions godot/world/cursor/world_cursor.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
extends Node2D


@onready var animated_sprite_2d: AnimatedSprite2D = $AnimatedSprite2D


func _ready() -> void:
animated_sprite_2d.animation_finished.connect(queue_free)
117 changes: 117 additions & 0 deletions godot/world/cursor/world_cursor.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
[gd_scene load_steps=18 format=3 uid="uid://dlqkbdxsdixud"]

[ext_resource type="Texture2D" uid="uid://bxfiovujaysye" path="res://world/cursor/world-cursor.png" id="1_2ktcu"]
[ext_resource type="Script" path="res://world/cursor/world_cursor.gd" id="1_a2y76"]

[sub_resource type="AtlasTexture" id="AtlasTexture_n83yg"]
atlas = ExtResource("1_2ktcu")
region = Rect2(0, 0, 64, 64)

[sub_resource type="AtlasTexture" id="AtlasTexture_f8f2o"]
atlas = ExtResource("1_2ktcu")
region = Rect2(64, 0, 64, 64)

[sub_resource type="AtlasTexture" id="AtlasTexture_v8u72"]
atlas = ExtResource("1_2ktcu")
region = Rect2(128, 0, 64, 64)

[sub_resource type="AtlasTexture" id="AtlasTexture_ruvor"]
atlas = ExtResource("1_2ktcu")
region = Rect2(192, 0, 64, 64)

[sub_resource type="AtlasTexture" id="AtlasTexture_r48hf"]
atlas = ExtResource("1_2ktcu")
region = Rect2(256, 0, 64, 64)

[sub_resource type="AtlasTexture" id="AtlasTexture_5g4qb"]
atlas = ExtResource("1_2ktcu")
region = Rect2(320, 0, 64, 64)

[sub_resource type="AtlasTexture" id="AtlasTexture_lgs1e"]
atlas = ExtResource("1_2ktcu")
region = Rect2(384, 0, 64, 64)

[sub_resource type="AtlasTexture" id="AtlasTexture_3jmax"]
atlas = ExtResource("1_2ktcu")
region = Rect2(448, 0, 64, 64)

[sub_resource type="AtlasTexture" id="AtlasTexture_n1dah"]
atlas = ExtResource("1_2ktcu")
region = Rect2(512, 0, 64, 64)

[sub_resource type="AtlasTexture" id="AtlasTexture_eobxn"]
atlas = ExtResource("1_2ktcu")
region = Rect2(576, 0, 64, 64)

[sub_resource type="AtlasTexture" id="AtlasTexture_rurlk"]
atlas = ExtResource("1_2ktcu")
region = Rect2(640, 0, 64, 64)

[sub_resource type="AtlasTexture" id="AtlasTexture_jp5oe"]
atlas = ExtResource("1_2ktcu")
region = Rect2(704, 0, 64, 64)

[sub_resource type="AtlasTexture" id="AtlasTexture_6lvc5"]
atlas = ExtResource("1_2ktcu")
region = Rect2(768, 0, 64, 64)

[sub_resource type="AtlasTexture" id="AtlasTexture_5cl47"]
atlas = ExtResource("1_2ktcu")
region = Rect2(832, 0, 64, 64)

[sub_resource type="SpriteFrames" id="SpriteFrames_wtvpl"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_n83yg")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_f8f2o")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_v8u72")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ruvor")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_r48hf")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_5g4qb")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_lgs1e")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_3jmax")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_n1dah")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_eobxn")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_rurlk")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_jp5oe")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_6lvc5")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_5cl47")
}],
"loop": false,
"name": &"default",
"speed": 16.0
}]

[node name="WorldCursor" type="Node2D"]
script = ExtResource("1_a2y76")

[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
sprite_frames = SubResource("SpriteFrames_wtvpl")
autoplay = "default"
7 changes: 7 additions & 0 deletions godot/world/player/player.gd
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
extends CharacterBody2D


const WorldCursor = preload("res://world/cursor/world_cursor.tscn")


@export var ACCELERATION = 1550
@export var CHARGING_ACCELERATION = ACCELERATION * 2
@export var FRICTION = 770
Expand Down Expand Up @@ -33,6 +37,9 @@ func _unhandled_input(event):

func set_target_position(target_position:Vector2) -> void:
navigation_agent_2d.target_position = target_position
var cursor = WorldCursor.instantiate()
cursor.global_position = target_position
get_parent().add_child(cursor)


func _on_receptor_touched(receptor:Receptor) -> void:
Expand Down

0 comments on commit 8dd4df5

Please # to comment.