[WIP] A Stomp hazard

This commit is contained in:
Sagi Dayan 2020-11-10 08:51:34 -05:00
parent 2e28444826
commit 5eb6b0194e
13 changed files with 235 additions and 67 deletions

View file

@ -2,106 +2,106 @@
[ext_resource path="res://assets/Tiles/tileset.png" type="Texture" id=1]
[sub_resource type="OccluderPolygon2D" id=53]
[sub_resource type="OccluderPolygon2D" id=1]
polygon = PoolVector2Array( 16, 16, 4.51224, 16, 4.51224, 5.0704, 16, 5.0704 )
[sub_resource type="OccluderPolygon2D" id=54]
[sub_resource type="OccluderPolygon2D" id=2]
polygon = PoolVector2Array( 16, 16, 4.4869, 16, 4.4869, 0, 16, 0 )
[sub_resource type="OccluderPolygon2D" id=57]
[sub_resource type="OccluderPolygon2D" id=3]
polygon = PoolVector2Array( 16, 0, 4.4869, 0, 4.4869, 10.994, 16, 10.994 )
[sub_resource type="OccluderPolygon2D" id=55]
[sub_resource type="OccluderPolygon2D" id=4]
polygon = PoolVector2Array( 16, 16, 0, 16, 0, 5.14114, 16, 5.2346 )
[sub_resource type="OccluderPolygon2D" id=58]
[sub_resource type="OccluderPolygon2D" id=5]
polygon = PoolVector2Array( 0, 16, 16, 16, 16, 0, 0, 0 )
[sub_resource type="OccluderPolygon2D" id=59]
[sub_resource type="OccluderPolygon2D" id=6]
polygon = PoolVector2Array( 16, 0, 0, 0, 0, 11.0875, 16, 11.0875 )
[sub_resource type="OccluderPolygon2D" id=56]
[sub_resource type="OccluderPolygon2D" id=7]
polygon = PoolVector2Array( 11.9286, 15.9829, 0, 16, 0, 5.32807, 11.8352, 5.32807 )
[sub_resource type="OccluderPolygon2D" id=60]
[sub_resource type="OccluderPolygon2D" id=8]
polygon = PoolVector2Array( 0, 0, 11.8352, 0, 11.7417, 16, 0, 16 )
[sub_resource type="OccluderPolygon2D" id=61]
[sub_resource type="OccluderPolygon2D" id=9]
polygon = PoolVector2Array( 11.5548, 0, 0, 0, 0, 11.0875, 11.5548, 11.0875 )
[sub_resource type="OccluderPolygon2D" id=62]
[sub_resource type="OccluderPolygon2D" id=10]
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 11.4032, 12.8456, 11.4032, 11.6306, 11.4032, 11.724, 16, 0, 16, 0, 0 )
[sub_resource type="OccluderPolygon2D" id=63]
[sub_resource type="OccluderPolygon2D" id=11]
polygon = PoolVector2Array( 11.6306, 16, 0, 16, 0, 0, 11.6306, 0 )
[sub_resource type="OccluderPolygon2D" id=64]
[sub_resource type="OccluderPolygon2D" id=12]
polygon = PoolVector2Array( 11.4436, 0, 11.5371, 4.45152, 16, 4.54499, 16, 16, 0, 16, 0, 0 )
[sub_resource type="OccluderPolygon2D" id=65]
[sub_resource type="OccluderPolygon2D" id=13]
polygon = PoolVector2Array( 16, 0, 0, 0, 0, 11.2163, 16, 11.2163 )
[sub_resource type="OccluderPolygon2D" id=66]
[sub_resource type="OccluderPolygon2D" id=14]
polygon = PoolVector2Array( 16, 16, 0, 16, 0, 4.63845, 16, 4.63845 )
[sub_resource type="OccluderPolygon2D" id=67]
[sub_resource type="OccluderPolygon2D" id=15]
polygon = PoolVector2Array( 0, 11.4032, 0, 0, 16, 0, 16, 16, 3.18344, 16, 3.08997, 11.3097 )
[sub_resource type="OccluderPolygon2D" id=68]
[sub_resource type="OccluderPolygon2D" id=16]
polygon = PoolVector2Array( 16, 16, 3.08997, 16, 3.08997, 0, 16, 0 )
[sub_resource type="OccluderPolygon2D" id=69]
[sub_resource type="OccluderPolygon2D" id=17]
polygon = PoolVector2Array( 0, 4.73192, 0, 4.73192, 3.18344, 4.73192, 3.18344, 0, 16, 0, 15.8945, 16, 0, 16 )
[sub_resource type="ConvexPolygonShape2D" id=36]
[sub_resource type="ConvexPolygonShape2D" id=18]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
[sub_resource type="ConvexPolygonShape2D" id=37]
[sub_resource type="ConvexPolygonShape2D" id=19]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
[sub_resource type="ConvexPolygonShape2D" id=38]
[sub_resource type="ConvexPolygonShape2D" id=20]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
[sub_resource type="ConvexPolygonShape2D" id=39]
[sub_resource type="ConvexPolygonShape2D" id=21]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
[sub_resource type="ConvexPolygonShape2D" id=40]
[sub_resource type="ConvexPolygonShape2D" id=22]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
[sub_resource type="ConvexPolygonShape2D" id=41]
[sub_resource type="ConvexPolygonShape2D" id=23]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
[sub_resource type="ConvexPolygonShape2D" id=42]
[sub_resource type="ConvexPolygonShape2D" id=24]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
[sub_resource type="ConvexPolygonShape2D" id=43]
[sub_resource type="ConvexPolygonShape2D" id=25]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
[sub_resource type="ConvexPolygonShape2D" id=44]
[sub_resource type="ConvexPolygonShape2D" id=26]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
[sub_resource type="ConvexPolygonShape2D" id=45]
[sub_resource type="ConvexPolygonShape2D" id=27]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
[sub_resource type="ConvexPolygonShape2D" id=46]
[sub_resource type="ConvexPolygonShape2D" id=28]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
[sub_resource type="ConvexPolygonShape2D" id=47]
[sub_resource type="ConvexPolygonShape2D" id=29]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
[sub_resource type="ConvexPolygonShape2D" id=48]
[sub_resource type="ConvexPolygonShape2D" id=30]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
[sub_resource type="ConvexPolygonShape2D" id=49]
[sub_resource type="ConvexPolygonShape2D" id=31]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
[sub_resource type="ConvexPolygonShape2D" id=50]
[sub_resource type="ConvexPolygonShape2D" id=32]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
[sub_resource type="ConvexPolygonShape2D" id=51]
[sub_resource type="ConvexPolygonShape2D" id=33]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
[sub_resource type="ConvexPolygonShape2D" id=52]
[sub_resource type="ConvexPolygonShape2D" id=34]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
[sub_resource type="TileSet" id=35]
@ -116,7 +116,7 @@ points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
0/autotile/icon_coordinate = Vector2( 1, 0 )
0/autotile/tile_size = Vector2( 16, 16 )
0/autotile/spacing = 0
0/autotile/occluder_map = [ Vector2( 0, 0 ), SubResource( 53 ), Vector2( 0, 1 ), SubResource( 54 ), Vector2( 0, 2 ), SubResource( 57 ), Vector2( 1, 0 ), SubResource( 55 ), Vector2( 1, 1 ), SubResource( 58 ), Vector2( 1, 2 ), SubResource( 59 ), Vector2( 2, 0 ), SubResource( 56 ), Vector2( 2, 1 ), SubResource( 60 ), Vector2( 2, 2 ), SubResource( 61 ), Vector2( 3, 0 ), SubResource( 62 ), Vector2( 3, 1 ), SubResource( 63 ), Vector2( 3, 2 ), SubResource( 64 ), Vector2( 4, 0 ), SubResource( 65 ), Vector2( 4, 2 ), SubResource( 66 ), Vector2( 5, 0 ), SubResource( 67 ), Vector2( 5, 1 ), SubResource( 68 ), Vector2( 5, 2 ), SubResource( 69 ) ]
0/autotile/occluder_map = [ Vector2( 0, 0 ), SubResource( 1 ), Vector2( 0, 1 ), SubResource( 2 ), Vector2( 0, 2 ), SubResource( 3 ), Vector2( 1, 0 ), SubResource( 4 ), Vector2( 1, 1 ), SubResource( 5 ), Vector2( 1, 2 ), SubResource( 6 ), Vector2( 2, 0 ), SubResource( 7 ), Vector2( 2, 1 ), SubResource( 8 ), Vector2( 2, 2 ), SubResource( 9 ), Vector2( 3, 0 ), SubResource( 10 ), Vector2( 3, 1 ), SubResource( 11 ), Vector2( 3, 2 ), SubResource( 12 ), Vector2( 4, 0 ), SubResource( 13 ), Vector2( 4, 2 ), SubResource( 14 ), Vector2( 5, 0 ), SubResource( 15 ), Vector2( 5, 1 ), SubResource( 16 ), Vector2( 5, 2 ), SubResource( 17 ) ]
0/autotile/navpoly_map = [ ]
0/autotile/priority_map = [ ]
0/autotile/z_index_map = [ ]
@ -124,110 +124,110 @@ points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
0/navigation_offset = Vector2( 0, 0 )
0/shape_offset = Vector2( 0, 0 )
0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
0/shape = SubResource( 36 )
0/shape = SubResource( 18 )
0/shape_one_way = false
0/shape_one_way_margin = 1.0
0/shapes = [ {
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 36 ),
"shape": SubResource( 18 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 1, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 37 ),
"shape": SubResource( 19 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 2, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 38 ),
"shape": SubResource( 20 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 0, 1 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 39 ),
"shape": SubResource( 21 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 1, 1 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 40 ),
"shape": SubResource( 22 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 2, 1 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 41 ),
"shape": SubResource( 23 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 0, 2 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 42 ),
"shape": SubResource( 24 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 1, 2 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 43 ),
"shape": SubResource( 25 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 2, 2 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 44 ),
"shape": SubResource( 26 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 3, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 45 ),
"shape": SubResource( 27 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 3, 1 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 46 ),
"shape": SubResource( 28 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 3, 2 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 47 ),
"shape": SubResource( 29 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 4, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 48 ),
"shape": SubResource( 30 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 4, 2 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 49 ),
"shape": SubResource( 31 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 5, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 50 ),
"shape": SubResource( 32 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 5, 1 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 51 ),
"shape": SubResource( 33 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 5, 2 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 52 ),
"shape": SubResource( 34 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
0/z_index = 0

BIN
assets/Tiles/stomp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/stomp.png-b303eb12135d71e5296780eea6884706.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/Tiles/stomp.png"
dest_files=[ "res://.import/stomp.png-b303eb12135d71e5296780eea6884706.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=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

View file

@ -59,6 +59,11 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://src/Hazards/Spike.gd"
}, {
"base": "Node2D",
"class": "Stomp",
"language": "GDScript",
"path": "res://src/Hazards/Stomp.gd"
}, {
"base": "TileMap",
"class": "TrapTiles",
"language": "GDScript",
@ -80,6 +85,7 @@ _global_script_class_icons={
"Level": "",
"Player": "",
"Spike": "",
"Stomp": "",
"TrapTiles": "",
"WarpZone": ""
}

View file

@ -73,6 +73,9 @@ func _physics_process(delta: float) -> void:
_boost_velocity = Vector2.ZERO
_check_collisions()
update_sprite(_direction)
elif _boost_velocity != Vector2.ZERO:
_velocity = move_and_slide_with_snap(_velocity, _snap_vector if _direction.y != -1 else Vector2.ZERO, FLOOR_NORMAL)
_boost_velocity = Vector2.ZERO
func _input_check() -> void:
@ -92,6 +95,7 @@ func _check_collisions():
for i in get_slide_count():
var collision = get_slide_collision(i)
if collision.collider.name == 'TrapTiles':
_boost_velocity = -_velocity
die()
return
@ -328,5 +332,9 @@ func face_player(right:bool = true):
1
)
func set_position(pos:Vector2):
position = pos
_falling_start_position = pos.y
func boost(velocity:Vector2):
_boost_velocity = velocity

View file

@ -673,7 +673,7 @@ __meta__ = {
}
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( 0, -7 )
position = Vector2( 0, -8 )
shape = SubResource( 1 )
[node name="Light2D" type="Light2D" parent="."]
@ -693,7 +693,7 @@ position = Vector2( 0, -8 )
texture = ExtResource( 8 )
vframes = 13
hframes = 8
frame = 73
frame = 32
[node name="SordRange" type="Area2D" parent="Sprite"]
position = Vector2( -8, 8 )

View file

@ -83,7 +83,7 @@ func _set_player_position(is_entering:bool):
_player.face_player(is_entering)
_player.respawn_position = position
_player.position = position
_player.set_position(position)
func _set_wrap_zones():
_first_time_init = false

View file

@ -10,6 +10,9 @@ func _ready() -> void:
_player.set_ability("wall_jump", true)
_player.set_ability("attack", true)
func _enter_tree():
AudioManager.play_music(AudioManager.Music.PreGame)
func _on_OldDudeIntroArea_body_entered(body: Node) -> void:
if _played_old_man_cutscene: return
if body.name == 'Player':

File diff suppressed because one or more lines are too long

View file

@ -9,6 +9,7 @@ export(int, -360, 360) var direction = 1 setget set_direction
func _on_DamageArea_body_entered(body: Node) -> void:
if body.name == "Player":
body.die()
body.boost(Vector2(150, 0))
func _on_TriggerArea_body_entered(body: Node) -> void:
if body.name == "Player" and not triggerd:

View file

@ -19,10 +19,10 @@ tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.1, 0.2, 0.3, 0.4 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1 ),
"times": PoolRealArray( 0, 0.1, 0.2, 0.3, 0.4, 0.5 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 0, 1, 2, 3, 4 ]
"values": [ 0, 1, 2, 3, 4, 5 ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("DamageArea/CollisionShape2D:position")
@ -66,6 +66,7 @@ tracks/1/keys = {
[node name="SpikeTrap" type="Node2D"]
script = ExtResource( 2 )
direction = 1
[node name="Sprite" type="Sprite" parent="."]
position = Vector2( 0, -8 )

48
src/Hazards/Stomp.gd Normal file
View file

@ -0,0 +1,48 @@
tool
extends Node2D
class_name Stomp
export var to_point := Vector2(0, 0) setget set_to_position
export var duration := 2.0 setget set_duration
export var delay := .5 setget set_delay
export(String, "UP_DOWN", "LEFT_RIGHT") var g = "UP_DOWN"
onready var tween = $Tween
onready var sprite = $Sprite
var _is_ready = false
func _ready() -> void:
_is_ready = true;
start_motion()
func _on_DeathZone_body_entered(body:Node) -> void:
if body.name == "Player":
body.die()
func set_to_position(val):
print("set_to_position")
to_point = val
start_motion()
func set_duration(val):
print("set_duration")
duration = val
start_motion()
func set_delay(val):
print("set_delay")
delay = val
start_motion()
func start_motion():
if not _is_ready: return
print("Stomp Start Motion")
sprite.position = Vector2.ZERO
tween.stop_all()
tween.repeat = true
tween.interpolate_property(sprite, "position", Vector2.ZERO, to_point, duration, Tween.TRANS_LINEAR, Tween.EASE_IN, delay)
tween.interpolate_property(sprite, "position", to_point, Vector2.ZERO, duration, Tween.TRANS_LINEAR, Tween.EASE_IN, duration+(delay*2))
tween.start()

57
src/Hazards/Stomp.tscn Normal file
View file

@ -0,0 +1,57 @@
[gd_scene load_steps=9 format=2]
[ext_resource path="res://src/Hazards/Stomp.gd" type="Script" id=1]
[ext_resource path="res://assets/Tiles/stomp.png" type="Texture" id=2]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 7, 7 )
[sub_resource type="Gradient" id=3]
colors = PoolColorArray( 1, 1, 1, 0.168627, 1, 1, 1, 0 )
[sub_resource type="GradientTexture" id=4]
gradient = SubResource( 3 )
[sub_resource type="Curve" id=5]
_data = [ Vector2( 0, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 0.30388 ), 0.0, 0.0, 0, 0 ]
[sub_resource type="CurveTexture" id=6]
curve = SubResource( 5 )
[sub_resource type="ParticlesMaterial" id=2]
flag_disable_z = true
gravity = Vector3( 0, 0, 0 )
orbit_velocity = 0.0
orbit_velocity_random = 0.0
scale_curve = SubResource( 6 )
color_ramp = SubResource( 4 )
[node name="Stomp" type="Node2D"]
light_mask = 8
script = ExtResource( 1 )
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 2 )
[node name="DeathZone" type="Area2D" parent="Sprite"]
position = Vector2( 0, 2 )
collision_layer = 4
[node name="CollisionShape2D" type="CollisionShape2D" parent="Sprite/DeathZone"]
position = Vector2( 0, -2 )
shape = SubResource( 1 )
[node name="Particles2D" type="Particles2D" parent="Sprite"]
show_behind_parent = true
light_mask = 0
amount = 12
lifetime = 0.2
local_coords = false
process_material = SubResource( 2 )
texture = ExtResource( 2 )
[node name="Tween" type="Tween" parent="."]
repeat = true
playback_process_mode = 0
playback/repeat = true
[connection signal="body_entered" from="Sprite/DeathZone" to="." method="_on_DeathZone_body_entered"]