diff --git a/LevelOne.tscn b/LevelOne.tscn index 59ad533..dcbc1d0 100644 --- a/LevelOne.tscn +++ b/LevelOne.tscn @@ -1,25 +1,34 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://icon.png" type="Texture" id=1] [sub_resource type="GDScript" id=1] script/source = "extends KinematicBody2D +const UP = Vector2(0, -1) +const GRAVITY = 20 +const SPEED = 200 +const JUMP_HEIGHT = -500 var motion = Vector2() func _physics_process(delta): + motion.y += GRAVITY if Input.is_action_pressed(\"dp_right\"): - motion.x = 100 + motion.x = SPEED elif Input.is_action_pressed(\"dp_left\"): - motion.x = -100 + motion.x = -SPEED else: motion.x = 0 + if is_on_floor(): + if Input.is_action_just_pressed(\"nin_b\"): + motion.y = JUMP_HEIGHT + if Input.is_action_just_pressed(\"select\"): get_tree().quit() - move_and_slide(motion) + move_and_slide(motion, UP) pass " @@ -34,10 +43,13 @@ animations = [ { [sub_resource type="RectangleShape2D" id=3] extents = Vector2( 32, 32 ) +[sub_resource type="RectangleShape2D" id=4] +extents = Vector2( 32, 32 ) + [node name="LevelOne" type="Node"] [node name="Player" type="KinematicBody2D" parent="."] -position = Vector2( 608, 176 ) +position = Vector2( 608, 160 ) script = SubResource( 1 ) __meta__ = { "_edit_group_": true @@ -48,3 +60,96 @@ frames = SubResource( 2 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="Player"] shape = SubResource( 3 ) + +[node name="Walls" type="Node" parent="."] + +[node name="Wall" type="StaticBody2D" parent="Walls"] +position = Vector2( 608, 288 ) +__meta__ = { +"_edit_group_": true +} + +[node name="Sprite" type="Sprite" parent="Walls/Wall"] +modulate = Color( 0, 0, 0, 1 ) +texture = ExtResource( 1 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Walls/Wall"] +shape = SubResource( 4 ) + +[node name="Wall2" type="StaticBody2D" parent="Walls"] +position = Vector2( 672, 288 ) +__meta__ = { +"_edit_group_": true +} + +[node name="Sprite" type="Sprite" parent="Walls/Wall2"] +modulate = Color( 0, 0, 0, 1 ) +texture = ExtResource( 1 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Walls/Wall2"] +shape = SubResource( 4 ) + +[node name="Wall3" type="StaticBody2D" parent="Walls"] +position = Vector2( 736, 288 ) +__meta__ = { +"_edit_group_": true +} + +[node name="Sprite" type="Sprite" parent="Walls/Wall3"] +modulate = Color( 0, 0, 0, 1 ) +texture = ExtResource( 1 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Walls/Wall3"] +shape = SubResource( 4 ) + +[node name="Wall4" type="StaticBody2D" parent="Walls"] +position = Vector2( 800, 288 ) +__meta__ = { +"_edit_group_": true +} + +[node name="Sprite" type="Sprite" parent="Walls/Wall4"] +modulate = Color( 0, 0, 0, 1 ) +texture = ExtResource( 1 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Walls/Wall4"] +shape = SubResource( 4 ) + +[node name="Wall5" type="StaticBody2D" parent="Walls"] +position = Vector2( 544, 288 ) +__meta__ = { +"_edit_group_": true +} + +[node name="Sprite" type="Sprite" parent="Walls/Wall5"] +modulate = Color( 0, 0, 0, 1 ) +texture = ExtResource( 1 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Walls/Wall5"] +shape = SubResource( 4 ) + +[node name="Wall6" type="StaticBody2D" parent="Walls"] +position = Vector2( 480, 288 ) +__meta__ = { +"_edit_group_": true +} + +[node name="Sprite" type="Sprite" parent="Walls/Wall6"] +modulate = Color( 0, 0, 0, 1 ) +texture = ExtResource( 1 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Walls/Wall6"] +shape = SubResource( 4 ) + +[node name="Wall7" type="StaticBody2D" parent="Walls"] +position = Vector2( 416, 288 ) +__meta__ = { +"_edit_group_": true +} + +[node name="Sprite" type="Sprite" parent="Walls/Wall7"] +modulate = Color( 0, 0, 0, 1 ) +texture = ExtResource( 1 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Walls/Wall7"] +shape = SubResource( 4 ) diff --git a/Player.gd b/Player.gd index ba50771..9842819 100644 --- a/Player.gd +++ b/Player.gd @@ -3,10 +3,16 @@ extends KinematicBody2D var motion = Vector2() func _physics_process(delta): - if Input.is_action_pressed("ui_right"): - motion.x = 100 - if Input.is_action_pressed("ui_left"): + if Input.is_action_pressed("dp_right"): + motion.x = 100 + elif Input.is_action_pressed("dp_left"): motion.x = -100 + else: + motion.x = 0 + + if Input.is_action_just_pressed("select"): + get_tree().quit() + move_and_slide(motion) - pass \ No newline at end of file + pass