diff --git a/pwojeto/Scenes/Character.tscn b/pwojeto/Scenes/Character.tscn index 12c966e..de66454 100644 --- a/pwojeto/Scenes/Character.tscn +++ b/pwojeto/Scenes/Character.tscn @@ -17,3 +17,7 @@ shape = SubResource( 1 ) position = Vector2( -0.540359, -1.62108 ) scale = Vector2( 100, 100 ) texture = SubResource( 2 ) + +[node name="WallJumpTimer" type="Timer" parent="."] +wait_time = 0.5 +one_shot = true diff --git a/pwojeto/Scripts/Character.gd b/pwojeto/Scripts/Character.gd index 0d4bd29..e753e17 100644 --- a/pwojeto/Scripts/Character.gd +++ b/pwojeto/Scripts/Character.gd @@ -8,34 +8,40 @@ var velocity=Vector2() var has_double_jump=true var life=100 var double_jump_cost=10 +var wall_jump_cost=5 +var has_wall_jump=true func _ready(): pass # Replace with function body. func _physics_process(delta): - if Input.is_action_pressed("left"): + if Input.is_action_pressed("left") and $WallJumpTimer.is_stopped(): velocity.x=-SPEED if $Sprite.flip_h==false: $Sprite.flip_h=true - elif Input.is_action_pressed("right" ): + elif Input.is_action_pressed("right" ) and $WallJumpTimer.is_stopped(): velocity.x=SPEED if $Sprite.flip_h==true: $Sprite.flip_h=false - else: + elif $WallJumpTimer.is_stopped(): velocity.x=0 if Input.is_action_just_pressed("jump") : if is_on_floor(): velocity.y=-JUMPSPEED + elif is_on_wall(): + wall_jump() + elif has_double_jump: - print(1) + double_jump() - + if not is_on_floor(): velocity.y+=GRAVITY*delta else: has_double_jump=true + has_wall_jump=true velocity=move_and_slide(velocity,Vector2(0,-1)) func double_jump(): @@ -43,6 +49,13 @@ func double_jump(): has_double_jump=false damage(double_jump_cost) +func wall_jump(): + if velocity.x!=0 and has_wall_jump: + velocity.y=-JUMPSPEED + velocity.x=-velocity.x + $WallJumpTimer.start() + damage(wall_jump_cost) + has_wall_jump=false func damage(damage): life-=damage if life<0: diff --git a/pwojeto/menus/main_menu.tscn b/pwojeto/menus/main_menu.tscn index 6a3f5ca..220fb70 100644 --- a/pwojeto/menus/main_menu.tscn +++ b/pwojeto/menus/main_menu.tscn @@ -17,5 +17,17 @@ shape = SubResource( 1 ) position = Vector2( 13.0142, -6.50708 ) polygon = PoolVector2Array( -5.36145, 491.573, 1930.5, 501.334, 1930.5, 764.871, 1.14563, 764.871 ) +[node name="StaticBody2D2" type="StaticBody2D" parent="."] +position = Vector2( 2345.83, -160.504 ) +rotation = 1.5708 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D2"] +position = Vector2( 841.813, 845.58 ) +shape = SubResource( 1 ) + +[node name="Polygon2D" type="Polygon2D" parent="StaticBody2D2"] +position = Vector2( -154.887, 263.417 ) +polygon = PoolVector2Array( -5.36145, 491.573, 1930.5, 501.334, 1930.5, 764.871, 1.14563, 764.871 ) + [node name="Character" parent="." instance=ExtResource( 1 )] position = Vector2( 917.5, 348.13 )