feature/enemies #28
38
godot/characters/enemies/WalkingEnemy.gd
Normal file
38
godot/characters/enemies/WalkingEnemy.gd
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
extends KinematicBody2D
|
||||||
|
|
||||||
|
|
||||||
|
signal player_touched
|
||||||
|
|
||||||
|
|
||||||
|
var velocity = Vector2()
|
||||||
|
export var direction = -1
|
||||||
|
export var detect_edges = true
|
||||||
|
export var speed = 25
|
||||||
|
export var gravity = 9.8
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
if direction == 1:
|
||||||
|
$AnimatedSprite.flip_h = true
|
||||||
|
$FloorChecker.position.x = $CollisionShape2D.shape.get_extents().x * direction
|
||||||
|
$FloorChecker.enabled = detect_edges
|
||||||
|
|
||||||
|
|
||||||
|
func _physics_process(_delta: float) -> void:
|
||||||
|
if is_on_wall() or not $FloorChecker.is_colliding() and is_on_floor() and $FloorChecker.enabled:
|
||||||
|
direction *= -1
|
||||||
|
$AnimatedSprite.flip_h = not $AnimatedSprite.flip_h
|
||||||
|
$FloorChecker.position.x = $CollisionShape2D.shape.get_extents().x * direction
|
||||||
|
|
||||||
|
velocity.y += gravity
|
||||||
|
velocity.x = speed * direction
|
||||||
|
velocity = move_and_slide(velocity, Vector2.UP)
|
||||||
|
|
||||||
|
for i in get_slide_count():
|
||||||
|
var collision = get_slide_collision(i)
|
||||||
|
if collision.collider.name == "Player":
|
||||||
|
emit_signal("player_touched")
|
||||||
|
|
||||||
|
|
||||||
|
func squash() -> void:
|
||||||
|
queue_free()
|
82
godot/characters/enemies/blightwing/Blightwing.gd
Normal file
82
godot/characters/enemies/blightwing/Blightwing.gd
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
extends KinematicBody2D
|
||||||
|
|
||||||
|
|
||||||
|
signal player_touched
|
||||||
|
|
||||||
|
|
||||||
|
export var direction = -1
|
||||||
|
export var speed = 50
|
||||||
|
export var follow_path = false
|
||||||
|
var target: Vector2 = Vector2(0, 0)
|
||||||
|
var target_id = 0
|
||||||
|
var start_position = Vector2()
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
start_position = position
|
||||||
|
if follow_path:
|
||||||
|
if $Path.get_child_count() == 0:
|
||||||
|
follow_path = false
|
||||||
|
else:
|
||||||
|
target = $Path.get_child(0).position
|
||||||
|
if direction == 1:
|
||||||
|
$AnimatedSprite.flip_h = true
|
||||||
|
|
||||||
|
|
||||||
|
func _physics_process(delta: float) -> void:
|
||||||
|
if $LeftWallChecker.is_colliding():
|
||||||
|
wall_checker_collided($LeftWallChecker)
|
||||||
|
elif $RightWallChecker.is_colliding():
|
||||||
|
wall_checker_collided($RightWallChecker)
|
||||||
|
|
||||||
|
if not follow_path:
|
||||||
|
var target_position = position
|
||||||
|
target_position.x *= 2 * direction
|
||||||
|
position = position.move_toward(target_position, round(speed * delta))
|
||||||
|
|
||||||
|
var velocity = get_velocity_towards_target(delta)
|
||||||
|
var collision = move_and_collide(velocity, true, true, true)
|
||||||
|
if collision and collision.collider.name != "Player":
|
||||||
|
var _collision = move_and_collide(velocity)
|
||||||
|
else:
|
||||||
|
var velocity = get_velocity_towards_target(delta)
|
||||||
|
|
||||||
|
var collision = move_and_collide(velocity, true, true, true)
|
||||||
|
if collision and collision.collider.name != "Player":
|
||||||
|
var _collision = move_and_collide(velocity)
|
||||||
|
else:
|
||||||
|
position = position.move_toward(start_position + target, round(speed * delta))
|
||||||
|
|
||||||
|
if position == start_position + target:
|
||||||
|
if $Path.get_child_count() - 1 == target_id:
|
||||||
|
target_id = -1
|
||||||
|
target = $Path.position
|
||||||
|
else:
|
||||||
|
target_id += 1
|
||||||
|
target = $Path.get_child(target_id).position
|
||||||
|
|
||||||
|
if start_position.x + target.x > position.x:
|
||||||
|
$AnimatedSprite.flip_h = true
|
||||||
|
elif start_position.x + target.x < position.x:
|
||||||
|
$AnimatedSprite.flip_h = false
|
||||||
|
|
||||||
|
|
||||||
|
func get_velocity_towards_target(delta: float) -> Vector2:
|
||||||
|
var velocity = Vector2(0, 0)
|
||||||
|
if start_position.x + target.x > position.x:
|
||||||
|
velocity.x = speed * delta
|
||||||
|
elif start_position.x + target.x < position.x:
|
||||||
|
velocity.x = -speed * delta
|
||||||
|
|
||||||
|
if start_position.y + target.y > position.y:
|
||||||
|
velocity.y = speed * delta
|
||||||
|
elif start_position.y + target.y < position.y:
|
||||||
|
velocity.y = -speed * delta
|
||||||
|
return velocity
|
||||||
|
|
||||||
|
|
||||||
|
func wall_checker_collided(wall_checker: RayCast2D) -> void:
|
||||||
|
if wall_checker.get_collider().name == "Player":
|
||||||
|
emit_signal("player_touched")
|
||||||
|
direction *= -1
|
||||||
|
$AnimatedSprite.flip_h = not $AnimatedSprite.flip_h
|
55
godot/characters/enemies/blightwing/Blightwing.tscn
Normal file
55
godot/characters/enemies/blightwing/Blightwing.tscn
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
[gd_scene load_steps=8 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://assets/characters/characters.png" type="Texture" id=1]
|
||||||
|
[ext_resource path="res://characters/enemies/blightwing/Blightwing.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=1]
|
||||||
|
atlas = ExtResource( 1 )
|
||||||
|
region = Rect2( 144, 48, 24, 24 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=2]
|
||||||
|
atlas = ExtResource( 1 )
|
||||||
|
region = Rect2( 168, 48, 24, 24 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=3]
|
||||||
|
atlas = ExtResource( 1 )
|
||||||
|
region = Rect2( 192, 48, 24, 24 )
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id=4]
|
||||||
|
animations = [ {
|
||||||
|
"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 2 ) ],
|
||||||
|
"loop": true,
|
||||||
|
"name": "fly",
|
||||||
|
"speed": 6.0
|
||||||
|
} ]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id=5]
|
||||||
|
extents = Vector2( 4.5, 5 )
|
||||||
|
|
||||||
|
[node name="Blightwing" type="KinematicBody2D" groups=["enemy", "rideable"]]
|
||||||
|
collision_layer = 8
|
||||||
|
collision_mask = 11
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||||
|
frames = SubResource( 4 )
|
||||||
|
animation = "fly"
|
||||||
|
frame = 3
|
||||||
|
playing = true
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
position = Vector2( 1.66894e-06, 1.5 )
|
||||||
|
rotation = 1.5708
|
||||||
|
shape = SubResource( 5 )
|
||||||
|
|
||||||
|
[node name="LeftWallChecker" type="RayCast2D" parent="."]
|
||||||
|
rotation = 1.5708
|
||||||
|
enabled = true
|
||||||
|
cast_to = Vector2( 0, 10 )
|
||||||
|
collision_mask = 11
|
||||||
|
|
||||||
|
[node name="RightWallChecker" type="RayCast2D" parent="."]
|
||||||
|
rotation = -1.5708
|
||||||
|
enabled = true
|
||||||
|
cast_to = Vector2( 0, 10 )
|
||||||
|
collision_mask = 11
|
27
godot/characters/enemies/blockface/Blockface.gd
Normal file
27
godot/characters/enemies/blockface/Blockface.gd
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
extends KinematicBody2D
|
||||||
|
|
||||||
|
|
||||||
|
signal player_touched
|
||||||
|
|
||||||
|
|
||||||
|
onready var start_position = position
|
||||||
|
var velocity = Vector2()
|
||||||
|
export var speed = 50.0
|
||||||
|
export var fall_speed = 75.0
|
||||||
|
var return_to_start: bool = false
|
||||||
|
|
||||||
|
|
||||||
|
func _physics_process(delta: float) -> void:
|
||||||
|
if return_to_start:
|
||||||
|
position = position.move_toward(start_position, speed * delta)
|
||||||
|
else:
|
||||||
|
var collision = move_and_collide(Vector2(0, (position.y + fall_speed) * delta))
|
||||||
|
if collision:
|
||||||
|
return_to_start = true
|
||||||
|
$AnimatedSprite.play("normal")
|
||||||
|
if collision.collider.name == "Player":
|
||||||
|
emit_signal("player_touched")
|
||||||
|
|
||||||
|
if position.y <= start_position.y:
|
||||||
|
return_to_start = false
|
||||||
|
$AnimatedSprite.play("angry")
|
40
godot/characters/enemies/blockface/Blockface.tscn
Normal file
40
godot/characters/enemies/blockface/Blockface.tscn
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
[gd_scene load_steps=7 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://assets/characters/characters.png" type="Texture" id=1]
|
||||||
|
[ext_resource path="res://characters/enemies/blockface/Blockface.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=1]
|
||||||
|
atlas = ExtResource( 1 )
|
||||||
|
region = Rect2( 96, 24, 24, 24 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=2]
|
||||||
|
atlas = ExtResource( 1 )
|
||||||
|
region = Rect2( 120, 24, 24, 24 )
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id=3]
|
||||||
|
animations = [ {
|
||||||
|
"frames": [ SubResource( 1 ) ],
|
||||||
|
"loop": true,
|
||||||
|
"name": "normal",
|
||||||
|
"speed": 5.0
|
||||||
|
}, {
|
||||||
|
"frames": [ SubResource( 2 ) ],
|
||||||
|
"loop": true,
|
||||||
|
"name": "angry",
|
||||||
|
"speed": 5.0
|
||||||
|
} ]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id=4]
|
||||||
|
extents = Vector2( 9, 9 )
|
||||||
|
|
||||||
|
[node name="Blockface" type="KinematicBody2D" groups=["enemy", "rideable"]]
|
||||||
|
collision_layer = 8
|
||||||
|
collision_mask = 11
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||||
|
frames = SubResource( 3 )
|
||||||
|
animation = "normal"
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
shape = SubResource( 4 )
|
1
godot/characters/enemies/dreadtooth/Dreadtooth.gd
Normal file
1
godot/characters/enemies/dreadtooth/Dreadtooth.gd
Normal file
@ -0,0 +1 @@
|
|||||||
|
extends "res://characters/enemies/WalkingEnemy.gd"
|
55
godot/characters/enemies/dreadtooth/Dreadtooth.tscn
Normal file
55
godot/characters/enemies/dreadtooth/Dreadtooth.tscn
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
[gd_scene load_steps=8 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://assets/characters/characters.png" type="Texture" id=1]
|
||||||
|
[ext_resource path="res://characters/enemies/dreadtooth/Dreadtooth.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=1]
|
||||||
|
atlas = ExtResource( 1 )
|
||||||
|
region = Rect2( 192, 24, 24, 24 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=2]
|
||||||
|
atlas = ExtResource( 1 )
|
||||||
|
region = Rect2( 144, 24, 24, 24 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=3]
|
||||||
|
atlas = ExtResource( 1 )
|
||||||
|
region = Rect2( 168, 24, 24, 24 )
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id=4]
|
||||||
|
animations = [ {
|
||||||
|
"frames": [ SubResource( 1 ) ],
|
||||||
|
"loop": true,
|
||||||
|
"name": "hide",
|
||||||
|
"speed": 5.0
|
||||||
|
}, {
|
||||||
|
"frames": [ SubResource( 2 ), SubResource( 3 ) ],
|
||||||
|
"loop": true,
|
||||||
|
"name": "walk",
|
||||||
|
"speed": 5.0
|
||||||
|
} ]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id=5]
|
||||||
|
extents = Vector2( 7.5, 6.5 )
|
||||||
|
|
||||||
|
[node name="Dreadtooth" type="KinematicBody2D" groups=["enemy"]]
|
||||||
|
collision_layer = 8
|
||||||
|
collision_mask = 11
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||||
|
frames = SubResource( 4 )
|
||||||
|
animation = "walk"
|
||||||
|
frame = 1
|
||||||
|
playing = true
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
position = Vector2( -0.5, 5.5 )
|
||||||
|
shape = SubResource( 5 )
|
||||||
|
|
||||||
|
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
|
||||||
|
polygon = PoolVector2Array( 0, -7, 3, -4, 3, -1, -4, -1, -4, -4, -1, -7 )
|
||||||
|
|
||||||
|
[node name="FloorChecker" type="RayCast2D" parent="."]
|
||||||
|
enabled = true
|
||||||
|
cast_to = Vector2( 0, 20 )
|
||||||
|
collision_mask = 10
|
35
godot/characters/enemies/gravevine/Gravevine.tscn
Normal file
35
godot/characters/enemies/gravevine/Gravevine.tscn
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
[gd_scene load_steps=6 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://assets/characters/characters.png" type="Texture" id=1]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=1]
|
||||||
|
atlas = ExtResource( 1 )
|
||||||
|
region = Rect2( 48, 24, 24, 24 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=2]
|
||||||
|
atlas = ExtResource( 1 )
|
||||||
|
region = Rect2( 72, 24, 24, 24 )
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id=3]
|
||||||
|
animations = [ {
|
||||||
|
"frames": [ SubResource( 1 ), SubResource( 2 ) ],
|
||||||
|
"loop": true,
|
||||||
|
"name": "default",
|
||||||
|
"speed": 5.0
|
||||||
|
} ]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id=4]
|
||||||
|
extents = Vector2( 5.5, 7.5 )
|
||||||
|
|
||||||
|
[node name="Gravevine" type="KinematicBody2D" groups=["enemy"]]
|
||||||
|
collision_layer = 8
|
||||||
|
collision_mask = 11
|
||||||
|
|
||||||
|
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||||
|
frames = SubResource( 3 )
|
||||||
|
frame = 1
|
||||||
|
playing = true
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
position = Vector2( -0.5, 0.5 )
|
||||||
|
shape = SubResource( 4 )
|
1
godot/characters/enemies/shelly/Shelly.gd
Normal file
1
godot/characters/enemies/shelly/Shelly.gd
Normal file
@ -0,0 +1 @@
|
|||||||
|
extends "res://characters/enemies/WalkingEnemy.gd"
|
51
godot/characters/enemies/shelly/Shelly.tscn
Normal file
51
godot/characters/enemies/shelly/Shelly.tscn
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
[gd_scene load_steps=8 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://assets/characters/characters.png" type="Texture" id=1]
|
||||||
|
[ext_resource path="res://characters/enemies/shelly/Shelly.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=1]
|
||||||
|
atlas = ExtResource( 1 )
|
||||||
|
region = Rect2( 48, 48, 24, 24 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=2]
|
||||||
|
atlas = ExtResource( 1 )
|
||||||
|
region = Rect2( 0, 48, 24, 24 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=3]
|
||||||
|
atlas = ExtResource( 1 )
|
||||||
|
region = Rect2( 24, 48, 24, 24 )
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id=4]
|
||||||
|
animations = [ {
|
||||||
|
"frames": [ SubResource( 1 ) ],
|
||||||
|
"loop": true,
|
||||||
|
"name": "hide",
|
||||||
|
"speed": 5.0
|
||||||
|
}, {
|
||||||
|
"frames": [ SubResource( 2 ), SubResource( 3 ) ],
|
||||||
|
"loop": true,
|
||||||
|
"name": "walk",
|
||||||
|
"speed": 3.0
|
||||||
|
} ]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id=5]
|
||||||
|
extents = Vector2( 7.5, 6.5 )
|
||||||
|
|
||||||
|
[node name="Shelly" type="KinematicBody2D" groups=["enemy", "squashable"]]
|
||||||
|
collision_layer = 8
|
||||||
|
collision_mask = 11
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||||
|
frames = SubResource( 4 )
|
||||||
|
animation = "walk"
|
||||||
|
playing = true
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
position = Vector2( 1, 5.5 )
|
||||||
|
shape = SubResource( 5 )
|
||||||
|
|
||||||
|
[node name="FloorChecker" type="RayCast2D" parent="."]
|
||||||
|
enabled = true
|
||||||
|
cast_to = Vector2( 0, 20 )
|
||||||
|
collision_mask = 10
|
28
godot/characters/enemies/spikeball/Spikeball.tscn
Normal file
28
godot/characters/enemies/spikeball/Spikeball.tscn
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
[gd_scene load_steps=5 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://assets/characters/characters.png" type="Texture" id=1]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=1]
|
||||||
|
atlas = ExtResource( 1 )
|
||||||
|
region = Rect2( 192, 0, 24, 24 )
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id=2]
|
||||||
|
animations = [ {
|
||||||
|
"frames": [ SubResource( 1 ) ],
|
||||||
|
"loop": true,
|
||||||
|
"name": "default",
|
||||||
|
"speed": 5.0
|
||||||
|
} ]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id=3]
|
||||||
|
radius = 9.05539
|
||||||
|
|
||||||
|
[node name="Spikeball" type="KinematicBody2D" groups=["enemy"]]
|
||||||
|
collision_layer = 8
|
||||||
|
collision_mask = 11
|
||||||
|
|
||||||
|
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||||
|
frames = SubResource( 2 )
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
shape = SubResource( 3 )
|
1
godot/characters/enemies/super_shelly/SuperShelly.gd
Normal file
1
godot/characters/enemies/super_shelly/SuperShelly.gd
Normal file
@ -0,0 +1 @@
|
|||||||
|
extends "res://characters/enemies/WalkingEnemy.gd"
|
52
godot/characters/enemies/super_shelly/SuperShelly.tscn
Normal file
52
godot/characters/enemies/super_shelly/SuperShelly.tscn
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
[gd_scene load_steps=8 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://assets/characters/characters.png" type="Texture" id=1]
|
||||||
|
[ext_resource path="res://characters/enemies/super_shelly/SuperShelly.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=1]
|
||||||
|
atlas = ExtResource( 1 )
|
||||||
|
region = Rect2( 120, 48, 24, 24 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=2]
|
||||||
|
atlas = ExtResource( 1 )
|
||||||
|
region = Rect2( 72, 48, 24, 24 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=3]
|
||||||
|
atlas = ExtResource( 1 )
|
||||||
|
region = Rect2( 96, 48, 24, 24 )
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id=4]
|
||||||
|
animations = [ {
|
||||||
|
"frames": [ SubResource( 1 ) ],
|
||||||
|
"loop": true,
|
||||||
|
"name": "hide",
|
||||||
|
"speed": 5.0
|
||||||
|
}, {
|
||||||
|
"frames": [ SubResource( 2 ), SubResource( 3 ) ],
|
||||||
|
"loop": true,
|
||||||
|
"name": "walk",
|
||||||
|
"speed": 3.0
|
||||||
|
} ]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id=5]
|
||||||
|
extents = Vector2( 12, 10.5 )
|
||||||
|
|
||||||
|
[node name="SuperShelly" type="KinematicBody2D" groups=["enemy", "squashable"]]
|
||||||
|
collision_layer = 8
|
||||||
|
collision_mask = 11
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||||
|
frames = SubResource( 4 )
|
||||||
|
animation = "walk"
|
||||||
|
frame = 1
|
||||||
|
playing = true
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
position = Vector2( 0, 1.5 )
|
||||||
|
shape = SubResource( 5 )
|
||||||
|
|
||||||
|
[node name="FloorChecker" type="RayCast2D" parent="."]
|
||||||
|
enabled = true
|
||||||
|
cast_to = Vector2( 0, 20 )
|
||||||
|
collision_mask = 10
|
@ -13,7 +13,7 @@
|
|||||||
extents = Vector2( 7, 12 )
|
extents = Vector2( 7, 12 )
|
||||||
|
|
||||||
[node name="Player" type="KinematicBody2D"]
|
[node name="Player" type="KinematicBody2D"]
|
||||||
collision_mask = 2
|
collision_mask = 10
|
||||||
script = ExtResource( 5 )
|
script = ExtResource( 5 )
|
||||||
|
|
||||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||||
@ -42,6 +42,12 @@ script = ExtResource( 6 )
|
|||||||
[node name="Fall" type="Node" parent="StateMachine"]
|
[node name="Fall" type="Node" parent="StateMachine"]
|
||||||
script = ExtResource( 7 )
|
script = ExtResource( 7 )
|
||||||
|
|
||||||
|
[node name="PlatformDetector" type="RayCast2D" parent="."]
|
||||||
|
position = Vector2( 12, 0 )
|
||||||
|
enabled = true
|
||||||
|
cast_to = Vector2( 0, 32 )
|
||||||
|
collision_mask = 24
|
||||||
|
|
||||||
[node name="Sounds" type="Node" parent="."]
|
[node name="Sounds" type="Node" parent="."]
|
||||||
|
|
||||||
[node name="Jump" type="AudioStreamPlayer" parent="Sounds"]
|
[node name="Jump" type="AudioStreamPlayer" parent="Sounds"]
|
||||||
|
40
godot/levels/PrototypeEnemies.tmx
Normal file
40
godot/levels/PrototypeEnemies.tmx
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<map version="1.8" tiledversion="1.8.6" orientation="orthogonal" renderorder="right-down" width="128" height="32" tilewidth="18" tileheight="18" infinite="0" nextlayerid="2" nextobjectid="1">
|
||||||
|
<tileset firstgid="1" source="../tilesets/tiles.tsx"/>
|
||||||
|
<layer id="1" name="Middleground" width="128" height="32">
|
||||||
|
<data encoding="csv">
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24
|
||||||
|
</data>
|
||||||
|
</layer>
|
||||||
|
</map>
|
24
godot/levels/PrototypeEnemies.tmx.import
Normal file
24
godot/levels/PrototypeEnemies.tmx.import
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="vnen.tiled_importer"
|
||||||
|
type="PackedScene"
|
||||||
|
path="res://.import/PrototypeEnemies.tmx-5728a1d35b5e3ba88a2df2406b1cd931.scn"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://levels/PrototypeEnemies.tmx"
|
||||||
|
dest_files=[ "res://.import/PrototypeEnemies.tmx-5728a1d35b5e3ba88a2df2406b1cd931.scn" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
custom_properties=true
|
||||||
|
tile_metadata=false
|
||||||
|
uv_clip=false
|
||||||
|
y_sort=false
|
||||||
|
image_flags=0
|
||||||
|
collision_layer=2
|
||||||
|
collision_mask=0
|
||||||
|
embed_internal_images=false
|
||||||
|
save_tiled_properties=false
|
||||||
|
add_background=true
|
||||||
|
post_import_script=""
|
98
godot/levels/PrototypeEnemies.tscn
Normal file
98
godot/levels/PrototypeEnemies.tscn
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
[gd_scene load_steps=12 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://CameraLimit.gdns" type="Script" id=1]
|
||||||
|
[ext_resource path="res://characters/player/Player.tscn" type="PackedScene" id=2]
|
||||||
|
[ext_resource path="res://levels/PrototypeEnemies.tmx" type="PackedScene" id=3]
|
||||||
|
[ext_resource path="res://assets/backgrounds/mountains.png" type="Texture" id=4]
|
||||||
|
[ext_resource path="res://characters/enemies/gravevine/Gravevine.tscn" type="PackedScene" id=5]
|
||||||
|
[ext_resource path="res://characters/enemies/dreadtooth/Dreadtooth.tscn" type="PackedScene" id=6]
|
||||||
|
[ext_resource path="res://characters/enemies/super_shelly/SuperShelly.tscn" type="PackedScene" id=7]
|
||||||
|
[ext_resource path="res://characters/enemies/spikeball/Spikeball.tscn" type="PackedScene" id=8]
|
||||||
|
[ext_resource path="res://characters/enemies/shelly/Shelly.tscn" type="PackedScene" id=9]
|
||||||
|
[ext_resource path="res://characters/enemies/blockface/Blockface.tscn" type="PackedScene" id=10]
|
||||||
|
[ext_resource path="res://characters/enemies/blightwing/Blightwing.tscn" type="PackedScene" id=11]
|
||||||
|
|
||||||
|
[node name="PrototypeEnemies" type="Node"]
|
||||||
|
|
||||||
|
[node name="Player" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 156, 438 )
|
||||||
|
collision/safe_margin = 0.12
|
||||||
|
|
||||||
|
[node name="Camera2D" type="Camera2D" parent="Player"]
|
||||||
|
current = true
|
||||||
|
limit_left = 0
|
||||||
|
limit_top = 0
|
||||||
|
limit_right = 512
|
||||||
|
limit_bottom = 288
|
||||||
|
drag_margin_h_enabled = true
|
||||||
|
drag_margin_v_enabled = true
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_bone_": true
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="VisibilityNotifier2D" type="VisibilityNotifier2D" parent="Player/Camera2D"]
|
||||||
|
rect = Rect2( 0, 0, 24, 24 )
|
||||||
|
|
||||||
|
[node name="ParallaxBackground" type="ParallaxBackground" parent="."]
|
||||||
|
|
||||||
|
[node name="ParallaxLayer" type="ParallaxLayer" parent="ParallaxBackground"]
|
||||||
|
motion_scale = Vector2( 0.2, 0.1 )
|
||||||
|
motion_offset = Vector2( 0, -288 )
|
||||||
|
motion_mirroring = Vector2( 528, 0 )
|
||||||
|
|
||||||
|
[node name="Sprite" type="Sprite" parent="ParallaxBackground/ParallaxLayer"]
|
||||||
|
texture = ExtResource( 4 )
|
||||||
|
centered = false
|
||||||
|
|
||||||
|
[node name="Map" type="Node" parent="."]
|
||||||
|
|
||||||
|
[node name="PrototypeEnemies" parent="Map" instance=ExtResource( 3 )]
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="Enemies" type="Node" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
|
||||||
|
[node name="Spikeball" parent="Enemies" instance=ExtResource( 8 )]
|
||||||
|
position = Vector2( 106, 547 )
|
||||||
|
|
||||||
|
[node name="Blightwing" parent="Enemies" instance=ExtResource( 11 )]
|
||||||
|
position = Vector2( 488, 400 )
|
||||||
|
follow_path = true
|
||||||
|
|
||||||
|
[node name="Path" type="Node2D" parent="Enemies/Blightwing"]
|
||||||
|
|
||||||
|
[node name="Node2D" type="Node2D" parent="Enemies/Blightwing/Path"]
|
||||||
|
position = Vector2( 0, 96 )
|
||||||
|
|
||||||
|
[node name="Node2D2" type="Node2D" parent="Enemies/Blightwing/Path"]
|
||||||
|
position = Vector2( -128, 96 )
|
||||||
|
|
||||||
|
[node name="Node2D3" type="Node2D" parent="Enemies/Blightwing/Path"]
|
||||||
|
position = Vector2( -128, 0 )
|
||||||
|
|
||||||
|
[node name="Blockface" parent="Enemies" instance=ExtResource( 10 )]
|
||||||
|
position = Vector2( 206, 404 )
|
||||||
|
|
||||||
|
[node name="Dreadtooth" parent="Enemies" instance=ExtResource( 6 )]
|
||||||
|
position = Vector2( 316, 379 )
|
||||||
|
|
||||||
|
[node name="Dreadtooth2" parent="Enemies" instance=ExtResource( 6 )]
|
||||||
|
position = Vector2( 350, 263 )
|
||||||
|
direction = 1
|
||||||
|
detect_edges = false
|
||||||
|
|
||||||
|
[node name="Gravevine" parent="Enemies" instance=ExtResource( 5 )]
|
||||||
|
position = Vector2( 250, 550 )
|
||||||
|
|
||||||
|
[node name="Shelly" parent="Enemies" instance=ExtResource( 9 )]
|
||||||
|
position = Vector2( 247, 439 )
|
||||||
|
|
||||||
|
[node name="SuperShelly" parent="Enemies" instance=ExtResource( 7 )]
|
||||||
|
position = Vector2( 62, 546 )
|
||||||
|
|
||||||
|
[connection signal="player_touched" from="Enemies/Blightwing" to="Player" method="_on_player_touched"]
|
||||||
|
[connection signal="player_touched" from="Enemies/Blockface" to="Player" method="_on_player_touched"]
|
||||||
|
[connection signal="player_touched" from="Enemies/Dreadtooth" to="Player" method="_on_player_touched"]
|
||||||
|
[connection signal="player_touched" from="Enemies/Dreadtooth2" to="Player" method="_on_player_touched"]
|
||||||
|
[connection signal="player_touched" from="Enemies/Shelly" to="Player" method="_on_player_touched"]
|
||||||
|
[connection signal="player_touched" from="Enemies/SuperShelly" to="Player" method="_on_player_touched"]
|
@ -100,6 +100,8 @@ Send={
|
|||||||
|
|
||||||
2d_physics/layer_1="Player"
|
2d_physics/layer_1="Player"
|
||||||
2d_physics/layer_2="Tiles"
|
2d_physics/layer_2="Tiles"
|
||||||
|
2d_physics/layer_4="Enemies"
|
||||||
|
2d_physics/layer_5="Platforms"
|
||||||
|
|
||||||
[physics]
|
[physics]
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
#include <SceneTree.hpp>
|
#include <SceneTree.hpp>
|
||||||
#include <Texture.hpp>
|
#include <Texture.hpp>
|
||||||
#include <Viewport.hpp>
|
#include <Viewport.hpp>
|
||||||
|
#include <RayCast2D.hpp>
|
||||||
|
#include <KinematicCollision2D.hpp>
|
||||||
|
|
||||||
using namespace godot;
|
using namespace godot;
|
||||||
using namespace player;
|
using namespace player;
|
||||||
@ -16,9 +18,11 @@ void Player::_register_methods()
|
|||||||
register_method("_physics_process", &Player::_physics_process);
|
register_method("_physics_process", &Player::_physics_process);
|
||||||
register_method("set_velocity", &Player::set_velocity);
|
register_method("set_velocity", &Player::set_velocity);
|
||||||
register_method("get_velocity", &Player::get_velocity);
|
register_method("get_velocity", &Player::get_velocity);
|
||||||
|
register_method("_on_player_touched", &Player::_on_player_touched);
|
||||||
//register_property<Player, Ref<SpriteFrames>>("sprite_frames", &Player::set_sprite_frames, &Player::get_sprite_frames, Ref<SpriteFrames>(), GODOT_METHOD_RPC_MODE_DISABLED, GODOT_PROPERTY_USAGE_DEFAULT, GODOT_PROPERTY_HINT_RESOURCE_TYPE, String("SpriteFrames"));
|
//register_property<Player, Ref<SpriteFrames>>("sprite_frames", &Player::set_sprite_frames, &Player::get_sprite_frames, Ref<SpriteFrames>(), GODOT_METHOD_RPC_MODE_DISABLED, GODOT_PROPERTY_USAGE_DEFAULT, GODOT_PROPERTY_HINT_RESOURCE_TYPE, String("SpriteFrames"));
|
||||||
register_property<Player, float>("speed", &Player::set_speed, &Player::get_speed, player::speed);
|
register_property<Player, float>("speed", &Player::set_speed, &Player::get_speed, player::speed);
|
||||||
register_property<Player, float>("jump_force", &Player::set_jump_force, &Player::get_jump_force, player::jump_force);
|
register_property<Player, float>("jump_force", &Player::set_jump_force, &Player::get_jump_force, player::jump_force);
|
||||||
|
register_property<Player, float>("bounce_force", &Player::set_bounce_force, &Player::get_bounce_force, player::bounce_force);
|
||||||
register_property<Player, float>("gravity", &Player::set_gravity, &Player::get_gravity, player::gravity);
|
register_property<Player, float>("gravity", &Player::set_gravity, &Player::get_gravity, player::gravity);
|
||||||
register_property<Player, float>("run_speed", &Player::set_run_speed, &Player::get_run_speed, player::run_speed);
|
register_property<Player, float>("run_speed", &Player::set_run_speed, &Player::get_run_speed, player::run_speed);
|
||||||
register_property<Player, bool>("double_jump", &Player::set_double_jump, &Player::get_double_jump, player::double_jump);
|
register_property<Player, bool>("double_jump", &Player::set_double_jump, &Player::get_double_jump, player::double_jump);
|
||||||
@ -42,6 +46,7 @@ void Player::_init()
|
|||||||
//sprite_frames = _resource_loader->load(player::sprite_frames);
|
//sprite_frames = _resource_loader->load(player::sprite_frames);
|
||||||
set_speed(player::speed);
|
set_speed(player::speed);
|
||||||
set_jump_force(player::jump_force);
|
set_jump_force(player::jump_force);
|
||||||
|
set_bounce_force(player::bounce_force);
|
||||||
set_gravity(player::gravity);
|
set_gravity(player::gravity);
|
||||||
set_run_speed(player::run_speed);
|
set_run_speed(player::run_speed);
|
||||||
set_double_jump(player::double_jump);
|
set_double_jump(player::double_jump);
|
||||||
@ -73,7 +78,7 @@ void Player::_ready()
|
|||||||
WARN_PRINT("Middleground not found!");
|
WARN_PRINT("Middleground not found!");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto object_node = get_tree()->get_root()->get_node("Main")->find_node("Monitor");
|
auto object_node = get_tree()->get_root()->get_node("Main")->find_node("Monitor", true);
|
||||||
if (object_node != nullptr)
|
if (object_node != nullptr)
|
||||||
{
|
{
|
||||||
auto state = get_node("StateMachine")->get_child(0);
|
auto state = get_node("StateMachine")->get_child(0);
|
||||||
@ -99,9 +104,54 @@ void Player::_physics_process(float delta)
|
|||||||
{
|
{
|
||||||
velocity.y += get_gravity();
|
velocity.y += get_gravity();
|
||||||
|
|
||||||
velocity = move_and_slide(velocity, Vector2::UP, true);
|
auto snap_vector = Vector2::ZERO;
|
||||||
|
if (!is_on_floor())
|
||||||
|
{
|
||||||
|
snap_vector = Vector2::DOWN * 20.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto platform_detector = get_node<RayCast2D>("PlatformDetector");
|
||||||
|
auto is_on_platform = platform_detector->is_colliding();
|
||||||
|
|
||||||
|
velocity = move_and_slide_with_snap(velocity, snap_vector, Vector2::UP, !is_on_platform, 4, 0.9, false);
|
||||||
|
//velocity = move_and_slide(velocity, Vector2::UP, !is_on_platform);
|
||||||
velocity.x = Math::lerp((float) velocity.x, (float) 0, (float) 0.2);
|
velocity.x = Math::lerp((float) velocity.x, (float) 0, (float) 0.2);
|
||||||
|
|
||||||
|
auto count = get_slide_count();
|
||||||
|
for (int64_t i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
auto collision = get_slide_collision(i);
|
||||||
|
auto collision_object = collision->get_collider();
|
||||||
|
auto collider = Object::cast_to<Node>(collision_object);
|
||||||
|
if (collider->is_in_group("squashable") && Vector2::UP.dot(collision->get_normal()) > 0.1)
|
||||||
|
{
|
||||||
|
collider->call_deferred("squash");
|
||||||
|
/*auto dup_node = collider->duplicate();
|
||||||
|
auto dup = Object::cast_to<KinematicBody2D>(dup_node);
|
||||||
|
auto dup_pos = dup->get_position();
|
||||||
|
dup_pos.x += 24;
|
||||||
|
dup->set_position(dup_pos);
|
||||||
|
auto enemies = get_tree()->get_root()->get_node("Main")->find_node("Enemies", true, false);
|
||||||
|
if (enemies != nullptr) {
|
||||||
|
enemies->add_child(dup);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WARN_PRINT("Enemies not found!");
|
||||||
|
dup->queue_free();
|
||||||
|
}*/
|
||||||
|
velocity.y = -get_bounce_force();
|
||||||
|
}
|
||||||
|
else if (collider->is_in_group("enemy") && (collider->is_in_group("rideable") && Vector2::DOWN.dot(collision->get_normal()) > 0))
|
||||||
|
{
|
||||||
|
_on_player_touched();
|
||||||
|
}
|
||||||
|
else if (collider->is_in_group("enemy") && !collider->is_in_group("rideable"))
|
||||||
|
{
|
||||||
|
_on_player_touched();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Clamp the player's position inside the camera's limits
|
// Clamp the player's position inside the camera's limits
|
||||||
auto camera = get_node<Camera2D>("Camera2D");
|
auto camera = get_node<Camera2D>("Camera2D");
|
||||||
auto position = get_global_position();
|
auto position = get_global_position();
|
||||||
@ -176,6 +226,16 @@ float Player::get_jump_force()
|
|||||||
return this->jump_force;
|
return this->jump_force;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::set_bounce_force(float bounce_force)
|
||||||
|
{
|
||||||
|
this->bounce_force = bounce_force;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Player::get_bounce_force()
|
||||||
|
{
|
||||||
|
return this->bounce_force;
|
||||||
|
}
|
||||||
|
|
||||||
void Player::set_gravity(float gravity)
|
void Player::set_gravity(float gravity)
|
||||||
{
|
{
|
||||||
this->gravity = gravity;
|
this->gravity = gravity;
|
||||||
@ -215,3 +275,12 @@ Vector2 Player::get_velocity()
|
|||||||
{
|
{
|
||||||
return this->velocity;
|
return this->velocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::_on_player_touched()
|
||||||
|
{
|
||||||
|
auto error = get_tree()->change_scene("res://Main.tscn");
|
||||||
|
if (error != Error::OK)
|
||||||
|
{
|
||||||
|
ERR_PRINT(String().num((int) error) + " Could not load scene!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -31,6 +31,11 @@ namespace godot
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const float jump_force = 300.0;
|
const float jump_force = 300.0;
|
||||||
|
/**
|
||||||
|
* @brief The default bounce force applied when bouncing on something.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
const float bounce_force = 200.0;
|
||||||
/**
|
/**
|
||||||
* @brief The default gravity applied to the player.
|
* @brief The default gravity applied to the player.
|
||||||
*
|
*
|
||||||
@ -93,6 +98,11 @@ namespace godot
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
float jump_force;
|
float jump_force;
|
||||||
|
/**
|
||||||
|
* @brief The force applied to the player when bouncing off something.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
float bounce_force;
|
||||||
/**
|
/**
|
||||||
* @brief The gravity applied to the player.
|
* @brief The gravity applied to the player.
|
||||||
*
|
*
|
||||||
@ -194,6 +204,20 @@ namespace godot
|
|||||||
*/
|
*/
|
||||||
float get_jump_force();
|
float get_jump_force();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the bounce force object.
|
||||||
|
*
|
||||||
|
* @param[in] bounce_force The new force applied to the player to make him bounce.
|
||||||
|
*/
|
||||||
|
void set_bounce_force(float bounce_force);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the bounce force object.
|
||||||
|
*
|
||||||
|
* @return float The current force being applied to the player.
|
||||||
|
*/
|
||||||
|
float get_bounce_force();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set the gravity object.
|
* @brief Set the gravity object.
|
||||||
*
|
*
|
||||||
@ -250,6 +274,12 @@ namespace godot
|
|||||||
* @return Vector2 Returns the velocity of the player.
|
* @return Vector2 Returns the velocity of the player.
|
||||||
*/
|
*/
|
||||||
Vector2 get_velocity();
|
Vector2 get_velocity();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function is called when an enemy touches the player.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void _on_player_touched();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user