diff --git a/images/game1/player.tres b/images/game1/player.tres index a2ed5ea..e96230f 100644 --- a/images/game1/player.tres +++ b/images/game1/player.tres @@ -59,5 +59,5 @@ animations = [ { "frames": [ SubResource( 1 ), SubResource( 2 ) ], "loop": true, "name": "default", -"speed": 10.0 +"speed": 2.0 } ] diff --git a/project.godot b/project.godot index 8523472..5fa3b59 100644 --- a/project.godot +++ b/project.godot @@ -44,7 +44,7 @@ window/size/width=192 window/size/height=108 window/size/fullscreen=true window/vsync/vsync_via_compositor=true -window/stretch/mode="2d" +window/stretch/mode="viewport" window/stretch/aspect="keep" [editor_plugins] diff --git a/scenes/game1.tscn b/scenes/game1.tscn index e92bae9..570bfdf 100644 --- a/scenes/game1.tscn +++ b/scenes/game1.tscn @@ -1,21 +1,75 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=10 format=2] [ext_resource path="res://images/game1/opening.tres" type="SpriteFrames" id=1] [ext_resource path="res://images/game1/opening2bg.tres" type="SpriteFrames" id=2] [ext_resource path="res://scripts/game1/Game1Script.gd" type="Script" id=3] [ext_resource path="res://scenes/player.tscn" type="PackedScene" id=4] +[ext_resource path="res://scripts/game1/opening2_next_step_trigger.gd" type="Script" id=5] + +[sub_resource type="RectangleShape2D" id=1] +extents = Vector2( 114.063, 10 ) + +[sub_resource type="RectangleShape2D" id=2] +extents = Vector2( 117.734, 10 ) + +[sub_resource type="RectangleShape2D" id=3] +extents = Vector2( 13.4499, 41.9587 ) + +[sub_resource type="RectangleShape2D" id=4] +extents = Vector2( 6.44203, 23.0973 ) [node name="Node2D" type="Node2D"] script = ExtResource( 3 ) -[node name="Opening2Bg" type="AnimatedSprite" parent="."] -frames = ExtResource( 2 ) -centered = false - [node name="Opening" type="AnimatedSprite" parent="."] visible = false frames = ExtResource( 1 ) centered = false -[node name="RigidBody2D" parent="." instance=ExtResource( 4 )] +[node name="Open2" type="Node2D" parent="."] + +[node name="Opening2Bg" type="AnimatedSprite" parent="Open2"] +frames = ExtResource( 2 ) +centered = false + +[node name="Player" parent="Open2" instance=ExtResource( 4 )] position = Vector2( -6.22136, 83.6906 ) + +[node name="walls" type="Node2D" parent="Open2"] + +[node name="StaticBody2D" type="StaticBody2D" parent="Open2/walls"] +position = Vector2( -6.22136, 83.6906 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Open2/walls/StaticBody2D"] +position = Vector2( 99.7793, 36.875 ) +shape = SubResource( 1 ) + +[node name="StaticBody2D2" type="StaticBody2D" parent="Open2/walls"] +position = Vector2( -6.22136, 83.6906 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Open2/walls/StaticBody2D2"] +position = Vector2( 101.948, -20.3563 ) +shape = SubResource( 2 ) + +[node name="StaticBody2D3" type="StaticBody2D" parent="Open2/walls"] +position = Vector2( -6.22136, 83.6906 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Open2/walls/StaticBody2D3"] +position = Vector2( -25.6957, 6 ) +shape = SubResource( 3 ) + +[node name="StaticBody2D4" type="StaticBody2D" parent="Open2/walls"] +position = Vector2( -6.22136, 83.6906 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Open2/walls/StaticBody2D4"] +position = Vector2( 224.921, 6 ) +shape = SubResource( 3 ) + +[node name="next_step_trigger" type="Area2D" parent="Open2"] +position = Vector2( -6.22136, 83.6906 ) +script = ExtResource( 5 ) +root_path = NodePath("../..") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Open2/next_step_trigger"] +position = Vector2( 210.738, 5 ) +shape = SubResource( 4 ) diff --git a/scenes/player.tscn b/scenes/player.tscn index b090ffe..b8286fc 100644 --- a/scenes/player.tscn +++ b/scenes/player.tscn @@ -1,13 +1,17 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=4 format=2] [ext_resource path="res://images/game1/player.tres" type="SpriteFrames" id=1] +[ext_resource path="res://scripts/game1/PlayerController.gd" type="Script" id=2] [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 10, 4.01179 ) [node name="Player" type="RigidBody2D"] +position = Vector2( 1, -1 ) mode = 2 gravity_scale = 0.0 +linear_damp = 25.0 +script = ExtResource( 2 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource( 1 ) diff --git a/scripts/game1/Game1Script.gd b/scripts/game1/Game1Script.gd index 8af9e7d..8cfa592 100644 --- a/scripts/game1/Game1Script.gd +++ b/scripts/game1/Game1Script.gd @@ -5,3 +5,6 @@ func _ready(): $Opening.play('default') yield($Opening, 'animation_finished') $Opening.hide() + +func launch_game(): + $Open2.hide() diff --git a/scripts/game1/PlayerController.gd b/scripts/game1/PlayerController.gd new file mode 100644 index 0000000..d2b3fe9 --- /dev/null +++ b/scripts/game1/PlayerController.gd @@ -0,0 +1,40 @@ +extends RigidBody2D + + +var dir = Vector2(0, 0) + +func _input(event): + var x = 0 + var y = 0 + if event.is_action_pressed('left'): + x -= 1 + if event.is_action_released('left'): + x += 1 + if event.is_action_pressed('right'): + x += 1 + if event.is_action_released('right'): + x -= 1 + + if event.is_action_pressed('up'): + y -= 1 + if event.is_action_released('up'): + y += 1 + if event.is_action_pressed('down'): + y += 1 + if event.is_action_released('down'): + y -= 1 + + dir.x += x + dir.y += y + +func _process(delta): + if linear_velocity.length_squared() < 1: + $Sprite.play('default') + elif linear_velocity.x > 0: + $Sprite.play('right') + else: + $Sprite.play('left') + +func _physics_process(delta : float): + apply_central_impulse(dir.normalized() * 10) + diff --git a/scripts/game1/opening2_next_step_trigger.gd b/scripts/game1/opening2_next_step_trigger.gd new file mode 100644 index 0000000..279ec74 --- /dev/null +++ b/scripts/game1/opening2_next_step_trigger.gd @@ -0,0 +1,12 @@ +extends Area2D + +export (NodePath) var root_path : String +onready var root = get_node(root_path) + +func _ready(): + assert (root != null) + connect('body_entered', self, 'on_body_entered') + +func on_body_entered(body : Node): + if body.name == 'Player': + root.launch_game()