Compare commits
1 Commits
Projectile
...
5fe0a716ce
| Author | SHA1 | Date | |
|---|---|---|---|
| 5fe0a716ce |
BIN
block/Assets/GameplayArt/Black.png
Normal file
BIN
block/Assets/GameplayArt/Black.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
40
block/Assets/GameplayArt/Black.png.import
Normal file
40
block/Assets/GameplayArt/Black.png.import
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
[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
|
||||||
BIN
block/Assets/GameplayArt/PallateV1.png
Normal file
BIN
block/Assets/GameplayArt/PallateV1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 125 B |
40
block/Assets/GameplayArt/PallateV1.png.import
Normal file
40
block/Assets/GameplayArt/PallateV1.png.import
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
[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
|
||||||
BIN
block/Assets/GameplayArt/wizard_1.png
Normal file
BIN
block/Assets/GameplayArt/wizard_1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 79 KiB |
40
block/Assets/GameplayArt/wizard_1.png.import
Normal file
40
block/Assets/GameplayArt/wizard_1.png.import
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
[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
|
||||||
BIN
block/Assets/PlaceHolders/PlaceholderPallate.png
Normal file
BIN
block/Assets/PlaceHolders/PlaceholderPallate.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
40
block/Assets/PlaceHolders/PlaceholderPallate.png.import
Normal file
40
block/Assets/PlaceHolders/PlaceholderPallate.png.import
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
[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
|
||||||
24
block/Assets/Shaders/PosterizerTest.gdshader
Normal file
24
block/Assets/Shaders/PosterizerTest.gdshader
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
1
block/Assets/Shaders/PosterizerTest.gdshader.uid
Normal file
1
block/Assets/Shaders/PosterizerTest.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://sek5p4kfxpli
|
||||||
65
block/Assets/Shaders/ShaderTest.gdshader
Normal file
65
block/Assets/Shaders/ShaderTest.gdshader
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
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; // 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);
|
||||||
|
|
||||||
|
|
||||||
|
float best_dist = 10.0;
|
||||||
|
vec3 best_color = rgba.rgb;
|
||||||
|
///*
|
||||||
|
// 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);
|
||||||
|
//*/
|
||||||
|
|
||||||
|
//*
|
||||||
|
// Palette snapping logic
|
||||||
|
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.rgb, p_color);
|
||||||
|
|
||||||
|
if (dist < best_dist) {
|
||||||
|
best_dist = dist;
|
||||||
|
best_color = p_color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//*/
|
||||||
|
COLOR = vec4(best_color, 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);
|
||||||
|
*/
|
||||||
1
block/Assets/Shaders/ShaderTest.gdshader.uid
Normal file
1
block/Assets/Shaders/ShaderTest.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://dyr1qs8xwscgm
|
||||||
@@ -5,22 +5,45 @@ const speed = 200
|
|||||||
var direction = Vector2.RIGHT
|
var direction = Vector2.RIGHT
|
||||||
#var debug_normal: Vector2 = Vector2.ZERO
|
#var debug_normal: Vector2 = Vector2.ZERO
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
#direction = (player.global_position - global_position).normalized()
|
||||||
|
#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():
|
func get_facing_direction():
|
||||||
var direction_vector = Vector2.from_angle(rotation)
|
# Get the direction vector based on the node's current rotation
|
||||||
|
var direction_vector: Vector2 = Vector2.from_angle(rotation)
|
||||||
return direction_vector
|
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
|
||||||
rotation = direction.angle()
|
#direction = newDirection
|
||||||
|
#direction = direction.bounce(perp_line)
|
||||||
|
rotation = rad_to_deg(direction.angle())
|
||||||
|
print("direction:", direction)
|
||||||
|
|
||||||
# Debug function
|
func bounce(normal: Vector2):
|
||||||
func _draw():
|
direction = direction.bounce(normal)
|
||||||
# draw_line(Vector2(1,0) * 1000, debug_normal * 50, Color.RED, 2.0)
|
rotation = rad_to_deg(direction.angle())
|
||||||
pass
|
|
||||||
|
|||||||
37
block/Scenes/ShaderTest.tscn
Normal file
37
block/Scenes/ShaderTest.tscn
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
[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="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/PXwidth = 640.0
|
||||||
|
shader_parameter/PXheight = 360.0
|
||||||
|
|
||||||
|
[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="CanvasLayer" type="CanvasLayer" parent="." unique_id=298300130]
|
||||||
|
layer = 10
|
||||||
|
|
||||||
|
[node name="ColorRect" type="ColorRect" parent="CanvasLayer" unique_id=570744568]
|
||||||
|
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"]
|
||||||
@@ -13,7 +13,7 @@ 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
|
||||||
@@ -24,6 +24,9 @@ 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")
|
||||||
@export var Projectile: PackedScene
|
@export var Projectile: PackedScene
|
||||||
|
|
||||||
@@ -35,6 +38,8 @@ func _on_timer_timeout() -> void:
|
|||||||
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()
|
||||||
@@ -43,6 +48,10 @@ func chose(array):
|
|||||||
func wraparound():
|
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 _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
look_at(player.global_position)
|
look_at(player.global_position)
|
||||||
@@ -52,3 +61,29 @@ func _process(delta: float) -> void:
|
|||||||
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()
|
||||||
|
"""
|
||||||
|
|||||||
@@ -17,8 +17,7 @@ func _process(_delta: float) -> void:
|
|||||||
|
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|
||||||
look_at(get_global_mouse_position())
|
# look_at(get_global_mouse_position()) # uncompensated mouse control
|
||||||
|
|
||||||
#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) #+90 to makes top of image face mouse, not side
|
||||||
# rotation += angle_to_mouse# + deg_to_rad(90) #+90 to makes top of image face mouse, not side
|
|
||||||
|
|||||||
@@ -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://g0m835iol4mp" path="res://Assets/PlaceHolders/Screenshot 2024-11-24 210808.png" id="1_v0iea"]
|
[ext_resource type="Texture2D" uid="uid://dk7eufhisqp25" path="res://Assets/GameplayArt/wizard_1.png" id="2_vgqql"]
|
||||||
[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,8 +13,9 @@
|
|||||||
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.114894986, 0.11449075)
|
||||||
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]
|
||||||
scale = Vector2(4.2653956, 4.2653956)
|
scale = Vector2(4.2653956, 4.2653956)
|
||||||
|
|||||||
@@ -1,32 +1,45 @@
|
|||||||
extends Area2D
|
extends Area2D
|
||||||
|
|
||||||
var debug_normal: Vector2 = Vector2.ZERO
|
var debug_normal: Vector2 = Vector2.ZERO
|
||||||
|
var bounceTrajectory: Vector2
|
||||||
|
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# 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"):
|
||||||
print("Event: Projectile hit shield")
|
draw_line(Vector2(400,900), debug_normal * 50, Color.RED, 2.0) # normal
|
||||||
var shield_normal = global_transform.x.normalized()
|
|
||||||
print("Readout: Shield normal: ", Vec2str(shield_normal))
|
print("projectile has hit player shield")
|
||||||
# Gets the direction from the parent Node2D NOT the Area2d component
|
#gets the proper velocity
|
||||||
var projectile_velocity = area.get_parent().get_facing_direction()
|
var projectile_velocity = area.get_parent().get_facing_direction()
|
||||||
print("Readout: Projectile dir: ", Vec2str(projectile_velocity))
|
print("projectile speed......................", projectile_velocity)
|
||||||
var bounceTrajectory = projectile_velocity.bounce(shield_normal)
|
var shield_normal = global_transform.x.normalized()
|
||||||
print("Readout: Bounce dir: ", Vec2str(bounceTrajectory))
|
#var bounceTrajectory: Vector2 = projectile_velocity.bounce(shield_normal)
|
||||||
|
bounceTrajectory = projectile_velocity.bounce(shield_normal)
|
||||||
|
print("Shield Normal: ", shield_normal)
|
||||||
if area.get_parent().has_method("changeDirection"):
|
if area.get_parent().has_method("changeDirection"):
|
||||||
|
draw_line(bounceTrajectory, debug_normal * 50, Color.RED, 2.0)
|
||||||
|
# area.changeDirection(bounceTrajectory)
|
||||||
|
# area.get_parent().changeTrajectory(bounceTrajectory)
|
||||||
area.get_parent().changeDirection(bounceTrajectory)
|
area.get_parent().changeDirection(bounceTrajectory)
|
||||||
|
#if area.has_method("bounce"):
|
||||||
|
# area.bounce(bounceTrajectory)
|
||||||
|
|
||||||
# Debug functions
|
|
||||||
func _draw():
|
|
||||||
# draw_line(Vector2(1,0) * 1000, debug_normal * 50, Color.RED, 2.0) # normal
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Makes the string a bit easier to read in debug console
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func Vec2str(vec: Vector2) -> String:
|
#func _process(delta: float) -> void:
|
||||||
var x_sign = " " if vec.x >= 0 else ""
|
# pass
|
||||||
var y_sign = " " if vec.y >= 0 else ""
|
|
||||||
|
|
||||||
return "(%s%.2f, %s%.2f)" % [x_sign, vec.x, y_sign, vec.y]
|
|
||||||
|
|||||||
@@ -15,6 +15,14 @@ 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"
|
||||||
|
|||||||
Reference in New Issue
Block a user