collisions, enemies, knockback, rolling

This commit is contained in:
mightypanders
2021-04-04 19:20:44 +02:00
parent 650a5a4a83
commit 01490a7f01
14 changed files with 1306 additions and 17 deletions

7
assets/Boxes/Hitbox.tscn Normal file
View File

@ -0,0 +1,7 @@
[gd_scene format=2]
[node name="Hitbox" type="Area2D"]
collision_layer = 0
collision_mask = 0
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]

View File

@ -0,0 +1,7 @@
[gd_scene format=2]
[node name="Hurtbox" type="Area2D"]
collision_layer = 0
collision_mask = 0
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]

View File

@ -0,0 +1,12 @@
extends Node2D
onready var animatedSprite = $AnimatedSprite
func _ready():
animatedSprite.frame = 0
animatedSprite.play("Animate")
pass # Replace with function body.
func _on_AnimatedSprite_animation_finished():
queue_free()
pass # Replace with function body.

View File

@ -0,0 +1,43 @@
[gd_scene load_steps=9 format=2]
[ext_resource path="res://assets/Effects/GrassEffect.png" type="Texture" id=1]
[ext_resource path="res://assets/Effects/GrassEffect.gd" type="Script" id=2]
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 1 )
region = Rect2( 0, 0, 32, 32 )
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 1 )
region = Rect2( 32, 0, 32, 32 )
[sub_resource type="AtlasTexture" id=3]
atlas = ExtResource( 1 )
region = Rect2( 64, 0, 32, 32 )
[sub_resource type="AtlasTexture" id=4]
atlas = ExtResource( 1 )
region = Rect2( 96, 0, 32, 32 )
[sub_resource type="AtlasTexture" id=5]
atlas = ExtResource( 1 )
region = Rect2( 128, 0, 32, 32 )
[sub_resource type="SpriteFrames" id=6]
animations = [ {
"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ) ],
"loop": false,
"name": "Animate",
"speed": 15.0
} ]
[node name="GrassEffect" type="Node2D"]
script = ExtResource( 2 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
frames = SubResource( 6 )
animation = "Animate"
frame = 4
centered = false
offset = Vector2( -8, -8 )
[connection signal="animation_finished" from="AnimatedSprite" to="." method="_on_AnimatedSprite_animation_finished"]

10
assets/Enemies/Bat.gd Normal file
View File

@ -0,0 +1,10 @@
extends KinematicBody2D
var knockback = Vector2.ZERO
func _physics_process(delta):
knockback = knockback.move_toward(Vector2.ZERO,200*delta)
knockback = move_and_slide(knockback)
func _on_Hurtbox_area_entered(area):
knockback = area.knockbackvector * 120

68
assets/Enemies/Bat.tscn Normal file
View File

@ -0,0 +1,68 @@
[gd_scene load_steps=13 format=2]
[ext_resource path="res://assets/Shadows/SmallShadow.png" type="Texture" id=1]
[ext_resource path="res://assets/Enemies/Bat.png" type="Texture" id=2]
[ext_resource path="res://assets/Boxes/Hurtbox.tscn" type="PackedScene" id=3]
[ext_resource path="res://assets/Enemies/Bat.gd" type="Script" id=4]
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 2 )
region = Rect2( 0, 0, 16, 24 )
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 2 )
region = Rect2( 16, 0, 16, 24 )
[sub_resource type="AtlasTexture" id=3]
atlas = ExtResource( 2 )
region = Rect2( 32, 0, 16, 24 )
[sub_resource type="AtlasTexture" id=4]
atlas = ExtResource( 2 )
region = Rect2( 48, 0, 16, 24 )
[sub_resource type="AtlasTexture" id=5]
atlas = ExtResource( 2 )
region = Rect2( 64, 0, 16, 24 )
[sub_resource type="SpriteFrames" id=6]
animations = [ {
"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ) ],
"loop": true,
"name": "default",
"speed": 10.0
} ]
[sub_resource type="CircleShape2D" id=7]
radius = 3.91596
[sub_resource type="CapsuleShape2D" id=8]
radius = 7.14859
height = 4.89034
[node name="Bat" type="KinematicBody2D"]
collision_layer = 16
script = ExtResource( 4 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
position = Vector2( -0.10413, -0.55414 )
frames = SubResource( 6 )
frame = 3
playing = true
offset = Vector2( 0, -12 )
[node name="Shadow" type="Sprite" parent="."]
texture = ExtResource( 1 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 7 )
[node name="Hurtbox" parent="." instance=ExtResource( 3 )]
collision_layer = 8
[node name="CollisionShape2D" parent="Hurtbox" index="0"]
position = Vector2( 0.10511, -14.9259 )
shape = SubResource( 8 )
[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
[editable path="Hurtbox"]

View File

@ -0,0 +1,3 @@
extends Area2D
var knockbackvector = Vector2.ZERO

10
assets/World/Grass.gd Normal file
View File

@ -0,0 +1,10 @@
extends Sprite
onready var GrassEffect = load("res://assets/Effects/GrassEffect.tscn")
func destroyGrass():
var grassEffect = GrassEffect.instance()
var world = get_tree().current_scene
world.add_child(grassEffect)
grassEffect.global_position = global_position
queue_free()
func _on_Hurtbox_area_entered(area):
destroyGrass()

27
assets/World/Grass.tscn Normal file
View File

@ -0,0 +1,27 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://assets/World/Grass.png" type="Texture" id=1]
[ext_resource path="res://assets/World/Grass.gd" type="Script" id=2]
[ext_resource path="res://assets/Boxes/Hurtbox.tscn" type="PackedScene" id=3]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 6.51773, 6.19977 )
[node name="Grass" type="Node2D"]
[node name="Grass" type="Sprite" parent="."]
position = Vector2( 0.0651245, 0.152679 )
texture = ExtResource( 1 )
centered = false
offset = Vector2( -8, -8 )
script = ExtResource( 2 )
[node name="Hurtbox" parent="." instance=ExtResource( 3 )]
collision_layer = 8
[node name="CollisionShape2D" parent="Hurtbox" index="0"]
position = Vector2( 7.94595, 7.94598 )
shape = SubResource( 1 )
[connection signal="area_entered" from="Hurtbox" to="Grass" method="_on_Hurtbox_area_entered"]
[editable path="Hurtbox"]