From 02ebacf45d14d1fa9998687ecbfaa8dfd690d29d Mon Sep 17 00:00:00 2001 From: ajuvercr Date: Sat, 8 Feb 2020 11:36:48 +0100 Subject: [PATCH] general update --- Camera2D.gd | 11 ----------- Main.tscn | 2 +- Player.gd | 2 +- Player.tscn | 27 ++++++++++++++------------- Tower.gd | 2 +- 5 files changed, 17 insertions(+), 27 deletions(-) diff --git a/Camera2D.gd b/Camera2D.gd index 94f5f41..33513f3 100644 --- a/Camera2D.gd +++ b/Camera2D.gd @@ -3,8 +3,6 @@ extends Node export (PackedScene) var Tower = preload("res://Tower.tscn"); onready var screen_size = Vector2(ProjectSettings.get("display/window/size/width"), ProjectSettings.get("display/window/size/height")) -onready var player = get_node("Player") -onready var bg = get_node("Background") export var tower_density = 250 var last_built = 500 @@ -20,15 +18,6 @@ func build_tower(): add_child(tower) last_built += tower_density -func update_view(): - var canvas_transform = get_viewport().get_canvas_transform() - var pos = player.position - pos.y = 0 - canvas_transform[2] = -pos + screen_size / 2 - - bg.position = player.position - get_viewport().set_canvas_transform(canvas_transform) - func _ready(): randomize() diff --git a/Main.tscn b/Main.tscn index abdd68c..9bd26c7 100644 --- a/Main.tscn +++ b/Main.tscn @@ -22,7 +22,7 @@ collision_layer = 0 motion_scale = Vector2( 0.5, 1 ) motion_mirroring = Vector2( 420, 0 ) -[node name="Background" type="Sprite" parent="ParallaxBackground/ParallaxLayer"] +[node name="Sprite" type="Sprite" parent="ParallaxBackground/ParallaxLayer"] position = Vector2( 209.839, 320 ) scale = Vector2( 2.91891, 2.5 ) texture = SubResource( 1 ) diff --git a/Player.gd b/Player.gd index 12b4655..d4f4b5c 100644 --- a/Player.gd +++ b/Player.gd @@ -34,7 +34,7 @@ func _process(delta): position += Vector2(speed, speed_y * speed) - # TODO find the correct rotation, noob + rotation = atan(speed_y / speed) if position.y > screen_size.y: diff --git a/Player.tscn b/Player.tscn index 2e76614..de0f917 100644 --- a/Player.tscn +++ b/Player.tscn @@ -3,10 +3,6 @@ [ext_resource path="res://Player.gd" type="Script" id=1] [ext_resource path="res://res/sprites.png" type="Texture" id=2] -[sub_resource type="CapsuleShape2D" id=1] -radius = 12.8837 -height = 4.07484 - [sub_resource type="AtlasTexture" id=2] atlas = ExtResource( 2 ) region = Rect2( -4, 488, 84, 16 ) @@ -16,7 +12,7 @@ length = 0.8 loop = true step = 0.2 tracks/0/type = "value" -tracks/0/path = NodePath("Node2D/Sprite1:frame") +tracks/0/path = NodePath("Node2D/Sprite:frame") tracks/0/interp = 1 tracks/0/loop_wrap = true tracks/0/imported = false @@ -25,24 +21,25 @@ tracks/0/keys = { "times": PoolRealArray( 0, 0.2, 0.4, 0.6 ), "transitions": PoolRealArray( 1, 1, 1, 1 ), "update": 1, -"values": [ 1, 2, 1, 0 ] +"values": [ 0, 1, 2, 1 ] } -[node name="Player" type="Area2D"] +[sub_resource type="CapsuleShape2D" id=1] +radius = 12.8837 +height = 4.07484 + +[node name="Area2D" type="Area2D"] position = Vector2( 9.25964, 6.09653 ) script = ExtResource( 1 ) __meta__ = { "_edit_group_": true } -[node name="CollisionShape2D" type="CollisionShape2D" parent="."] -rotation = 1.5708 -shape = SubResource( 1 ) - [node name="Node2D" type="Node2D" parent="."] -scale = Vector2( 2, 2 ) -[node name="Sprite1" type="Sprite" parent="Node2D"] +[node name="Sprite" type="Sprite" parent="Node2D"] +position = Vector2( -3.46641, -2.14102 ) +scale = Vector2( 2.14565, 2.14019 ) texture = SubResource( 2 ) hframes = 3 frame = 1 @@ -52,6 +49,10 @@ root_node = NodePath("../..") autoplay = "fly" anims/fly = SubResource( 3 ) +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +rotation = 1.5708 +shape = SubResource( 1 ) + [node name="Camera2D" type="Camera2D" parent="."] current = true limit_top = 0 diff --git a/Tower.gd b/Tower.gd index 8e57392..e66a5d5 100644 --- a/Tower.gd +++ b/Tower.gd @@ -1,4 +1,4 @@ - extends Node2D +extends Node2D signal exit # Declare member variables here. Examples: