From 706de868fe6c3728fe29087690800a0199774e1c Mon Sep 17 00:00:00 2001 From: Logan Date: Fri, 17 Jul 2020 20:10:42 -0500 Subject: [PATCH] Updates global player position --- ItemPickup.gd | 3 +++ characters/Player.tscn | 6 +----- levels/test.tscn | 2 +- script/globals.gd | 1 + script/player.gd | 6 ++++-- 5 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 ItemPickup.gd diff --git a/ItemPickup.gd b/ItemPickup.gd new file mode 100644 index 0000000..8efb11b --- /dev/null +++ b/ItemPickup.gd @@ -0,0 +1,3 @@ +extends Node + + diff --git a/characters/Player.tscn b/characters/Player.tscn index 7a44776..1bba75d 100644 --- a/characters/Player.tscn +++ b/characters/Player.tscn @@ -1,10 +1,9 @@ -[gd_scene load_steps=12 format=2] +[gd_scene load_steps=11 format=2] [ext_resource path="res://script/player.gd" type="Script" id=1] [ext_resource path="res://ui/PlayerStats.tscn" type="PackedScene" id=2] [ext_resource path="res://meta/BoundedCamera.tscn" type="PackedScene" id=3] [ext_resource path="res://script/PlayerStateMachine.gd" type="Script" id=4] -[ext_resource path="res://magic/Wands/BasicWand.tscn" type="PackedScene" id=5] [ext_resource path="res://art/WizardM.png" type="Texture" id=6] [sub_resource type="OccluderPolygon2D" id=1] @@ -84,9 +83,6 @@ script = ExtResource( 4 ) [node name="HoldPosition" type="Position2D" parent="."] position = Vector2( 0, -7 ) -[node name="Wand" parent="HoldPosition" instance=ExtResource( 5 )] -position = Vector2( 14, 0 ) - [node name="Sprite" type="Sprite" parent="."] position = Vector2( 0, -12 ) texture = ExtResource( 6 ) diff --git a/levels/test.tscn b/levels/test.tscn index b205ef9..27c3693 100644 --- a/levels/test.tscn +++ b/levels/test.tscn @@ -9,4 +9,4 @@ position = Vector2( 60, 176 ) [node name="TileMap" parent="." instance=ExtResource( 2 )] -tile_data = PoolIntArray( 65536, 0, 8, 65537, 0, 10, 65538, 0, 10, 65539, 0, 10, 65540, 0, 10, 65541, 0, 10, 65542, 0, 10, 65543, 0, 10, 65544, 0, 10, 65545, 0, 10, 65546, 0, 10, 65547, 0, 10, 65548, 0, 10, 65549, 0, 10, 65550, 0, 10, 65551, 0, 10, 65552, 0, 10, 65553, 0, 10, 65554, 0, 10, 65555, 0, 10, 65556, 0, 10, 65557, 0, 11, 131072, 0, 65544, 131073, 0, 131078, 131074, 0, 196617, 131075, 0, 196617, 131076, 0, 196617, 131077, 0, 196617, 131078, 0, 196617, 131079, 0, 196617, 131080, 0, 196617, 131081, 0, 196617, 131082, 0, 196617, 131083, 0, 196617, 131084, 0, 196617, 131085, 0, 196617, 131086, 0, 196617, 131087, 0, 196617, 131088, 0, 196617, 131089, 0, 196617, 131090, 0, 196617, 131091, 0, 196617, 131092, 0, 131077, 131093, 0, 131083, 196608, 0, 65544, 196609, 0, 131083, 196628, 0, 65544, 196629, 0, 131083, 262144, 0, 65544, 262145, 0, 131083, 262164, 0, 65544, 262165, 0, 131083, 327680, 0, 65544, 327681, 0, 131083, 327700, 0, 65544, 327701, 0, 131083, 393216, 0, 65544, 393217, 0, 131083, 393236, 0, 65544, 393237, 0, 131083, 458752, 0, 65544, 458753, 0, 131083, 458772, 0, 65544, 458773, 0, 131083, 524288, 0, 65544, 524289, 0, 131083, 524308, 0, 65544, 524309, 0, 131083, 589824, 0, 65544, 589825, 0, 131083, 589844, 0, 65544, 589845, 0, 131083, 655360, 0, 65544, 655361, 0, 131083, 655380, 0, 65544, 655381, 0, 131083, 720896, 0, 65544, 720897, 0, 65542, 720898, 0, 10, 720899, 0, 10, 720900, 0, 10, 720901, 0, 10, 720902, 0, 10, 720903, 0, 10, 720904, 0, 10, 720905, 0, 10, 720906, 0, 10, 720907, 0, 10, 720908, 0, 10, 720909, 0, 10, 720910, 0, 10, 720911, 0, 10, 720912, 0, 10, 720913, 0, 10, 720914, 0, 10, 720915, 0, 10, 720916, 0, 65541, 720917, 0, 131083, 786432, 0, 196616, 786433, 0, 196617, 786434, 0, 196617, 786435, 0, 196617, 786436, 0, 196617, 786437, 0, 196617, 786438, 0, 196617, 786439, 0, 196617, 786440, 0, 196617, 786441, 0, 196617, 786442, 0, 196617, 786443, 0, 196617, 786444, 0, 196617, 786445, 0, 196617, 786446, 0, 196617, 786447, 0, 196617, 786448, 0, 196617, 786449, 0, 196617, 786450, 0, 196617, 786451, 0, 196617, 786452, 0, 196617, 786453, 0, 196619 ) +tile_data = PoolIntArray( 65536, 0, 8, 65537, 0, 10, 65538, 0, 10, 65539, 0, 10, 65540, 0, 10, 65541, 0, 10, 65542, 0, 10, 65543, 0, 10, 65544, 0, 10, 65545, 0, 10, 65546, 0, 10, 65547, 0, 10, 65548, 0, 10, 65549, 0, 10, 65550, 0, 10, 65551, 0, 10, 65552, 0, 10, 65553, 0, 10, 65554, 0, 10, 65555, 0, 10, 65556, 0, 11, 131072, 0, 65544, 131073, 0, 131078, 131074, 0, 196617, 131075, 0, 196617, 131076, 0, 196617, 131077, 0, 196617, 131078, 0, 196617, 131079, 0, 196617, 131080, 0, 196617, 131081, 0, 196617, 131082, 0, 196617, 131083, 0, 196617, 131084, 0, 196617, 131085, 0, 196617, 131086, 0, 196617, 131087, 0, 196617, 131088, 0, 196617, 131089, 0, 196617, 131090, 0, 196617, 131091, 0, 131077, 131092, 0, 131083, 196608, 0, 65544, 196609, 0, 131083, 196627, 0, 65544, 196628, 0, 131083, 262144, 0, 65544, 262145, 0, 131083, 262163, 0, 65544, 262164, 0, 131083, 327680, 0, 65544, 327681, 0, 131083, 327699, 0, 65544, 327700, 0, 131083, 393216, 0, 65544, 393217, 0, 131083, 393235, 0, 65544, 393236, 0, 131083, 458752, 0, 65544, 458753, 0, 131083, 458771, 0, 65544, 458772, 0, 131083, 524288, 0, 65544, 524289, 0, 131083, 524307, 0, 65544, 524308, 0, 131083, 589824, 0, 65544, 589825, 0, 131083, 589843, 0, 65544, 589844, 0, 131083, 655360, 0, 65544, 655361, 0, 131083, 655379, 0, 65544, 655380, 0, 131083, 720896, 0, 65544, 720897, 0, 65542, 720898, 0, 10, 720899, 0, 10, 720900, 0, 10, 720901, 0, 10, 720902, 0, 10, 720903, 0, 10, 720904, 0, 10, 720905, 0, 10, 720906, 0, 10, 720907, 0, 10, 720908, 0, 10, 720909, 0, 10, 720910, 0, 10, 720911, 0, 10, 720912, 0, 10, 720913, 0, 10, 720914, 0, 10, 720915, 0, 65541, 720916, 0, 131083, 786432, 0, 196616, 786433, 0, 196617, 786434, 0, 196617, 786435, 0, 196617, 786436, 0, 196617, 786437, 0, 196617, 786438, 0, 196617, 786439, 0, 196617, 786440, 0, 196617, 786441, 0, 196617, 786442, 0, 196617, 786443, 0, 196617, 786444, 0, 196617, 786445, 0, 196617, 786446, 0, 196617, 786447, 0, 196617, 786448, 0, 196617, 786449, 0, 196617, 786450, 0, 196617, 786451, 0, 196617, 786452, 0, 196619 ) diff --git a/script/globals.gd b/script/globals.gd index 2d42863..f0d7811 100644 --- a/script/globals.gd +++ b/script/globals.gd @@ -2,3 +2,4 @@ extends Node const TILE_SIZE = 16 var WHITE_PROJECTILE_PS = preload("res://magic/projectiles/WhiteProjectile.tscn") +var player = Vector2() diff --git a/script/player.gd b/script/player.gd index f111646..5cda024 100644 --- a/script/player.gd +++ b/script/player.gd @@ -26,7 +26,7 @@ onready var ShootDelay: Timer = $ShootDelay onready var StateMachine: Node = $PlayerStateMachine onready var HoldPosition: Node2D = $HoldPosition onready var ProjectileSpawn: Node2D = $HoldPosition/ProjectileSpawn -onready var Wand: Sprite = $HoldPosition/Wand +onready var Wand onready var Stats = $Stats onready var health = Stats.health setget set_health, get_health @@ -53,6 +53,8 @@ func _ready(): func _physics_process(delta): + Globals.player = position + print(Globals.player) emit_signal("grounded_updated", is_on_floor()) @@ -61,7 +63,7 @@ func handle_move_input(): velocity.x = lerp(velocity.x, speed * input_direction, get_movement_weight()) HoldPosition.look_at(get_global_mouse_position()) - if Input.is_action_pressed("shoot"): + if Input.is_action_pressed("shoot") and Wand != null: Wand.fire_projectile(HoldPosition.rotation_degrees) if input_direction > 0: