Compare commits

...

5 Commits

13 changed files with 163 additions and 2 deletions

View File

@@ -0,0 +1,9 @@
shader_type canvas_item;
uniform vec4 base_color : source_color = vec4(1.0, 0.2, 0.2, 1.0); // tint color
void fragment() {
vec4 tex = texture(TEXTURE, UV);
COLOR = vec4(base_color.rgb * tex.r, tex.a);
}

View File

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

BIN
assets/sprites/slime_small grayscale.aseprite (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/sprites/slime_small grayscale.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ctob5me7woid8"
path="res://.godot/imported/slime_small grayscale.png-b5ea2536903e774dce2837ff19f6ad76.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/sprites/slime_small grayscale.png"
dest_files=["res://.godot/imported/slime_small grayscale.png-b5ea2536903e774dce2837ff19f6ad76.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
assets/sprites/slime_small.aseprite (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/sprites/slime_small.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bfj2h2jp1w60p"
path="res://.godot/imported/slime_small.png-a01d407ba84c2dd70ce8b2ef5c142cae.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/sprites/slime_small.png"
dest_files=["res://.godot/imported/slime_small.png-a01d407ba84c2dd70ce8b2ef5c142cae.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -17,6 +17,7 @@ extends CharacterBody2D
@onready var sprite_2d: Sprite2D = $Sprite2D
var player: Player
var enemy_name: String
var target: Node2D
var god_mode: bool = false
var is_dead: bool = false
@@ -27,6 +28,7 @@ var _path_update_timer: float = 0.0
func _ready() -> void:
health = max_health
enemy_name = _gen_name()
shape_cast_2d.shape.radius = collision_shape_2d.shape.radius
shape_cast_2d.enabled = false
sprite_2d.material = sprite_2d.material.duplicate()
@@ -38,6 +40,8 @@ func _find_player():
player = get_tree().get_first_node_in_group(GlobalConst.GROUP_PLAYER)
target = player
func _gen_name() -> String:
return "Unnamed enemy"
func _physics_process(delta: float) -> void:
if not target:

View File

@@ -0,0 +1,19 @@
class_name EnemySlimeSmall
extends EnemyBase
@export var color: Color = Color.CHARTREUSE
@onready var disabled_sprite: Sprite2D = $Sprite2D
@onready var base_sprite: Sprite2D = $Sprite/BaseSprite
var shader = preload("res://assets/shaders/base_color_tint.gdshader")
var shader_material: ShaderMaterial
func _ready() -> void:
shader_material = ShaderMaterial.new()
disabled_sprite.visible = false
set_color(color)
shader_material.shader = shader
base_sprite.material = shader_material
func set_color(new_color: Color) -> void:
shader_material.set_shader_parameter("base_color", new_color)

View File

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

View File

@@ -0,0 +1,41 @@
[gd_scene load_steps=9 format=3 uid="uid://cjikar11hbp3b"]
[ext_resource type="PackedScene" uid="uid://b7vq8xspnlyeu" path="res://scenes/enemies/enemy_base.tscn" id="1_o6v6p"]
[ext_resource type="Script" uid="uid://c5wgwy5itcnkk" path="res://scenes/enemies/enemy_slime_small.gd" id="2_2bnvq"]
[ext_resource type="Shader" uid="uid://cf48pgfl308o3" path="res://assets/shaders/base_color_tint.gdshader" id="3_2yvgl"]
[ext_resource type="Texture2D" uid="uid://ctob5me7woid8" path="res://assets/sprites/slime_small grayscale.png" id="3_iaao1"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_daihb"]
shader = ExtResource("3_2yvgl")
shader_parameter/base_color = Color(3.46541e-06, 0.969973, 0.260278, 1)
[sub_resource type="AtlasTexture" id="AtlasTexture_2yvgl"]
atlas = ExtResource("3_iaao1")
region = Rect2(0, 15, 16, 15)
[sub_resource type="AtlasTexture" id="AtlasTexture_daihb"]
atlas = ExtResource("3_iaao1")
region = Rect2(0, 30, 16, 15)
[sub_resource type="AtlasTexture" id="AtlasTexture_wu20c"]
atlas = ExtResource("3_iaao1")
region = Rect2(0, 45, 16, 15)
[node name="EnemySlimeSmall" instance=ExtResource("1_o6v6p")]
script = ExtResource("2_2bnvq")
color = Color(0.498039, 1, 0, 1)
[node name="Sprite" type="Node2D" parent="." index="0"]
[node name="BaseSprite" type="Sprite2D" parent="Sprite" index="0"]
material = SubResource("ShaderMaterial_daihb")
texture = SubResource("AtlasTexture_2yvgl")
[node name="Highlights" type="Sprite2D" parent="Sprite" index="1"]
texture = SubResource("AtlasTexture_daihb")
[node name="Shading" type="Sprite2D" parent="Sprite" index="2"]
texture = SubResource("AtlasTexture_wu20c")
[node name="Sprite2D" parent="." index="1"]
visible = false

View File

@@ -10,7 +10,8 @@ extends Node2D
const ENEMY_RAT = preload("res://scenes/enemies/enemy_rat.tscn")
const ENEMY_BAT = preload("res://scenes/enemies/enemy_bat.tscn")
const ENEMY_SLIME_SMALL = preload("res://scenes/enemies/enemy_slime_small.tscn")
const SLIME_COLOR_VARIATIONS: Array[Color]= [ Color.CHARTREUSE, Color.FUCHSIA, Color.DARK_ORANGE ]
func _ready() -> void:
timer.wait_time = 1 / spawn_rate
@@ -23,16 +24,21 @@ func _on_timer_timeout() -> void:
var enemies = get_tree().get_nodes_in_group(GlobalConst.GROUP_ENEMY)
GlobalConst.sig_debug_stats_set.emit("enemy_count", "%s" % len(enemies))
var next_enemy: PackedScene
match randi() % 2:
match randi() % 3:
0:
next_enemy = ENEMY_BAT
1:
next_enemy = ENEMY_RAT
2:
next_enemy = ENEMY_SLIME_SMALL
if len(enemies) < max_enemies:
var new_enemy = next_enemy.instantiate()
new_enemy.position = _get_spawn_pos()
new_enemy.target = target
if is_instance_of(new_enemy, EnemySlimeSmall):
var slime_color: Color = SLIME_COLOR_VARIATIONS.pick_random()
new_enemy.color = slime_color
add_child(new_enemy)