Test sprite rotation, add overworld collisions

This commit is contained in:
2024-09-09 14:01:42 -07:00
parent 9cc88028dd
commit 3e0846223e
15 changed files with 499 additions and 7 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

@@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cnbdf5rnmss0c"
path.s3tc="res://.godot/imported/GameJam_DevilCapricorn_WalkBehind.png-d474259823f7e07d28e67fbeafea4ee9.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://src/npc/goddess/GameJam_DevilCapricorn_WalkBehind.png"
dest_files=["res://.godot/imported/GameJam_DevilCapricorn_WalkBehind.png-d474259823f7e07d28e67fbeafea4ee9.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dg22b8xckfhfx"
path.s3tc="res://.godot/imported/GameJam_DevilCapricorn_WalkForward.png-234fa02af8dbdd9edff550fcb77a7464.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://src/npc/goddess/GameJam_DevilCapricorn_WalkForward.png"
dest_files=["res://.godot/imported/GameJam_DevilCapricorn_WalkForward.png-234fa02af8dbdd9edff550fcb77a7464.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

@@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b7aj0ii438hho"
path.s3tc="res://.godot/imported/GameJam_DevilCapricorn_WalkSide.png-771c2b0d0af534bbb03d6b7aadea21c5.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://src/npc/goddess/GameJam_DevilCapricorn_WalkSide.png"
dest_files=["res://.godot/imported/GameJam_DevilCapricorn_WalkSide.png-771c2b0d0af534bbb03d6b7aadea21c5.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

@@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://xu8t0sly6ju7"
path.s3tc="res://.godot/imported/GameJam_DevilCapricorn_WalkSideLeft.png-01b9979d4d466cf12540b33bef3b5d16.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://src/npc/goddess/GameJam_DevilCapricorn_WalkSideLeft.png"
dest_files=["res://.godot/imported/GameJam_DevilCapricorn_WalkSideLeft.png-01b9979d4d466cf12540b33bef3b5d16.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

View File

@@ -0,0 +1,36 @@
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using GameJamDungeon;
using Godot;
using System;
[Meta(typeof(IAutoNode))]
public partial class Goddess : Node3D
{
public override void _Notification(int what) => this.Notify(what);
[Dependency]
public IGameRepo GameRepo => this.DependOn<IGameRepo>();
[Export]
public Godot.Collections.Array<Texture2D> Sprites { get; set; } = default!;
[Node] public Sprite3D Sprite { get; set; } = default!;
public void OnReady()
{
SetPhysicsProcess(true);
}
public override void _Process(double delta)
{
var cameraPosition = new Vector2(GameRepo.PlayerGlobalPosition.Value.X, GameRepo.PlayerGlobalPosition.Value.Z).Normalized();
var facing = Vector2.Up;
var angle = facing.AngleTo(cameraPosition);
var cameraAngle = (int)Mathf.Floor((angle + Mathf.Pi / 8) / (Mathf.Pi / 4));
cameraAngle = (cameraAngle + 4) % 4;
Sprite.Texture = Sprites[cameraAngle];
}
}

View File

@@ -0,0 +1,8 @@
[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://wqh1m4j0n64m"]
[ext_resource type="Shader" path="res://src/npc/goddess/SpriteMelt.gdshader" id="1_k3mvs"]
[resource]
shader = ExtResource("1_k3mvs")
shader_parameter/progress = 0.0
shader_parameter/meltiness = 1.0

View File

@@ -1,10 +1,18 @@
[gd_scene load_steps=2 format=3 uid="uid://d4l4qutp8x40c"] [gd_scene load_steps=7 format=3 uid="uid://d4l4qutp8x40c"]
[ext_resource type="Script" path="res://src/npc/goddess/Goddess.cs" id="1_4cyto"]
[ext_resource type="Texture2D" uid="uid://bhiyrdo2jk1qg" path="res://src/npc/goddess/goddess.png" id="1_uay1m"] [ext_resource type="Texture2D" uid="uid://bhiyrdo2jk1qg" path="res://src/npc/goddess/goddess.png" id="1_uay1m"]
[ext_resource type="Texture2D" uid="uid://cnbdf5rnmss0c" path="res://src/npc/goddess/GameJam_DevilCapricorn_WalkBehind.png" id="2_d6er1"]
[ext_resource type="Texture2D" uid="uid://dg22b8xckfhfx" path="res://src/npc/goddess/GameJam_DevilCapricorn_WalkForward.png" id="2_twumu"]
[ext_resource type="Texture2D" uid="uid://xu8t0sly6ju7" path="res://src/npc/goddess/GameJam_DevilCapricorn_WalkSideLeft.png" id="3_tds5k"]
[ext_resource type="Texture2D" uid="uid://b7aj0ii438hho" path="res://src/npc/goddess/GameJam_DevilCapricorn_WalkSide.png" id="4_6kg8t"]
[node name="Goddess" type="Node3D"] [node name="Goddess" type="Node3D"]
script = ExtResource("1_4cyto")
Sprites = Array[Texture2D]([ExtResource("2_d6er1"), ExtResource("3_tds5k"), ExtResource("2_twumu"), ExtResource("4_6kg8t")])
[node name="Sprite3D" type="Sprite3D" parent="."] [node name="Sprite" type="Sprite3D" parent="."]
unique_name_in_owner = true
transform = Transform3D(1.25, 0, 0, 0, 1.25, 0, 0, 0, 1.25, 0, 0, 0) transform = Transform3D(1.25, 0, 0, 0, 1.25, 0, 0, 0, 1.25, 0, 0, 0)
gi_mode = 0 gi_mode = 0
billboard = 2 billboard = 2

View File

@@ -0,0 +1,114 @@
shader_type spatial;
render_mode blend_mix,depth_draw_opaque,cull_back,diffuse_burley,specular_schlick_ggx,unshaded;
uniform vec4 albedo : source_color = vec4(1.0,1.0,1.0,1.0);
uniform sampler2D sprite_sheet : source_color;
/// the count of v_frames, used for the directions
uniform int directions_count = 1;
/// the count of h_frames, used for the animations
uniform int frames_count = 1;
/// the current h_frame
uniform int frame = 1;
/// the angle around vertical axis; the resulting direction looks to (cos y_angle, 0, -sin y_angle)
uniform float y_angle = 0.0;
/// this parameter below specifies which angle is the first frame pointed to.
/// example: if your character has the first frame turned toward north, the starting angle should be pi/2, if it looks to east it can be let to 0.0
uniform float starting_angle = 0.0;
/// this option specify if the direction changes along the vertical axis (default, false) or use the horizontal one instead (true)
uniform bool directions_on_horizontal_axis = false;
/// if you have drawn the sprite sheet so as to make the object rotate clockwise instead of counter-clockwise, set this parameter below true
uniform bool clockwise = false;
void vertex() {
MODELVIEW_MATRIX = VIEW_MATRIX * mat4(INV_VIEW_MATRIX[0],INV_VIEW_MATRIX[1],INV_VIEW_MATRIX[2],MODEL_MATRIX[3]);
}
void fragment() {
//euler angle around the vertical axis
float vert_axis_angle = atan(-VIEW_MATRIX[0][2]/VIEW_MATRIX[2][2]) + (VIEW_MATRIX[0][0] < 0.0?PI:0.0);
//difference
vert_axis_angle += y_angle - starting_angle;
//pinning
vert_axis_angle += PI / float(directions_count);
float direction = floor(vert_axis_angle * float(directions_count) / TAU);
if (clockwise) direction = 1.0 - direction;
float uv_y = direction / float(directions_count);
//texture UV
vec2 texture_uv = directions_on_horizontal_axis?
vec2(
(UV.x / float(directions_count)) + uv_y,
(UV.y + float(frame))/float(frames_count)
):
vec2(
(UV.x + float(frame))/float(frames_count),
(UV.y / float(directions_count)) + uv_y
);
vec4 albedo_tex = texture(sprite_sheet,texture_uv);
//albedo
ALBEDO = albedo.rgb * albedo_tex.rgb;
ALPHA = albedo.a * albedo_tex.a;
}
/************************ FOR GODOT 3 ***************************
shader_type spatial;
render_mode blend_mix,depth_draw_opaque,cull_back,diffuse_burley,specular_schlick_ggx,unshaded;
uniform vec4 albedo: hint_color = vec4(1.0,1.0,1.0,1.0);
uniform sampler2D sprite_sheet : hint_albedo;
/// the count of v_frames, used for the directions
uniform int directions_count = 1;
/// the count of h_frames, used for the animations
uniform int frames_count = 1;
/// the current h_frame
uniform int frame = 1;
/// the angle around vertical axis; the resulting direction looks to (cos y_angle, 0, -sin y_angle)
uniform float y_angle = 0.0;
/// this parameter below specifies which angle is the first frame pointed to.
/// example: if your character has the first frame turned toward north, the starting angle should be pi/2,
///if it looks to east it can be let to 0.0
uniform float starting_angle = 0.0;
/// this option specify if the direction changes along the vertical axis (default, false) or use the horizontal one instead (true)
uniform bool directions_on_horizontal_axis = false;
/// if you have drawn the sprite sheet so as to make the object rotate clockwise instead of counter-clockwise, set this parameter below true
uniform bool clockwise = false;
void vertex() {
MODELVIEW_MATRIX = INV_CAMERA_MATRIX * mat4(CAMERA_MATRIX[0],CAMERA_MATRIX[1],CAMERA_MATRIX[2],WORLD_MATRIX[3]);
}
void fragment() {
//euler angle around the vertical axis
float vert_axis_angle = atan(CAMERA_MATRIX[0][2]/CAMERA_MATRIX[0][0]) + (CAMERA_MATRIX[0][0] < 0.0?3.141593:0.0);
//difference
vert_axis_angle += y_angle - starting_angle;
//pinning
vert_axis_angle += 3.141593 / float(directions_count);
float direction = floor(vert_axis_angle * float(directions_count) / 6.283185);
if (clockwise) direction = 1.0 - direction;
float uv_y = direction / float(directions_count);
//texture UV
vec2 texture_uv = directions_on_horizontal_axis?
vec2(
(UV.x / float(directions_count)) + uv_y,
(UV.y + float(frame))/float(frames_count)
):
vec2(
(UV.x + float(frame))/float(frames_count),
(UV.y / float(directions_count)) + uv_y
);
vec4 albedo_tex = texture(sprite_sheet,texture_uv);
//albedo
ALBEDO = albedo.rgb * albedo_tex.rgb;
ALPHA = albedo.a * albedo_tex.a;
}
****************************************************************/

BIN
src/npc/testsprite.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View File

@@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dmh2hm1iy6i1x"
path.s3tc="res://.godot/imported/testsprite.png-70f2b03f832bdb736932806bcf06b54e.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://src/npc/testsprite.png"
dest_files=["res://.godot/imported/testsprite.png-70f2b03f832bdb736932806bcf06b54e.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0