develop #34

Merged
cromer merged 36 commits from develop into master 2022-08-28 01:13:46 -04:00
7 changed files with 68 additions and 56 deletions
Showing only changes of commit b24c9e8732 - Show all commits

51
godot/goal/Goal.tscn Normal file
View File

@ -0,0 +1,51 @@
[gd_scene load_steps=9 format=2]
[ext_resource path="res://assets/flag.png" type="Texture" id=1]
[ext_resource path="res://goal/GoalNotReached.gdns" type="Script" id=2]
[ext_resource path="res://goal/GoalReached.gdns" type="Script" id=3]
[ext_resource path="res://state_machine/StateMachine.gdns" type="Script" id=4]
[sub_resource type="RectangleShape2D" id=5]
extents = Vector2( 10, 18 )
[sub_resource type="AtlasTexture" id=6]
atlas = ExtResource( 1 )
region = Rect2( 0, 0, 18, 36 )
[sub_resource type="AtlasTexture" id=7]
atlas = ExtResource( 1 )
region = Rect2( 18, 0, 18, 36 )
[sub_resource type="SpriteFrames" id=8]
animations = [ {
"frames": [ SubResource( 6 ), SubResource( 7 ) ],
"loop": true,
"name": "flagmove",
"speed": 5.0
} ]
[node name="Goal" type="Area2D"]
position = Vector2( 324, 378 )
collision_layer = 32
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( 18, 18 )
shape = SubResource( 5 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
position = Vector2( 18, 18 )
frames = SubResource( 8 )
animation = "flagmove"
frame = 1
playing = true
[node name="StateMachine" type="Node" parent="."]
script = ExtResource( 4 )
[node name="GoalReached" type="Node" parent="StateMachine"]
script = ExtResource( 3 )
[node name="GoalNotReached" type="Node" parent="StateMachine"]
script = ExtResource( 2 )
[connection signal="body_entered" from="." to="StateMachine/GoalNotReached" method="_on_Goal_body_entered"]

View File

@ -0,0 +1,8 @@
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://gdnative/alai.tres" type="GDNativeLibrary" id=1]
[resource]
resource_name = "GoalReached"
class_name = "GoalReached"
library = ExtResource( 1 )

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=18 format=2]
[gd_scene load_steps=13 format=2]
[ext_resource path="res://CameraLimit.gdns" type="Script" id=1]
[ext_resource path="res://characters/player/Player.tscn" type="PackedScene" id=2]
@ -7,8 +7,7 @@
[ext_resource path="res://collectables/coin/Coin.tscn" type="PackedScene" id=5]
[ext_resource path="res://assets/coin.png" type="Texture" id=6]
[ext_resource path="res://hud/coin/Counter.gdns" type="Script" id=7]
[ext_resource path="res://assets/flag.png" type="Texture" id=8]
[ext_resource path="res://levels/GoalNotReached.gdns" type="Script" id=9]
[ext_resource path="res://goal/Goal.tscn" type="PackedScene" id=8]
[sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 0, 0, 0, 0.541176 )
@ -29,25 +28,6 @@ animations = [ {
"speed": 5.0
} ]
[sub_resource type="RectangleShape2D" id=5]
extents = Vector2( 10, 18 )
[sub_resource type="AtlasTexture" id=6]
atlas = ExtResource( 8 )
region = Rect2( 0, 0, 18, 36 )
[sub_resource type="AtlasTexture" id=7]
atlas = ExtResource( 8 )
region = Rect2( 18, 0, 18, 36 )
[sub_resource type="SpriteFrames" id=8]
animations = [ {
"frames": [ SubResource( 6 ), SubResource( 7 ) ],
"loop": true,
"name": "flagmove",
"speed": 5.0
} ]
[node name="Prototype" type="Node2D"]
[node name="Player" parent="." instance=ExtResource( 2 )]
@ -112,6 +92,7 @@ script = ExtResource( 7 )
position = Vector2( 162, 18 )
frames = SubResource( 4 )
animation = "spin"
frame = 1
playing = true
centered = false
@ -120,32 +101,9 @@ centered = false
[node name="coin" parent="Coins" instance=ExtResource( 5 )]
position = Vector2( 72, 450 )
[node name="AnimatedSprite" parent="Coins/coin" index="1"]
frame = 0
[node name="coin2" parent="Coins" instance=ExtResource( 5 )]
position = Vector2( 234, 450 )
[node name="Goal" type="Area2D" parent="."]
position = Vector2( 324, 378 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="Goal"]
position = Vector2( 18, 18 )
shape = SubResource( 5 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="Goal"]
position = Vector2( 18, 18 )
frames = SubResource( 8 )
animation = "flagmove"
playing = true
[node name="StateMachine" type="Node" parent="Goal"]
[node name="GoalReached" type="Node" parent="Goal/StateMachine"]
[node name="GoalNotReached" type="Node" parent="Goal/StateMachine"]
script = ExtResource( 9 )
[connection signal="body_entered" from="Goal" to="Goal/StateMachine/GoalNotReached" method="_on_Goal_body_entered"]
[node name="Goal" parent="." instance=ExtResource( 8 )]
[editable path="Coins/coin"]

View File

@ -96,6 +96,7 @@ right={
2d_physics/layer_1="Player"
2d_physics/layer_2="Tiles"
2d_physics/layer_3="Collectables"
2d_physics/layer_6="End Level"
[physics]

View File

@ -38,16 +38,9 @@ void GoalNotReached::_state_exit()
void GoalNotReached::_on_Goal_body_entered(Node *node)
{
Godot::print("Flag touched");
/* auto parent_node = get_parent();
if (parent_node != nullptr)
{
auto goal = Object::cast_to<Area2D>(parent_node);
goal->set_collision_mask_bit(0, false);
}
get_state_machine()->change("GoalReached");*/
get_state_machine()->change("GoalReached");
}

View File

@ -1,4 +1,5 @@
#include "goal/GoalReached.h"
#include <Area2D.hpp>
using namespace godot;
@ -6,7 +7,6 @@ void GoalReached::_register_methods()
{
register_method("_state_enter", &GoalReached::_state_enter);
register_method("_state_exit", &GoalReached::_state_exit);
//register_signal<GoalReached>("coin_collected", "amount", GODOT_VARIANT_TYPE_INT);
}
GoalReached::GoalReached()
@ -24,6 +24,7 @@ void GoalReached::_init()
void GoalReached::_state_enter()
{
Godot::print("Flag touched");
}