Skip to content

Commit

Permalink
main: add particleas when player is hit
Browse files Browse the repository at this point in the history
  • Loading branch information
fmorgner committed Aug 29, 2020
1 parent dd24300 commit 725a698
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
3 changes: 3 additions & 0 deletions godot/art/deathSparkle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions godot/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,5 @@ ui_down={

[rendering]

quality/filters/msaa=1
environment/default_environment="res://default_env.tres"
30 changes: 29 additions & 1 deletion godot/scenes/Main.tscn
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
[gd_scene load_steps=8 format=2]
[gd_scene load_steps=10 format=2]

[ext_resource path="res://bin/dodgetc_Main.gdns" type="Script" id=1]
[ext_resource path="res://scenes/Mob.tscn" type="PackedScene" id=2]
[ext_resource path="res://scenes/Player.tscn" type="PackedScene" id=3]
[ext_resource path="res://scenes/HUD.tscn" type="PackedScene" id=4]
[ext_resource path="res://art/House In a Forest Loop.ogg" type="AudioStream" id=5]
[ext_resource path="res://art/gameover.wav" type="AudioStream" id=6]
[ext_resource path="res://art/deathSparkle.png" type="Texture" id=7]

[sub_resource type="Curve2D" id=1]
_data = {
"points": PoolVector2Array( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 480, 0, 0, 0, 0, 0, 480, 720, 0, 0, 0, 0, 0, 720, 0, 0, 0, 0, 0, 0 )
}

[sub_resource type="ParticlesMaterial" id=2]
lifetime_randomness = 0.4
emission_shape = 1
emission_sphere_radius = 10.0
flag_disable_z = true
spread = 180.0
gravity = Vector3( 0, 0, 0 )
initial_velocity = 100.0
initial_velocity_random = 1.0
orbit_velocity = 0.0
orbit_velocity_random = 0.0
scale = 0.08
scale_random = 0.05
color = Color( 0.996078, 0.8, 0.27451, 1 )
hue_variation = 0.2
hue_variation_random = 0.75

[node name="Main" type="Node"]
script = ExtResource( 1 )
mob = ExtResource( 2 )
Expand Down Expand Up @@ -50,6 +68,16 @@ stream = ExtResource( 5 )

[node name="DeathSound" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 6 )

[node name="DeathParticles" type="Particles2D" parent="."]
visible = false
emitting = false
amount = 128
lifetime = 2.0
one_shot = true
explosiveness = 1.0
process_material = SubResource( 2 )
texture = ExtResource( 7 )
[connection signal="hit" from="Player" to="." method="on_player_hit"]
[connection signal="timeout" from="MobTimer" to="." method="on_mob_timer_timed_out"]
[connection signal="timeout" from="ScoreTimer" to="." method="on_score_timer_timed_out"]
Expand Down
10 changes: 10 additions & 0 deletions source/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <AudioStreamPlayer.hpp>
#include <Godot.hpp>
#include <Particles2D.hpp>
#include <PathFollow2D.hpp>
#include <Position2D.hpp>
#include <Ref.hpp>
Expand Down Expand Up @@ -40,6 +41,12 @@ namespace dodgetc
get_typed_node<godot::AudioStreamPlayer>("Music")->stop();
get_typed_node<godot::AudioStreamPlayer>("DeathSound")->play();

auto player = get_typed_node<Player>("Player");
auto death_particles = get_typed_node<godot::Particles2D>("DeathParticles");
death_particles->set_position(player->get_position());
death_particles->set_visible(true);
death_particles->set_emitting(true);

get_typed_node<HUD>("HUD")->show_game_over();

get_tree()->call_group("mobs", "queue_free");
Expand Down Expand Up @@ -78,6 +85,9 @@ namespace dodgetc
{
score = 0;

auto death_particles = get_typed_node<godot::Particles2D>("DeathParticles");
death_particles->set_visible(false);

auto player = get_typed_node<Player>("Player");
auto start_position = get_typed_node<godot::Position2D>("StartPosition");
player->start(start_position->get_position());
Expand Down

0 comments on commit 725a698

Please sign in to comment.