Skip to content
Snippets Groups Projects
Commit 42069947 authored by Jannik Rosendahl's avatar Jannik Rosendahl
Browse files

add black_white shader

adds a black and white shader to the player animated sprite. toggle with set_black_white(bool)
parent 1c2bf60a
No related branches found
No related tags found
No related merge requests found
...@@ -68,7 +68,10 @@ func _ready(): ...@@ -68,7 +68,10 @@ func _ready():
$Control/HealthBar.tint_progress = Color.green $Control/HealthBar.tint_progress = Color.green
$MeleeDetector.monitoring = false $MeleeDetector.monitoring = false
print("ready") print("ready")
set_black_white(false)
func _process(delta): func _process(delta):
if not is_alive: if not is_alive:
...@@ -245,7 +248,6 @@ func take_damage(n : int): ...@@ -245,7 +248,6 @@ func take_damage(n : int):
is_alive = false is_alive = false
update_animation() update_animation()
func take_damage_player(n : int): func take_damage_player(n : int):
take_damage(n) take_damage(n)
...@@ -281,7 +283,11 @@ func update_animation(): ...@@ -281,7 +283,11 @@ func update_animation():
$InfoLabel.text = "is_moving: " + str(is_moving) + "\nis_jumping: " + str(is_jumping) + "\nis_attacking: " + str(is_attacking) + "\nvh: " + str(velocity.x) + "\nvv" + str(velocity.y) + "\nhp: " + str(hitpoints) $InfoLabel.text = "is_moving: " + str(is_moving) + "\nis_jumping: " + str(is_jumping) + "\nis_attacking: " + str(is_attacking) + "\nvh: " + str(velocity.x) + "\nvv" + str(velocity.y) + "\nhp: " + str(hitpoints)
func set_black_white(boolean: bool):
if boolean:
$AnimatedSprite.material = load("res://src/actors/player/PlayerShader.tres")
else:
$AnimatedSprite.material = null
""" SECTION SIGNAL FUNCTIONS """ """ SECTION SIGNAL FUNCTIONS """
......
[gd_scene load_steps=55 format=2] [gd_scene load_steps=56 format=2]
[ext_resource path="res://src/assets/actors/Player/player_attack_melee.png" type="Texture" id=1] [ext_resource path="res://src/assets/actors/Player/player_attack_melee.png" type="Texture" id=1]
[ext_resource path="res://src/actors/player/Player.gd" type="Script" id=2] [ext_resource path="res://src/actors/player/Player.gd" type="Script" id=2]
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
[ext_resource path="res://src/assets/actors/Player/health-bar-under.png" type="Texture" id=9] [ext_resource path="res://src/assets/actors/Player/health-bar-under.png" type="Texture" id=9]
[ext_resource path="res://src/assets/actors/Player/health-bar-over.png" type="Texture" id=10] [ext_resource path="res://src/assets/actors/Player/health-bar-over.png" type="Texture" id=10]
[ext_resource path="res://src/assets/actors/Player/health_bar_health.png" type="Texture" id=11] [ext_resource path="res://src/assets/actors/Player/health_bar_health.png" type="Texture" id=11]
[ext_resource path="res://src/actors/player/PlayerShader.tres" type="Material" id=12]
[sub_resource type="AtlasTexture" id=1] [sub_resource type="AtlasTexture" id=1]
flags = 4 flags = 4
...@@ -259,10 +260,11 @@ collision/safe_margin = 0.01 ...@@ -259,10 +260,11 @@ collision/safe_margin = 0.01
script = ExtResource( 2 ) script = ExtResource( 2 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."] [node name="AnimatedSprite" type="AnimatedSprite" parent="."]
material = ExtResource( 12 )
position = Vector2( 10, -24 ) position = Vector2( 10, -24 )
frames = SubResource( 38 ) frames = SubResource( 38 )
animation = "melee" animation = "melee"
frame = 7 frame = 5
playing = true playing = true
[node name="Camera2D" type="Camera2D" parent="."] [node name="Camera2D" type="Camera2D" parent="."]
......
[gd_resource type="ShaderMaterial" load_steps=2 format=2]
[sub_resource type="Shader" id=52]
code = "shader_type canvas_item;
render_mode unshaded;
void fragment() {
COLOR = texture(TEXTURE, UV);
float lumi = (COLOR.r + COLOR.g + COLOR.b) / 3f;
COLOR.rgb = vec3(lumi);
}"
[resource]
shader = SubResource( 52 )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment