add falling block
This commit is contained in:
parent
d6547b61d4
commit
54f0880864
20 changed files with 153 additions and 26 deletions
16
objects/environment/rock/rock.gd
Normal file
16
objects/environment/rock/rock.gd
Normal file
|
@ -0,0 +1,16 @@
|
|||
extends KinematicBody2D
|
||||
var velocity = Vector2.ZERO
|
||||
onready var bottom = $Bottom
|
||||
|
||||
func _physics_process(delta):
|
||||
if !is_on_floor():
|
||||
#Gravity
|
||||
velocity.y = 100
|
||||
velocity.x = 0
|
||||
else:
|
||||
velocity.y = 0
|
||||
move_and_slide(velocity,Vector2.UP)
|
||||
velocity.x = 0
|
||||
|
||||
func push(direction):
|
||||
velocity -= direction * 32
|
40
objects/environment/rock/rock.tscn
Normal file
40
objects/environment/rock/rock.tscn
Normal file
|
@ -0,0 +1,40 @@
|
|||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[ext_resource path="res://graphics/rock/rock.png" type="Texture" id=1]
|
||||
[ext_resource path="res://scripts/1px_border.gdshader" type="Shader" id=2]
|
||||
[ext_resource path="res://objects/environment/rock/rock.gd" type="Script" id=3]
|
||||
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=1]
|
||||
shader = ExtResource( 2 )
|
||||
shader_param/border_color = Color( 0, 0, 0, 1 )
|
||||
shader_param/border_corners = false
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=2]
|
||||
extents = Vector2( 5, 4.5 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=3]
|
||||
extents = Vector2( 5, 4.5 )
|
||||
|
||||
[node name="Rock" type="KinematicBody2D" groups=["pushable"]]
|
||||
collision_layer = 4
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
material = SubResource( 1 )
|
||||
position = Vector2( 0, -1 )
|
||||
texture = ExtResource( 1 )
|
||||
centered = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2( 5, 3.5 )
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="." groups=["squash"]]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
position = Vector2( 5, 3.5 )
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[node name="Bottom" type="Position2D" parent="."]
|
||||
position = Vector2( 5, 8 )
|
Loading…
Add table
Add a link
Reference in a new issue