Compare commits
3 Commits
5fe0a716ce
...
Visual-ove
| Author | SHA1 | Date | |
|---|---|---|---|
| cd4f527ab1 | |||
| 2c1c865e3d | |||
| 743899be33 |
57
TedsNotepad.txt
Normal file
57
TedsNotepad.txt
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
||||||
BIN
block/Assets/GameplayArt/Creature2Spritesheet.png
Normal file
BIN
block/Assets/GameplayArt/Creature2Spritesheet.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 247 KiB |
40
block/Assets/GameplayArt/Creature2Spritesheet.png.import
Normal file
40
block/Assets/GameplayArt/Creature2Spritesheet.png.import
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
[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
|
||||||
@@ -6,6 +6,7 @@ uniform sampler2D screen_texture : hint_screen_texture, filter_nearest;
|
|||||||
uniform float pixel_size = 256.0; // This now represents the "Height" resolution
|
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 color_levels : hint_range(2.0, 256.0) = 2.0;
|
||||||
|
|
||||||
|
|
||||||
uniform float PXwidth = 640;
|
uniform float PXwidth = 640;
|
||||||
uniform float PXheight = 360;
|
uniform float PXheight = 360;
|
||||||
|
|
||||||
|
|||||||
@@ -4,46 +4,67 @@ shader_type canvas_item;
|
|||||||
uniform sampler2D screen_texture : hint_screen_texture, filter_nearest;
|
uniform sampler2D screen_texture : hint_screen_texture, filter_nearest;
|
||||||
uniform sampler2D palette_texture : filter_nearest;
|
uniform sampler2D palette_texture : filter_nearest;
|
||||||
uniform int palette_size = 16;
|
uniform int palette_size = 16;
|
||||||
uniform float pixel_size = 256.0; // This now represents the "Height" resolution
|
uniform float pixel_size = 256.0;
|
||||||
uniform float color_levels : hint_range(2.0, 256.0) = 2.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 float PXwidth = 640;
|
uniform vec2 target_resolution = vec2(640.0, 360.0);
|
||||||
uniform float PXheight = 360;
|
|
||||||
|
|
||||||
void fragment() {
|
void fragment() {
|
||||||
float aspect_ratio = SCREEN_PIXEL_SIZE.y / SCREEN_PIXEL_SIZE.x;
|
vec2 uv = floor(SCREEN_UV * target_resolution) / target_resolution;
|
||||||
vec2 uv = SCREEN_UV;
|
vec2 v_pixel_size = 1.0 / target_resolution;
|
||||||
uv.x = round(uv.x * pixel_size * aspect_ratio) / (pixel_size * aspect_ratio);
|
vec2 offset = v_pixel_size * 0.5;
|
||||||
uv.y = round(uv.y * pixel_size) / pixel_size;
|
|
||||||
|
// 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));
|
||||||
|
|
||||||
// 3. Sample and Posterize
|
float min_brightness = min(b0, min(b1, min(b2, min(b3, b4))));
|
||||||
vec4 rgba = texture(screen_texture, uv);
|
|
||||||
|
|
||||||
|
vec3 final_rgb;
|
||||||
|
|
||||||
float best_dist = 10.0;
|
// 2. The "Outline Guard"
|
||||||
vec3 best_color = rgba.rgb;
|
// If ANY sampled pixel in this area is dark, force it to black immediately
|
||||||
///*
|
if (min_brightness < outline_sensitivity) {
|
||||||
// test posteriser instead of the for loop:
|
final_rgb = vec3(0.0, 0.0, 0.0);
|
||||||
float levels = 8.0; // Number of color steps per channel
|
} else {
|
||||||
rgba.rgb = floor(rgba.rgb * levels) / levels;
|
// 3. Normal Palette Snapping
|
||||||
COLOR = vec4(rgba.rgb, 1.0);
|
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++) {
|
||||||
// Palette snapping logic
|
float x_coord = (float(i) + 0.5) / float(palette_size);
|
||||||
for (int i = 0; i < palette_size; i++) {
|
vec3 p_color = texture(palette_texture, vec2(x_coord, 0.5)).rgb;
|
||||||
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);
|
||||||
|
|
||||||
float dist = distance(rgba.rgb, p_color);
|
/*
|
||||||
|
// Apply bias in the loop as a secondary safety measure
|
||||||
if (dist < best_dist) {
|
if (length(p_color) < 0.1) {
|
||||||
best_dist = dist;
|
dist *= black_bias;
|
||||||
best_color = p_color;
|
}
|
||||||
|
//*/
|
||||||
|
if (dist < best_dist) {
|
||||||
|
best_dist = dist;
|
||||||
|
best_color = p_color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
final_rgb = best_color;
|
||||||
}
|
}
|
||||||
//*/
|
|
||||||
COLOR = vec4(best_color, 1.0);
|
COLOR = vec4(final_rgb, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vertex() {
|
void vertex() {
|
||||||
|
|||||||
89
block/Scenes/Creature_2.tscn
Normal file
89
block/Scenes/Creature_2.tscn
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
[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")
|
||||||
88
block/Scenes/Creature_2.tscn8571099678.tmp
Normal file
88
block/Scenes/Creature_2.tscn8571099678.tmp
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
[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")
|
||||||
@@ -16,6 +16,7 @@ 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")
|
||||||
|
|
||||||
|
|||||||
@@ -1,49 +1,24 @@
|
|||||||
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 = (player.global_position - global_position).normalized()
|
# direction of the player
|
||||||
#look_at(player.global_position)
|
|
||||||
# pass
|
|
||||||
direction = (player.global_position - global_position).normalized()
|
direction = (player.global_position - global_position).normalized()
|
||||||
global_rotation=direction.angle()
|
global_rotation = direction.angle()
|
||||||
#direction= global_position.direction_to(player.global_position)
|
|
||||||
#direction = Vector2.RIGHT.rotated(rotation+ get_angle_to(playerDirection))
|
|
||||||
|
|
||||||
func _draw():
|
|
||||||
pass
|
|
||||||
# draw_line(Vector2(1,0) * 1000, debug_normal * 50, Color.RED, 2.0)
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
position += direction * speed * delta
|
position += direction * speed * delta
|
||||||
#position += playerDirection * speed * delta
|
|
||||||
look_at(player.global_position)
|
|
||||||
|
|
||||||
#look_at(direction)#
|
|
||||||
|
|
||||||
func get_facing_direction():
|
|
||||||
# Get the direction vector based on the node's current rotation
|
|
||||||
var direction_vector: Vector2 = Vector2.from_angle(rotation)
|
|
||||||
return direction_vector
|
|
||||||
|
|
||||||
func changeTrajectory(direction_vector: Vector2):
|
|
||||||
rotation = rad_to_deg(atan2(direction_vector.y, direction_vector.x))
|
|
||||||
|
|
||||||
func changeDirection(normal: Vector2):
|
func changeDirection(normal: Vector2):
|
||||||
print("direction:", direction)
|
|
||||||
# direction = direction.bounce(normal)
|
|
||||||
direction = normal
|
direction = normal
|
||||||
#direction = newDirection
|
rotation = direction.angle()
|
||||||
#direction = direction.bounce(perp_line)
|
|
||||||
rotation = rad_to_deg(direction.angle())
|
|
||||||
print("direction:", direction)
|
|
||||||
|
|
||||||
func bounce(normal: Vector2):
|
#debug functions
|
||||||
direction = direction.bounce(normal)
|
var debug_normal: Vector2 = Vector2.ZERO
|
||||||
rotation = rad_to_deg(direction.angle())
|
func _draw():
|
||||||
|
if isDebugLineOn:
|
||||||
|
draw_line(Vector2(1,0) * 1000, debug_normal * 50, Color.RED, 2.0)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://du7hapc7kscm6" path="res://Scenes/game.tscn" id="1_i0wgn"]
|
[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="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="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"]
|
[ext_resource type="Texture2D" uid="uid://b4xxaewt8vfbl" path="res://Assets/GameplayArt/PallateV1.png" id="4_vet50"]
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_exucn"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_exucn"]
|
||||||
@@ -11,8 +12,9 @@ shader_parameter/palette_texture = ExtResource("4_vet50")
|
|||||||
shader_parameter/palette_size = 16
|
shader_parameter/palette_size = 16
|
||||||
shader_parameter/pixel_size = 256.0
|
shader_parameter/pixel_size = 256.0
|
||||||
shader_parameter/color_levels = 8.0
|
shader_parameter/color_levels = 8.0
|
||||||
shader_parameter/PXwidth = 640.0
|
shader_parameter/black_bias = 0.6
|
||||||
shader_parameter/PXheight = 360.0
|
shader_parameter/outline_sensitivity = 0.25
|
||||||
|
shader_parameter/target_resolution = Vector2(640, 360)
|
||||||
|
|
||||||
[node name="ShaderTest" type="Node2D" unique_id=1126703629]
|
[node name="ShaderTest" type="Node2D" unique_id=1126703629]
|
||||||
|
|
||||||
@@ -21,10 +23,14 @@ shader_parameter/PXheight = 360.0
|
|||||||
[node name="Sprite2D" parent="Game/ArenaGameManager/MapArena/Parallax2D" parent_id_path=PackedInt32Array(850692785, 1024187604, 194007747, 598922861) index="0" unique_id=1318408175]
|
[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")
|
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]
|
[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=298300130]
|
||||||
layer = 10
|
layer = 10
|
||||||
|
|
||||||
[node name="ColorRect" type="ColorRect" parent="CanvasLayer" unique_id=570744568]
|
[node name="ColorRect" type="ColorRect" parent="CanvasLayer" unique_id=570744568]
|
||||||
|
texture_filter = 2
|
||||||
material = SubResource("ShaderMaterial_exucn")
|
material = SubResource("ShaderMaterial_exucn")
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
|
|||||||
@@ -13,33 +13,29 @@ enum States
|
|||||||
const max_distance = 750
|
const max_distance = 750
|
||||||
const SPEED = 300.0
|
const SPEED = 300.0
|
||||||
var is_enemy_chase: bool
|
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
|
||||||
# newProjectile.global_rotation=global_rotation
|
# newProjectile.global_rotation=global_rotation
|
||||||
get_tree().current_scene.add_child(newProjectile)
|
get_tree().current_scene.add_child(newProjectile)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func chose(array):
|
func chose(array):
|
||||||
array.shuffle()
|
array.shuffle()
|
||||||
@@ -49,41 +45,21 @@ 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()
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
if (global_position.x-player.global_position.x)>600:#player to the right
|
|
||||||
global_position.x=player.global_position.x-600#move right
|
|
||||||
elif(global_position.x-player.global_position.x)<-600:#player to the left
|
|
||||||
global_position.x=player.global_position.x+600#move left
|
|
||||||
|
|
||||||
if (global_position.y-player.global_position.y)>600:#player to the up
|
|
||||||
global_position.y=player.global_position.y-600#move up
|
|
||||||
elif(global_position.y-player.global_position.y)<-600:#player to the down
|
|
||||||
global_position.y=player.global_position.y+600#move down
|
|
||||||
"""
|
|
||||||
"""
|
|
||||||
func _physics_process(delta: float) -> void:
|
|
||||||
# Add the gravity.
|
|
||||||
if not is_on_floor():
|
|
||||||
velocity += get_gravity() * delta
|
|
||||||
# Get the input direction and handle the movement/deceleration.
|
|
||||||
# As good practice, you should replace UI actions with custom gameplay actions.
|
|
||||||
var direction := Input.get_axis("ui_left", "ui_right")
|
|
||||||
if direction:
|
|
||||||
velocity.x = direction * SPEED
|
|
||||||
else:
|
|
||||||
velocity.x = move_toward(velocity.x, 0, SPEED)
|
|
||||||
|
|
||||||
move_and_slide()
|
|
||||||
"""
|
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
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,7 +15,8 @@ func _process(_delta: float) -> void:
|
|||||||
|
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|
||||||
# look_at(get_global_mouse_position()) # uncompensated mouse control
|
look_at(get_global_mouse_position())
|
||||||
|
|
||||||
var angle_to_mouse = get_angle_to(get_global_mouse_position())
|
# mouse control no longer requires this 90 degree compensation
|
||||||
rotation += angle_to_mouse# + deg_to_rad(90) #+90 to makes top of image face mouse, not side
|
# var angle_to_mouse = get_angle_to(get_global_mouse_position())
|
||||||
|
# rotation += angle_to_mouse + deg_to_rad(90)
|
||||||
|
|||||||
@@ -14,11 +14,12 @@ 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
|
rotation = -1.5707964
|
||||||
scale = Vector2(0.114894986, 0.11449075)
|
scale = Vector2(0.115, 0.115)
|
||||||
texture = ExtResource("2_vgqql")
|
texture = ExtResource("2_vgqql")
|
||||||
|
|
||||||
[node name="BodyColision" type="CollisionShape2D" parent="." unique_id=1477808378]
|
[node name="BodyColision" type="CollisionShape2D" parent="." unique_id=1477808378]
|
||||||
scale = Vector2(4.2653956, 4.2653956)
|
visible = false
|
||||||
|
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]
|
||||||
@@ -27,6 +28,7 @@ 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")
|
||||||
@@ -37,6 +39,7 @@ 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")
|
||||||
|
|||||||
@@ -1,45 +1,36 @@
|
|||||||
extends Area2D
|
extends Area2D
|
||||||
|
|
||||||
var debug_normal: Vector2 = Vector2.ZERO
|
# Toggles debugger console output
|
||||||
var bounceTrajectory: Vector2
|
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)
|
||||||
print("READY!")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func _draw():
|
|
||||||
# pass
|
|
||||||
draw_line(bounceTrajectory *1000, debug_normal * 50, Color.RED, 2.0) # normal
|
|
||||||
# draw_line(Vector2(400,900), debug_normal * 50, Color.RED, 2.0) # normal
|
|
||||||
# draw_line(Vector2.ZERO, debug_bounce * 50, Color.GREEN, 2.0) # bounce direction
|
|
||||||
# draw_line(Vector2.ZERO, debug_incoming * 50, Color.BLUE, 2.0) # incoming projectile
|
|
||||||
|
|
||||||
|
|
||||||
func _on_area_entered(area):
|
func _on_area_entered(area):
|
||||||
if area.is_in_group("Projectiles"):
|
if area.is_in_group("Projectiles"):
|
||||||
draw_line(Vector2(400,900), debug_normal * 50, Color.RED, 2.0) # normal
|
# gets parent node because parent is what's moving, not the child area node
|
||||||
|
var parent = area.get_parent()
|
||||||
print("projectile has hit player shield")
|
readout("Event: Projectile has hit player shield")
|
||||||
#gets the proper velocity
|
var projectile_dir = Vector2.from_angle(parent.rotation)
|
||||||
var projectile_velocity = area.get_parent().get_facing_direction()
|
vec2Readout("Projectile Dir", projectile_dir)
|
||||||
print("projectile speed......................", projectile_velocity)
|
|
||||||
var shield_normal = global_transform.x.normalized()
|
var shield_normal = global_transform.x.normalized()
|
||||||
#var bounceTrajectory: Vector2 = projectile_velocity.bounce(shield_normal)
|
vec2Readout("Shield Normal: ", shield_normal)
|
||||||
bounceTrajectory = projectile_velocity.bounce(shield_normal)
|
if parent.has_method("changeDirection"):
|
||||||
print("Shield Normal: ", shield_normal)
|
var bounce_dir = projectile_dir.bounce(shield_normal)
|
||||||
if area.get_parent().has_method("changeDirection"):
|
parent.changeDirection(bounce_dir)
|
||||||
draw_line(bounceTrajectory, debug_normal * 50, Color.RED, 2.0)
|
|
||||||
# area.changeDirection(bounceTrajectory)
|
|
||||||
# area.get_parent().changeTrajectory(bounceTrajectory)
|
|
||||||
area.get_parent().changeDirection(bounceTrajectory)
|
|
||||||
#if area.has_method("bounce"):
|
|
||||||
# area.bounce(bounceTrajectory)
|
|
||||||
|
|
||||||
|
# makes debug output cleaner when printing Vector2
|
||||||
|
func vec2str(vec: Vector2) -> String:
|
||||||
|
var x_str = String.num(vec.x, 2)
|
||||||
|
var y_str = String.num(vec.y, 2)
|
||||||
|
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):
|
||||||
|
if isVerbose:
|
||||||
|
print("Readout: ", label, vec2str(vec))
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
func readout(str: String):
|
||||||
#func _process(delta: float) -> void:
|
if isVerbose:
|
||||||
# pass
|
print(str)
|
||||||
|
|||||||
56
todoList
56
todoList
@@ -2,12 +2,15 @@ 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 basic characters, and background
|
- Get sprites for and background
|
||||||
- collisions
|
- projectile damage
|
||||||
- projectiles
|
- enemy attack types
|
||||||
- attack types?
|
- enemy behaviors
|
||||||
Done
|
Done
|
||||||
- WASD movement
|
- WASD movement
|
||||||
|
- projectiles launching
|
||||||
|
- projectiles bouncing
|
||||||
|
- Get sprites for basic characters,
|
||||||
|
|
||||||
|
|
||||||
Current imported assests:
|
Current imported assests:
|
||||||
@@ -15,9 +18,6 @@ https://screamingbrainstudios.itch.io/tiny-texture-pack
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
x1*x2+y1*y2
|
|
||||||
|
|
||||||
along normal speedx*sp
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -27,45 +27,3 @@ 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)
|
|
||||||
Reference in New Issue
Block a user