2 Commits

Author SHA1 Message Date
894f77e3cd Cleanup
Cleaning up the messy sections of my code and making the debug console output easier to read
2026-03-04 13:11:51 -08:00
bbda9768a2 Fixed projectile rotation
Fixed minor visual glitch where projectiles wouldn't be at the correct rotation after being deflected
2026-03-03 17:04:12 -08:00
26 changed files with 96 additions and 668 deletions

View File

@@ -1,57 +0,0 @@
x1*x2+y1*y2
along normal speedx*sp
var proje_normal = global_transform.x.normalized()
#proje_normal.y = -proje_normal.y
print("Proje Normal: ", proje_normal)
var speed_perp: float = proje_normal.dot(normal)
var perp_line: Vector2 = Vector2(normal.y,-normal.x)
var speed_para: float = proje_normal.dot(perp_line)
print("speed perp: ", speed_perp)
print("speed para: ", speed_para)
# this is just to check my math
# should be aproximately 1 (there will be some bit depth precision errors)
print("speed hype: ", speed_para*speed_para + speed_perp*speed_perp)
var newDirection: Vector2 = Vector2(
(speed_perp * normal.x) + (speed_para * normal.y),
(speed_perp * normal.y) + (speed_para *-normal.x))
var projectile_velocity = area.get_parent().get_facing_direction()
print("projectile speed......................", projectile_velocity)
var shield_normal = global_transform.x.normalized()
print("Shield Normal: ", shield_normal)
#shield_normal.y = -shield_normal.y
# if abs(projectile_velocity.y)>abs(projectile_velocity.x):
# shield_normal = global_transform.y.normalized()
#shield_normal.y = -shield_normal.y
#shield_normal.x = -shield_normal.x
# var shield_perp = Vector2(shield_normal.y,-shield_normal.x)
# if area.has_method("bounce"):
# if projectile_velocity.dot(shield_perp) < 0:
# area.bounce(shield_normal)
if area.has_method("bounce"):
#if projectile_velocity.dot(shield_normal) < 0:
area.bounce(shield_normal)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://djar02rjgqabs"
path="res://.godot/imported/Black.png-1613e05a6d554bb6d40131c1c2f5f072.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/GameplayArt/Black.png"
dest_files=["res://.godot/imported/Black.png-1613e05a6d554bb6d40131c1c2f5f072.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 247 KiB

View File

@@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c8c6fh1jtdd0i"
path="res://.godot/imported/Creature2Spritesheet.png-e2e0ef81f527506d5f444ce2e43b5c24.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/GameplayArt/Creature2Spritesheet.png"
dest_files=["res://.godot/imported/Creature2Spritesheet.png-e2e0ef81f527506d5f444ce2e43b5c24.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 B

View File

@@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b4xxaewt8vfbl"
path="res://.godot/imported/PallateV1.png-34e6e0012a0cedbe20615ffb3ccf5822.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/GameplayArt/PallateV1.png"
dest_files=["res://.godot/imported/PallateV1.png-34e6e0012a0cedbe20615ffb3ccf5822.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

View File

@@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dk7eufhisqp25"
path="res://.godot/imported/wizard_1.png-f69e6649a354bdd2df6db43b36f207c1.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/GameplayArt/wizard_1.png"
dest_files=["res://.godot/imported/wizard_1.png-f69e6649a354bdd2df6db43b36f207c1.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

View File

@@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b5gvrcwfqtubf"
path="res://.godot/imported/PlaceholderPallate.png-81deac43f0fca2626c9303de8fa9ae37.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/PlaceHolders/PlaceholderPallate.png"
dest_files=["res://.godot/imported/PlaceholderPallate.png-81deac43f0fca2626c9303de8fa9ae37.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

View File

@@ -1,25 +0,0 @@
shader_type canvas_item;
uniform sampler2D palette_texture : filter_nearest;
uniform int palette_size = 16;
uniform sampler2D screen_texture : hint_screen_texture, filter_nearest;
uniform float pixel_size = 256.0; // This now represents the "Height" resolution
uniform float color_levels : hint_range(2.0, 256.0) = 2.0;
uniform float PXwidth = 640;
uniform float PXheight = 360;
void fragment() {
float aspect_ratio = SCREEN_PIXEL_SIZE.y / SCREEN_PIXEL_SIZE.x;
vec2 uv = SCREEN_UV;
uv.x = round(uv.x * pixel_size * aspect_ratio) / (pixel_size * aspect_ratio);
uv.y = round(uv.y * pixel_size) / pixel_size;
// 3. Sample and Posterize
vec4 rgba = texture(screen_texture, uv);
vec3 crushed_color = floor(rgba.rgb * color_levels) / (color_levels - 1.0);
COLOR = vec4(crushed_color, rgba.a);
}

View File

@@ -1 +0,0 @@
uid://sek5p4kfxpli

View File

@@ -1,86 +0,0 @@
shader_type canvas_item;
// This grabs the screen texture automatically in Godot 4
uniform sampler2D screen_texture : hint_screen_texture, filter_nearest;
uniform sampler2D palette_texture : filter_nearest;
uniform int palette_size = 16;
uniform float pixel_size = 256.0;
uniform float color_levels : hint_range(2.0, 256.0) = 2.0;
uniform float black_bias : hint_range(0.0, 1.0) = 1.0; // Lower = stronger preference for black
uniform float outline_sensitivity : hint_range(0.0, 1.0) = 0.25; // Higher = grabs more grey
uniform vec2 target_resolution = vec2(640.0, 360.0);
void fragment() {
vec2 uv = floor(SCREEN_UV * target_resolution) / target_resolution;
vec2 v_pixel_size = 1.0 / target_resolution;
vec2 offset = v_pixel_size * 0.5;
// check center and 4 small offsets to see if black is nearby
vec3 col0 = texture(screen_texture, uv).rgb;
vec3 col1 = texture(screen_texture, uv + vec2(offset.x, 0.0)).rgb;
vec3 col2 = texture(screen_texture, uv - vec2(offset.x, 0.0)).rgb;
vec3 col3 = texture(screen_texture, uv + vec2(0.0, offset.y)).rgb;
vec3 col4 = texture(screen_texture, uv - vec2(0.0, offset.y)).rgb;
// Calculate the darkest brightness among the 5 samples
float b0 = dot(col0, vec3(0.299, 0.587, 0.114));
float b1 = dot(col1, vec3(0.299, 0.587, 0.114));
float b2 = dot(col2, vec3(0.299, 0.587, 0.114));
float b3 = dot(col3, vec3(0.299, 0.587, 0.114));
float b4 = dot(col4, vec3(0.299, 0.587, 0.114));
float min_brightness = min(b0, min(b1, min(b2, min(b3, b4))));
vec3 final_rgb;
// 2. The "Outline Guard"
// If ANY sampled pixel in this area is dark, force it to black immediately
if (min_brightness < outline_sensitivity) {
final_rgb = vec3(0.0, 0.0, 0.0);
} else {
// 3. Normal Palette Snapping
vec3 rgba = col0; // Use center sample for normal colors
float best_dist = 10.0;
vec3 best_color = rgba;
for (int i = 0; i < palette_size; i++) {
float x_coord = (float(i) + 0.5) / float(palette_size);
vec3 p_color = texture(palette_texture, vec2(x_coord, 0.5)).rgb;
float dist = distance(rgba, p_color);
/*
// Apply bias in the loop as a secondary safety measure
if (length(p_color) < 0.1) {
dist *= black_bias;
}
//*/
if (dist < best_dist) {
best_dist = dist;
best_color = p_color;
}
}
final_rgb = best_color;
}
COLOR = vec4(final_rgb, 1.0);
}
void vertex() {
// Called for every vertex the material is visible on.
}
//void light() {
// // Called for every pixel for every light affecting the CanvasItem.
// // Uncomment to replace the default light processing function with this one.
//}
/*
// test posteriser instead of the for loop:
float levels = 8.0; // Number of color steps per channel
rgba.rgb = floor(rgba.rgb * levels) / levels;
COLOR = vec4(rgba.rgb, 1.0);
*/

View File

@@ -1 +0,0 @@
uid://dyr1qs8xwscgm

View File

@@ -1,89 +0,0 @@
[gd_scene format=3 uid="uid://cja4ibeplpuvg"]
[ext_resource type="PackedScene" uid="uid://db1oeukux1376" path="res://Scenes/Enemy1.tscn" id="1_1lo65"]
[ext_resource type="Texture2D" uid="uid://c8c6fh1jtdd0i" path="res://Assets/GameplayArt/Creature2Spritesheet.png" id="2_wvt7r"]
[sub_resource type="AtlasTexture" id="AtlasTexture_uldxc"]
atlas = ExtResource("2_wvt7r")
region = Rect2(0, 0, 1002, 1002)
[sub_resource type="AtlasTexture" id="AtlasTexture_hm5n8"]
atlas = ExtResource("2_wvt7r")
region = Rect2(1002, 0, 1002, 1002)
[sub_resource type="SpriteFrames" id="SpriteFrames_r1616"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_uldxc")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_hm5n8")
}],
"loop": true,
"name": &"default",
"speed": 1.0
}]
[sub_resource type="CircleShape2D" id="CircleShape2D_sli80"]
radius = 18.0
[sub_resource type="Animation" id="Animation_uldxc"]
resource_name = "Wiggle"
length = 2.0
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 1),
"transitions": PackedFloat32Array(1, 1),
"update": 1,
"values": [0, 1]
}
[sub_resource type="Animation" id="Animation_wvt7r"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [0]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_hm5n8"]
_data = {
&"Idle": SubResource("Animation_uldxc"),
&"RESET": SubResource("Animation_wvt7r")
}
[node name="Enemy1" unique_id=1765361359 instance=ExtResource("1_1lo65")]
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." index="0" unique_id=769003556]
visible = false
rotation = -1.5707964
scale = Vector2(0.3, 0.3)
sprite_frames = SubResource("SpriteFrames_r1616")
frame = 1
frame_progress = 0.7216727
[node name="Sprite2D" parent="." index="1" unique_id=93765061]
position = Vector2(0, 0)
rotation = -1.5707964
texture = ExtResource("2_wvt7r")
hframes = 2
[node name="CollisionShape2D" parent="." index="2" unique_id=1856443411]
shape = SubResource("CircleShape2D_sli80")
[node name="AnimationPlayer" type="AnimationPlayer" parent="." index="4" unique_id=525993328]
libraries/ = SubResource("AnimationLibrary_hm5n8")

View File

@@ -1,88 +0,0 @@
[gd_scene format=3 uid="uid://cja4ibeplpuvg"]
[ext_resource type="PackedScene" uid="uid://db1oeukux1376" path="res://Scenes/Enemy1.tscn" id="1_1lo65"]
[ext_resource type="Texture2D" uid="uid://c8c6fh1jtdd0i" path="res://Assets/GameplayArt/Creature2Spritesheet.png" id="2_wvt7r"]
[sub_resource type="AtlasTexture" id="AtlasTexture_uldxc"]
atlas = ExtResource("2_wvt7r")
region = Rect2(0, 0, 1002, 1002)
[sub_resource type="AtlasTexture" id="AtlasTexture_hm5n8"]
atlas = ExtResource("2_wvt7r")
region = Rect2(1002, 0, 1002, 1002)
[sub_resource type="SpriteFrames" id="SpriteFrames_r1616"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_uldxc")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_hm5n8")
}],
"loop": true,
"name": &"default",
"speed": 1.0
}]
[sub_resource type="CircleShape2D" id="CircleShape2D_sli80"]
radius = 18.0
[sub_resource type="Animation" id="Animation_uldxc"]
resource_name = "Wiggle"
length = 2.0
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 1),
"transitions": PackedFloat32Array(1, 1),
"update": 1,
"values": [0, 1]
}
[sub_resource type="Animation" id="Animation_wvt7r"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [1]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_hm5n8"]
_data = {
&"Idle": SubResource("Animation_uldxc"),
&"RESET": SubResource("Animation_wvt7r")
}
[node name="Enemy1" unique_id=1765361359 instance=ExtResource("1_1lo65")]
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." index="0" unique_id=769003556]
visible = false
rotation = -1.5707964
scale = Vector2(0.3, 0.3)
sprite_frames = SubResource("SpriteFrames_r1616")
frame = 1
frame_progress = 0.7216727
[node name="Sprite2D" parent="." index="1" unique_id=93765061]
texture = ExtResource("2_wvt7r")
hframes = 2
frame = 1
[node name="CollisionShape2D" parent="." index="2" unique_id=1856443411]
shape = SubResource("CircleShape2D_sli80")
[node name="AnimationPlayer" type="AnimationPlayer" parent="." index="4" unique_id=525993328]
libraries/ = SubResource("AnimationLibrary_hm5n8")

View File

@@ -16,7 +16,6 @@ scale = Vector2(0.3, 0.3)
texture = ExtResource("1_g6sln") texture = ExtResource("1_g6sln")
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1856443411] [node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1856443411]
visible = false
scale = Vector2(6, 6) scale = Vector2(6, 6)
shape = SubResource("CapsuleShape2D_g6sln") shape = SubResource("CapsuleShape2D_g6sln")

View File

@@ -1,24 +1,26 @@
extends Node2D extends Node2D
const isDebugLineOn: bool = false
const speed = 200 const speed = 200
@onready var player: CharacterBody2D = get_tree().get_first_node_in_group("player") @onready var player: CharacterBody2D = get_tree().get_first_node_in_group("player")
var direction = Vector2.RIGHT var direction = Vector2.RIGHT
#var debug_normal: Vector2 = Vector2.ZERO
func _ready() -> void: func _ready() -> void:
# direction of the player
direction = (player.global_position - global_position).normalized() direction = (player.global_position - global_position).normalized()
global_rotation = direction.angle() global_rotation=direction.angle()
func _process(delta: float) -> void: func _process(delta: float) -> void:
position += direction * speed * delta position += direction * speed * delta
func get_facing_direction():
var direction_vector = Vector2.from_angle(rotation)
return direction_vector
func changeDirection(normal: Vector2): func changeDirection(normal: Vector2):
direction = normal direction = normal
rotation = direction.angle() rotation = direction.angle()
#debug functions # Debug function
var debug_normal: Vector2 = Vector2.ZERO
func _draw(): func _draw():
if isDebugLineOn: # draw_line(Vector2(1,0) * 1000, debug_normal * 50, Color.RED, 2.0)
draw_line(Vector2(1,0) * 1000, debug_normal * 50, Color.RED, 2.0) pass

View File

@@ -1,43 +0,0 @@
[gd_scene format=3 uid="uid://3xfnj6mipd2w"]
[ext_resource type="PackedScene" uid="uid://du7hapc7kscm6" path="res://Scenes/game.tscn" id="1_i0wgn"]
[ext_resource type="Shader" uid="uid://dyr1qs8xwscgm" path="res://Assets/Shaders/ShaderTest.gdshader" id="2_exucn"]
[ext_resource type="Texture2D" uid="uid://djar02rjgqabs" path="res://Assets/GameplayArt/Black.png" id="2_ipaa6"]
[ext_resource type="PackedScene" uid="uid://cja4ibeplpuvg" path="res://Scenes/Creature_2.tscn" id="3_meac5"]
[ext_resource type="Texture2D" uid="uid://b4xxaewt8vfbl" path="res://Assets/GameplayArt/PallateV1.png" id="4_vet50"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_exucn"]
shader = ExtResource("2_exucn")
shader_parameter/palette_texture = ExtResource("4_vet50")
shader_parameter/palette_size = 16
shader_parameter/pixel_size = 256.0
shader_parameter/color_levels = 8.0
shader_parameter/black_bias = 0.6
shader_parameter/outline_sensitivity = 0.25
shader_parameter/target_resolution = Vector2(640, 360)
[node name="ShaderTest" type="Node2D" unique_id=1126703629]
[node name="Game" parent="." unique_id=850692785 instance=ExtResource("1_i0wgn")]
[node name="Sprite2D" parent="Game/ArenaGameManager/MapArena/Parallax2D" parent_id_path=PackedInt32Array(850692785, 1024187604, 194007747, 598922861) index="0" unique_id=1318408175]
texture = ExtResource("2_ipaa6")
[node name="Enemy2" parent="Game" unique_id=1765361359 instance=ExtResource("3_meac5")]
position = Vector2(258, 363)
[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=298300130]
layer = 10
[node name="ColorRect" type="ColorRect" parent="CanvasLayer" unique_id=570744568]
texture_filter = 2
material = SubResource("ShaderMaterial_exucn")
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[editable path="Game"]
[editable path="Game/ArenaGameManager"]
[editable path="Game/ArenaGameManager/MapArena"]

View File

@@ -17,20 +17,19 @@ var is_enemy_chase: bool
var health = 100 var health = 100
var health_max = 100 var health_max = 100
var health_min = 0 var health_min = 0
var attack_dammage = 10 var attack_dammage = 10
var dir: Vector2 var dir: Vector2
var knockback = 200 var knockback = 200
var current_state = States.IDLE var current_state = States.IDLE
@onready var player: CharacterBody2D = get_tree().get_first_node_in_group("player") @onready var player: CharacterBody2D = get_tree().get_first_node_in_group("player")
@onready var _animation_player = $AnimationPlayer
@export var Projectile: PackedScene @export var Projectile: PackedScene
var anim_player
func _on_timer_timeout() -> void: func _on_timer_timeout() -> void:
$DirectionTimer.wait_time = chose([1,2,3]) $DirectionTimer.wait_time = chose([1,2,3])
if current_state != States.CHASE: if current_state !=States.CHASE:
dir = chose([Vector2.RIGHT, Vector2.LEFT]) dir = chose([Vector2.RIGHT, Vector2.LEFT])
var newProjectile = Projectile.instantiate() as Node2D var newProjectile = Projectile.instantiate() as Node2D
newProjectile.global_position=global_position newProjectile.global_position=global_position
@@ -45,21 +44,11 @@ func wraparound():
var direction = global_position.direction_to(player.global_position) var direction = global_position.direction_to(player.global_position)
global_position += direction * max_distance*2 global_position += direction * max_distance*2
func _ready() -> void:
if has_node("AnimationPlayer"):
anim_player = get_node_or_null("AnimationPlayer")
var list = anim_player.get_animation_list()
print(list) # Outputs something like ["idle", "walk", "default"]
func _process(delta: float) -> void: func _process(delta: float) -> void:
if has_node("AnimationPlayer"):
anim_player = get_node_or_null("AnimationPlayer")
if anim_player.has_animation("Idle"):
anim_player.play("Idle")
look_at(player.global_position) look_at(player.global_position)
#print(player.global_position)
var distance = global_position.distance_to(player.global_position) var distance = global_position.distance_to(player.global_position)
if distance > max_distance: if distance>max_distance:
wraparound() wraparound()

View File

@@ -1,8 +1,10 @@
extends CharacterBody2D extends CharacterBody2D
const SPEED = 300.0 const SPEED = 300.0
func _process(delta: float) -> void:
func _process(_delta: float) -> void:
var dirX := Input.get_axis("move_left", "move_right") var dirX := Input.get_axis("move_left", "move_right")
var dirY := Input.get_axis("move_up", "move_down") var dirY := Input.get_axis("move_up", "move_down")
@@ -17,6 +19,6 @@ func _process(delta: float) -> void:
look_at(get_global_mouse_position()) look_at(get_global_mouse_position())
# mouse control no longer requires this 90 degree compensation #OLD: used when player shield direction aigned 90 deg off from front
# var angle_to_mouse = get_angle_to(get_global_mouse_position()) # var angle_to_mouse = get_angle_to(get_global_mouse_position())
# rotation += angle_to_mouse + deg_to_rad(90) # rotation += angle_to_mouse# + deg_to_rad(90) #+90 to makes top of image face mouse, not side

View File

@@ -1,7 +1,7 @@
[gd_scene format=3 uid="uid://cjrgnm28xwju7"] [gd_scene format=3 uid="uid://cjrgnm28xwju7"]
[ext_resource type="Script" uid="uid://bah031ailk0ha" path="res://Scenes/player.gd" id="1_cvnsp"] [ext_resource type="Script" uid="uid://bah031ailk0ha" path="res://Scenes/player.gd" id="1_cvnsp"]
[ext_resource type="Texture2D" uid="uid://dk7eufhisqp25" path="res://Assets/GameplayArt/wizard_1.png" id="2_vgqql"] [ext_resource type="Texture2D" uid="uid://g0m835iol4mp" path="res://Assets/PlaceHolders/Screenshot 2024-11-24 210808.png" id="1_v0iea"]
[ext_resource type="Texture2D" uid="uid://bcmuqd6p3jhdw" path="res://Assets/PlaceHolders/Elmo.png" id="3_6t5aa"] [ext_resource type="Texture2D" uid="uid://bcmuqd6p3jhdw" path="res://Assets/PlaceHolders/Elmo.png" id="3_6t5aa"]
[ext_resource type="Script" uid="uid://b7vgyn15fioeu" path="res://Scenes/shield_hitbox.gd" id="4_vgqql"] [ext_resource type="Script" uid="uid://b7vgyn15fioeu" path="res://Scenes/shield_hitbox.gd" id="4_vgqql"]
@@ -13,13 +13,11 @@
script = ExtResource("1_cvnsp") script = ExtResource("1_cvnsp")
[node name="Body" type="Sprite2D" parent="." unique_id=719417979] [node name="Body" type="Sprite2D" parent="." unique_id=719417979]
rotation = -1.5707964 scale = Vector2(0.114894986, 0.11449075)
scale = Vector2(0.115, 0.115) texture = ExtResource("1_v0iea")
texture = ExtResource("2_vgqql")
[node name="BodyColision" type="CollisionShape2D" parent="." unique_id=1477808378] [node name="BodyColision" type="CollisionShape2D" parent="." unique_id=1477808378]
visible = false scale = Vector2(4.2653956, 4.2653956)
scale = Vector2(3.5, 3.5)
shape = SubResource("CircleShape2D_v0iea") shape = SubResource("CircleShape2D_v0iea")
[node name="Shield" type="Sprite2D" parent="." unique_id=212386399] [node name="Shield" type="Sprite2D" parent="." unique_id=212386399]
@@ -28,7 +26,6 @@ scale = Vector2(0.15, 0.15)
texture = ExtResource("3_6t5aa") texture = ExtResource("3_6t5aa")
[node name="ShieldColision" type="CollisionShape2D" parent="." unique_id=948717563] [node name="ShieldColision" type="CollisionShape2D" parent="." unique_id=948717563]
visible = false
position = Vector2(50, 0) position = Vector2(50, 0)
scale = Vector2(2.5, 6) scale = Vector2(2.5, 6)
shape = SubResource("RectangleShape2D_6t5aa") shape = SubResource("RectangleShape2D_6t5aa")
@@ -39,7 +36,6 @@ collision_mask = 2
script = ExtResource("4_vgqql") script = ExtResource("4_vgqql")
[node name="ShieldHitboxCol" type="CollisionShape2D" parent="ShieldHitbox" unique_id=1829894325] [node name="ShieldHitboxCol" type="CollisionShape2D" parent="ShieldHitbox" unique_id=1829894325]
visible = false
position = Vector2(50, 0) position = Vector2(50, 0)
scale = Vector2(2.5, 6) scale = Vector2(2.5, 6)
shape = SubResource("RectangleShape2D_6t5aa") shape = SubResource("RectangleShape2D_6t5aa")

View File

@@ -1,36 +1,32 @@
extends Area2D extends Area2D
# Toggles debugger console output var debug_normal: Vector2 = Vector2.ZERO
const isVerbose: bool = false
# Called when the node enters the scene tree for the first time.
func _ready() -> void: func _ready() -> void:
area_entered.connect(_on_area_entered) area_entered.connect(_on_area_entered)
func _on_area_entered(area): func _on_area_entered(area):
if area.is_in_group("Projectiles"): if area.is_in_group("Projectiles"):
# gets parent node because parent is what's moving, not the child area node print("Event: Projectile hit shield")
var parent = area.get_parent()
readout("Event: Projectile has hit player shield")
var projectile_dir = Vector2.from_angle(parent.rotation)
vec2Readout("Projectile Dir", projectile_dir)
var shield_normal = global_transform.x.normalized() var shield_normal = global_transform.x.normalized()
vec2Readout("Shield Normal: ", shield_normal) print("Readout: Shield normal: ", Vec2str(shield_normal))
if parent.has_method("changeDirection"): # Gets the direction from the parent Node2D NOT the Area2d component
var bounce_dir = projectile_dir.bounce(shield_normal) var projectile_velocity = area.get_parent().get_facing_direction()
parent.changeDirection(bounce_dir) print("Readout: Projectile dir: ", Vec2str(projectile_velocity))
var bounceTrajectory = projectile_velocity.bounce(shield_normal)
print("Readout: Bounce dir: ", Vec2str(bounceTrajectory))
if area.get_parent().has_method("changeDirection"):
area.get_parent().changeDirection(bounceTrajectory)
# makes debug output cleaner when printing Vector2 # Debug functions
func vec2str(vec: Vector2) -> String: func _draw():
var x_str = String.num(vec.x, 2) # draw_line(Vector2(1,0) * 1000, debug_normal * 50, Color.RED, 2.0) # normal
var y_str = String.num(vec.y, 2) pass
if not x_str.begins_with("-"): x_str = " " + x_str
if not y_str.begins_with("-"): y_str = " " + y_str
return "(%s, %s)" % [x_str, y_str]
func vec2Readout(label: String, vec: Vector2): # Makes the string a bit easier to read in debug console
if isVerbose: func Vec2str(vec: Vector2) -> String:
print("Readout: ", label, vec2str(vec)) var x_sign = " " if vec.x >= 0 else ""
var y_sign = " " if vec.y >= 0 else ""
func readout(str: String): return "(%s%.2f, %s%.2f)" % [x_sign, vec.x, y_sign, vec.y]
if isVerbose:
print(str)

View File

@@ -15,14 +15,6 @@ run/main_scene="uid://du7hapc7kscm6"
config/features=PackedStringArray("4.6", "Forward Plus") config/features=PackedStringArray("4.6", "Forward Plus")
config/icon="res://icon.svg" config/icon="res://icon.svg"
[display]
window/size/viewport_width=1920
window/size/viewport_height=1080
window/stretch/mode="canvas_items"
window/stretch/aspect="expand"
window/stretch/scale=2.0
[global_group] [global_group]
player="Making this for an easy reference to the player in the enemies code" player="Making this for an easy reference to the player in the enemies code"

View File

@@ -2,15 +2,12 @@ So that we can keep track of what things need to be done
Using godot version 4.6 Using godot version 4.6
- Get sprites for and background - Get sprites for basic characters, and background
- projectile damage - collisions
- enemy attack types - projectiles
- enemy behaviors - attack types?
Done Done
- WASD movement - WASD movement
- projectiles launching
- projectiles bouncing
- Get sprites for basic characters,
Current imported assests: Current imported assests:
@@ -18,6 +15,9 @@ https://screamingbrainstudios.itch.io/tiny-texture-pack
x1*x2+y1*y2
along normal speedx*sp
@@ -27,3 +27,45 @@ https://screamingbrainstudios.itch.io/tiny-texture-pack
var proje_normal = global_transform.x.normalized()
#proje_normal.y = -proje_normal.y
print("Proje Normal: ", proje_normal)
var speed_perp: float = proje_normal.dot(normal)
var perp_line: Vector2 = Vector2(normal.y,-normal.x)
var speed_para: float = proje_normal.dot(perp_line)
print("speed perp: ", speed_perp)
print("speed para: ", speed_para)
# this is just to check my math
# should be aproximately 1 (there will be some bit depth precision errors)
print("speed hype: ", speed_para*speed_para + speed_perp*speed_perp)
var newDirection: Vector2 = Vector2(
(speed_perp * normal.x) + (speed_para * normal.y),
(speed_perp * normal.y) + (speed_para *-normal.x))
var projectile_velocity = area.get_parent().get_facing_direction()
print("projectile speed......................", projectile_velocity)
var shield_normal = global_transform.x.normalized()
print("Shield Normal: ", shield_normal)
#shield_normal.y = -shield_normal.y
# if abs(projectile_velocity.y)>abs(projectile_velocity.x):
# shield_normal = global_transform.y.normalized()
#shield_normal.y = -shield_normal.y
#shield_normal.x = -shield_normal.x
# var shield_perp = Vector2(shield_normal.y,-shield_normal.x)
# if area.has_method("bounce"):
# if projectile_velocity.dot(shield_perp) < 0:
# area.bounce(shield_normal)
if area.has_method("bounce"):
#if projectile_velocity.dot(shield_normal) < 0:
area.bounce(shield_normal)