-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
movimento basico, pulo e escalada da aranha implementados
- Loading branch information
1 parent
3678baa
commit 6bed480
Showing
4 changed files
with
105 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
[gd_scene load_steps=5 format=2] | ||
|
||
[ext_resource path="res://icon.png" type="Texture" id=1] | ||
[ext_resource path="res://Spider.gd" type="Script" id=2] | ||
|
||
[sub_resource type="RectangleShape2D" id=1] | ||
extents = Vector2( 62.5195, 61.5018 ) | ||
|
||
[sub_resource type="CircleShape2D" id=2] | ||
radius = 901.289 | ||
|
||
[node name="Spider" type="KinematicBody2D"] | ||
script = ExtResource( 2 ) | ||
|
||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] | ||
shape = SubResource( 1 ) | ||
|
||
[node name="Sprite" type="Sprite" parent="."] | ||
scale = Vector2( 2, 2 ) | ||
texture = ExtResource( 1 ) | ||
|
||
[node name="Area2D" type="Area2D" parent="."] | ||
|
||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] | ||
position = Vector2( 0.647079, 1.61767 ) | ||
shape = SubResource( 2 ) | ||
|
||
[node name="RayCast2D" type="RayCast2D" parent="."] | ||
|
||
[node name="RayCastLeft" type="RayCast2D" parent="."] | ||
position = Vector2( -74.6544, 50.8628 ) | ||
enabled = true | ||
|
||
[node name="RayCastRight" type="RayCast2D" parent="."] | ||
position = Vector2( 74.4957, 49.9128 ) | ||
enabled = true | ||
|
||
[node name="JumpTimer" type="Timer" parent="."] | ||
wait_time = 0.1 | ||
one_shot = true | ||
[connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"] | ||
[connection signal="body_exited" from="Area2D" to="." method="_on_Area2D_body_exited"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
extends KinematicBody2D | ||
var alvo=null | ||
var velocity=Vector2(0,0) | ||
var CLIMBSPEED=200 | ||
var SPEED=200 | ||
var GRAVITY=100 | ||
var is_jumping=false | ||
var JUMP_ANGLE=PI/6 | ||
var JUMP_SPEED=1000 | ||
func _ready(): | ||
pass | ||
|
||
|
||
func _physics_process(delta): | ||
if alvo!=null: | ||
if not is_jumping: | ||
|
||
if(global_position<alvo.global_position): | ||
velocity.x=SPEED | ||
elif global_position>alvo.global_position: | ||
velocity.x=-SPEED | ||
else: | ||
velocity.x=0 | ||
if is_on_wall(): | ||
|
||
velocity.y=-CLIMBSPEED | ||
elif not is_on_floor(): | ||
velocity.y+=GRAVITY | ||
if is_on_floor() and ((velocity.x<0 and not $RayCastLeft.is_colliding() )or(velocity.x>0 and not $RayCastRight.is_colliding())): | ||
jump() | ||
elif (is_on_floor() or is_on_wall())and $JumpTimer.is_stopped(): | ||
is_jumping=false | ||
else: | ||
velocity.y+=GRAVITY | ||
velocity=move_and_slide(velocity,Vector2(0,-1)) | ||
|
||
|
||
|
||
|
||
func _on_Area2D_body_entered(body): | ||
if body.is_in_group("character"): | ||
$RayCast2D.set_cast_to(body.global_position-global_position) | ||
$RayCast2D.force_raycast_update() | ||
if $RayCast2D.get_collider()==body: | ||
alvo=body | ||
|
||
|
||
func _on_Area2D_body_exited(body): | ||
if body.is_in_group("character"): | ||
alvo=null | ||
func jump(): | ||
print(1) | ||
$JumpTimer.start() | ||
is_jumping=true | ||
velocity=Vector2(0,-1).rotated(JUMP_ANGLE)*JUMP_SPEED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters