game1: add second opening scene with player controls

This commit is contained in:
Alice Gaudon 2020-08-17 14:37:07 +02:00
parent 2f06eb7f8b
commit b2471a0592
7 changed files with 122 additions and 9 deletions

View File

@ -59,5 +59,5 @@ animations = [ {
"frames": [ SubResource( 1 ), SubResource( 2 ) ], "frames": [ SubResource( 1 ), SubResource( 2 ) ],
"loop": true, "loop": true,
"name": "default", "name": "default",
"speed": 10.0 "speed": 2.0
} ] } ]

View File

@ -44,7 +44,7 @@ window/size/width=192
window/size/height=108 window/size/height=108
window/size/fullscreen=true window/size/fullscreen=true
window/vsync/vsync_via_compositor=true window/vsync/vsync_via_compositor=true
window/stretch/mode="2d" window/stretch/mode="viewport"
window/stretch/aspect="keep" window/stretch/aspect="keep"
[editor_plugins] [editor_plugins]

View File

@ -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/opening.tres" type="SpriteFrames" id=1]
[ext_resource path="res://images/game1/opening2bg.tres" type="SpriteFrames" id=2] [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://scripts/game1/Game1Script.gd" type="Script" id=3]
[ext_resource path="res://scenes/player.tscn" type="PackedScene" id=4] [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"] [node name="Node2D" type="Node2D"]
script = ExtResource( 3 ) script = ExtResource( 3 )
[node name="Opening2Bg" type="AnimatedSprite" parent="."]
frames = ExtResource( 2 )
centered = false
[node name="Opening" type="AnimatedSprite" parent="."] [node name="Opening" type="AnimatedSprite" parent="."]
visible = false visible = false
frames = ExtResource( 1 ) frames = ExtResource( 1 )
centered = false 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 ) 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 )

View File

@ -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://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] [sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 10, 4.01179 ) extents = Vector2( 10, 4.01179 )
[node name="Player" type="RigidBody2D"] [node name="Player" type="RigidBody2D"]
position = Vector2( 1, -1 )
mode = 2 mode = 2
gravity_scale = 0.0 gravity_scale = 0.0
linear_damp = 25.0
script = ExtResource( 2 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 1 ) shape = SubResource( 1 )

View File

@ -5,3 +5,6 @@ func _ready():
$Opening.play('default') $Opening.play('default')
yield($Opening, 'animation_finished') yield($Opening, 'animation_finished')
$Opening.hide() $Opening.hide()
func launch_game():
$Open2.hide()

View File

@ -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)

View File

@ -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()