Added simple spikes, improved the flying cutters code

This commit is contained in:
Jakob Feldmann 2022-07-12 00:18:28 +02:00
parent 5acddf6a46
commit f8aed2f056
10 changed files with 129 additions and 53 deletions

Binary file not shown.

View File

@ -0,0 +1,26 @@
[remap]
importer="aseprite.wizard.plugin"
type="SpriteFrames"
path="res://.import/spikesiguess.aseprite-49a6562634d2194b332527973f528b29.res"
[deps]
source_file="res://assets/obstacle object/spikesiguess.aseprite"
dest_files=[ "res://.import/spikesiguess.aseprite-49a6562634d2194b332527973f528b29.res" ]
[params]
split_layers=false
exclude_layers_pattern=""
only_visible_layers=false
sheet_type="Packed"
sprite_filename_pattern="{basename}.{layer}.{extension}"
texture_strip/import_texture_strip=false
texture_strip/filename_pattern="{basename}.{layer}.Strip.{extension}"
texture_atlas/import_texture_atlas=false
texture_atlas/filename_pattern="{basename}.{layer}.Atlas.{extension}"
texture_atlas/frame_filename_pattern="{basename}.{layer}.{animation}.{frame}.Atlas.{extension}"
animated_texture/import_animated_texture=false
animated_texture/filename_pattern="{basename}.{layer}.{animation}.Texture.{extension}"
animated_texture/frame_filename_pattern="{basename}.{layer}.{animation}.{frame}.Texture.{extension}"

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/spikesiguess.png-dfee592274c493a519dd900ed55b2b35.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/obstacle object/spikesiguess.png"
dest_files=[ "res://.import/spikesiguess.png-dfee592274c493a519dd900ed55b2b35.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=false
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

View File

@ -235,7 +235,7 @@ func calculate_wallslide_velocity(
else: else:
# TODO dont put constants in here # TODO dont put constants in here
linear_velocity.y = PhysicsFunc.two_step_euler( linear_velocity.y = PhysicsFunc.two_step_euler(
linear_velocity.y*0.88, _gravity * mass, mass, delta linear_velocity.y*0.94, _gravity * mass, mass, delta
) )
air_strafe_charges = 1 air_strafe_charges = 1
return linear_velocity return linear_velocity
@ -268,7 +268,7 @@ func calculate_stomp_velocity(
func execute_movement() -> void: func execute_movement() -> void:
velocity = move_and_slide(velocity, FLOOR_NORMAL) velocity = move_and_slide(velocity, FLOOR_NORMAL,false, 4, 0.785398,false)
func die() -> void: func die() -> void:

View File

@ -3,7 +3,7 @@ const PhysicsFunc = preload("res://src/Utilities/Physic/PhysicsFunc.gd")
#Array of RayCast2D #Array of RayCast2D
onready var trigger_rays = $FlyingLaserCutterBody/Triggers.get_children() onready var trigger_rays = $FlyingLaserCutterBody/Triggers.get_children()
onready var tween = $FlyingLaserCutterBody/Tween onready var body = $FlyingLaserCutterBody
onready var local_facing: Vector2 = Vector2.RIGHT onready var local_facing: Vector2 = Vector2.RIGHT
onready var global_facing: Vector2 = local_facing.rotated(transform.get_rotation()) onready var global_facing: Vector2 = local_facing.rotated(transform.get_rotation())
onready var slide_friction = 1.5 onready var slide_friction = 1.5
@ -27,30 +27,19 @@ func _physics_process(delta: float) -> void:
if ray.is_colliding(): if ray.is_colliding():
var collider = ray.get_collider() var collider = ray.get_collider()
if collider.is_in_group("player"): if collider.is_in_group("player"):
tween.stop($FlyingLaserCutterBody)
set("motion/sync_to_physics", false)
flyoff_triggered = true flyoff_triggered = true
body.set("motion/sync_to_physics", false)
break break
if body.position.x > 0:
velocity=1
body.position.x += (max_velocity/3)*-1*delta
else: else:
velocity = PhysicsFunc.two_step_euler( velocity = PhysicsFunc.two_step_euler(
velocity, acceleration_force, mass, delta velocity, acceleration_force, mass, delta
) )
velocity = clamp(velocity, 0, max_velocity) velocity = clamp(velocity, 0, max_velocity)
var collision = $FlyingLaserCutterBody.move_and_collide(velocity*global_facing*delta,true) var collision = body.move_and_collide(velocity*global_facing*delta,true)
if collision != null: if collision != null:
if !collision.collider.is_in_group("player"): if !collision.collider.is_in_group("player"):
_on_collision() body.set("motion/sync_to_physics", true)
flyoff_triggered = false
func _on_collision() -> void:
velocity = 1
flyoff_triggered = false
set("motion/sync_to_physics", true)
var distance: Vector2 = $FlyingLaserCutterBody.global_position - self.global_position
var time_vec = Vector2(abs(distance.x), abs(distance.y)) / (max_velocity / 3)
var time = time_vec.length()
tween.interpolate_property(
$FlyingLaserCutterBody, "global_position", $FlyingLaserCutterBody.global_position, self.global_position, time
)
tween.start()

View File

@ -2,12 +2,6 @@
[ext_resource path="res://src/Contraptions/Platform/FlyingLaserCutter.gd" type="Script" id=1] [ext_resource path="res://src/Contraptions/Platform/FlyingLaserCutter.gd" type="Script" id=1]
[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 11.4921, 11.9129 )
[sub_resource type="RectangleShape2D" id=4]
extents = Vector2( 3.06672, 10.9923 )
[sub_resource type="StreamTexture" id=6] [sub_resource type="StreamTexture" id=6]
load_path = "res://.import/FlyingLaserCutter.png-9cf80385a79c58041216f8c2509a5bab.stex" load_path = "res://.import/FlyingLaserCutter.png-9cf80385a79c58041216f8c2509a5bab.stex"
@ -27,28 +21,19 @@ tracks/0/keys = {
"values": [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0 ] "values": [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0 ]
} }
[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 11.4921, 11.9129 )
[sub_resource type="RectangleShape2D" id=4]
extents = Vector2( 3.06672, 10.9923 )
[node name="FlyingLaserCutter" type="Node2D"] [node name="FlyingLaserCutter" type="Node2D"]
script = ExtResource( 1 ) script = ExtResource( 1 )
[node name="FlyingLaserCutterBody" type="KinematicBody2D" parent="."] [node name="FlyingLaserCutterBody" type="KinematicBody2D" parent="."]
collision_layer = 32 collision_layer = 32
collision_mask = 56 collision_mask = 57
collision/safe_margin = 0.001
[node name="Tween" type="Tween" parent="FlyingLaserCutterBody"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="FlyingLaserCutterBody"]
position = Vector2( -0.461158, 0.0588541 )
shape = SubResource( 3 )
[node name="LaserArea" type="Area2D" parent="FlyingLaserCutterBody" groups=["harmful"]]
process_priority = -1
collision_layer = 32
collision_mask = 3
[node name="PainZone" type="CollisionShape2D" parent="FlyingLaserCutterBody/LaserArea" groups=["harmful"]]
process_priority = -1
position = Vector2( 9.64728, 0.0077219 )
shape = SubResource( 4 )
[node name="Sprite" type="Sprite" parent="FlyingLaserCutterBody"] [node name="Sprite" type="Sprite" parent="FlyingLaserCutterBody"]
texture = SubResource( 6 ) texture = SubResource( 6 )
@ -61,6 +46,20 @@ __meta__ = {
[node name="AnimationPlayer" type="AnimationPlayer" parent="FlyingLaserCutterBody/Sprite"] [node name="AnimationPlayer" type="AnimationPlayer" parent="FlyingLaserCutterBody/Sprite"]
anims/default = SubResource( 2 ) anims/default = SubResource( 2 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="FlyingLaserCutterBody"]
position = Vector2( -0.461, 0 )
shape = SubResource( 3 )
[node name="LaserArea" type="Area2D" parent="FlyingLaserCutterBody" groups=["harmful"]]
process_priority = -1
collision_layer = 32
collision_mask = 3
[node name="PainZone" type="CollisionShape2D" parent="FlyingLaserCutterBody/LaserArea" groups=["harmful"]]
process_priority = -1
position = Vector2( 9.64728, 0.0077219 )
shape = SubResource( 4 )
[node name="Triggers" type="Node2D" parent="FlyingLaserCutterBody"] [node name="Triggers" type="Node2D" parent="FlyingLaserCutterBody"]
position = Vector2( 0, 0.0077219 ) position = Vector2( 0, 0.0077219 )

View File

@ -0,0 +1,13 @@
[gd_scene load_steps=2 format=2]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 12, 12 )
[node name="DangerousBlockArea" type="Node2D" groups=["harmful"]]
[node name="Area2D" type="Area2D" parent="." groups=["harmful"]]
collision_layer = 8
collision_mask = 3
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D" groups=["harmful"]]
shape = SubResource( 1 )

View File

@ -0,0 +1,11 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://src/HarmfulObjects/DangerousBlockArea.tscn" type="PackedScene" id=1]
[ext_resource path="res://assets/obstacle object/spikesiguess.png" type="Texture" id=2]
[node name="Spikes" type="Node2D"]
[node name="DangerousBlockArea" parent="." instance=ExtResource( 1 )]
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 2 )

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=9 format=2] [gd_scene load_steps=10 format=2]
[ext_resource path="res://src/Actors/Blobby/Blobby.tscn" type="PackedScene" id=1] [ext_resource path="res://src/Actors/Blobby/Blobby.tscn" type="PackedScene" id=1]
[ext_resource path="res://assets/environment/blocks/24BlockBasic.png" type="Texture" id=2] [ext_resource path="res://assets/environment/blocks/24BlockBasic.png" type="Texture" id=2]
@ -6,6 +6,7 @@
[ext_resource path="res://src/Contraptions/Portal/Portal.tscn" type="PackedScene" id=4] [ext_resource path="res://src/Contraptions/Portal/Portal.tscn" type="PackedScene" id=4]
[ext_resource path="res://src/NeutralObjects/Coin.tscn" type="PackedScene" id=5] [ext_resource path="res://src/NeutralObjects/Coin.tscn" type="PackedScene" id=5]
[ext_resource path="res://src/Contraptions/Platform/FlyingLaserCutter.tscn" type="PackedScene" id=6] [ext_resource path="res://src/Contraptions/Platform/FlyingLaserCutter.tscn" type="PackedScene" id=6]
[ext_resource path="res://src/HarmfulObjects/Spikes.tscn" type="PackedScene" id=7]
[sub_resource type="ConvexPolygonShape2D" id=3] [sub_resource type="ConvexPolygonShape2D" id=3]
points = PoolVector2Array( 0, 0, 24, 0, 24, 24, 0, 24 ) points = PoolVector2Array( 0, 0, 24, 0, 24, 24, 0, 24 )
@ -34,7 +35,6 @@ points = PoolVector2Array( 0, 0, 24, 0, 24, 24, 0, 24 )
1/z_index = 0 1/z_index = 0
[node name="LevelTemplate" type="Node2D"] [node name="LevelTemplate" type="Node2D"]
scale = Vector2( 0.998402, 1.0004 )
__meta__ = { __meta__ = {
"_edit_horizontal_guides_": [ 464.0 ], "_edit_horizontal_guides_": [ 464.0 ],
"_edit_vertical_guides_": [ 2880.0 ] "_edit_vertical_guides_": [ 2880.0 ]
@ -48,7 +48,7 @@ position = Vector2( -259.915, 710.547 )
[node name="TileMap" type="TileMap" parent="."] [node name="TileMap" type="TileMap" parent="."]
tile_set = SubResource( 2 ) tile_set = SubResource( 2 )
cell_size = Vector2( 24, 24 ) cell_size = Vector2( 24, 24 )
cell_quadrant_size = 24 cell_quadrant_size = 48
collision_use_kinematic = true collision_use_kinematic = true
collision_friction = 0.0 collision_friction = 0.0
collision_layer = 8 collision_layer = 8
@ -62,22 +62,25 @@ position = Vector2( 1989, 528 )
[node name="Collectibles" type="Node" parent="."] [node name="Collectibles" type="Node" parent="."]
[node name="Coin" parent="Collectibles" instance=ExtResource( 5 )] [node name="Coin" parent="Collectibles" instance=ExtResource( 5 )]
position = Vector2( -166.948, 610.671 ) position = Vector2( -168, 612 )
scale = Vector2( 0.15, 0.15 ) scale = Vector2( 0.15, 0.15 )
[node name="AnimatedSprite" parent="Collectibles/Coin" index="2"] [node name="AnimatedSprite" parent="Collectibles/Coin" index="2"]
frame = 32 position = Vector2( 0, -2 )
frame = 224
[node name="FlyingLaserCutter3" parent="." instance=ExtResource( 6 )] [node name="FlyingLaserCutter3" parent="." instance=ExtResource( 6 )]
position = Vector2( -167.267, 632.742 ) position = Vector2( -168, 636 )
rotation = 1.5708 rotation = 1.5708
[node name="FlyingLaserCutter4" parent="." instance=ExtResource( 6 )] [node name="FlyingLaserCutter4" parent="." instance=ExtResource( 6 )]
position = Vector2( -300.48, 729.708 ) position = Vector2( -300, 576 )
[node name="FlyingLaserCutter5" parent="." instance=ExtResource( 6 )] [node name="FlyingLaserCutter5" parent="." instance=ExtResource( 6 )]
position = Vector2( -14.0224, 527.789 ) position = Vector2( -12.2599, 516.921 )
rotation = -3.14159 rotation = -3.14159
scale = Vector2( 0.996031, 1 )
[node name="Spikes" parent="." instance=ExtResource( 7 )]
position = Vector2( 1572, 732 )
[editable path="Collectibles/Coin"] [editable path="Collectibles/Coin"]