forked from team-sg/hero-mark-2
player.tscn: scholar of the first bullet casings
This commit is contained in:
parent
79cbd62a69
commit
bc57ba4171
45 changed files with 1429 additions and 113 deletions
|
@ -1,7 +1,7 @@
|
|||
extends Camera2D
|
||||
|
||||
onready var player = get_parent().get_node("Player")
|
||||
onready var last_sector = Game.get_sector(player.position)
|
||||
onready var player = get_tree().get_nodes_in_group("player").front()
|
||||
onready var last_sector = Game.get_sector(player.global_position)
|
||||
#Scroll direction
|
||||
export var scroll_h = true
|
||||
export var scroll_v = false
|
||||
|
@ -12,14 +12,18 @@ func _ready():
|
|||
Game.current_sector = last_sector
|
||||
|
||||
func _process(delta):
|
||||
var current_sector = Game.get_sector(player.position)
|
||||
if scroll_h && current_sector.x != last_sector.x:
|
||||
position.x = current_sector.x * Game.resolution.x
|
||||
if respawn_h:
|
||||
var offset = Vector2(8.0 * sign(current_sector.x - last_sector.x), 0.0)
|
||||
Game.respawn_point = player.global_position
|
||||
last_sector.x = current_sector.x
|
||||
if scroll_v && current_sector.y != last_sector.y:
|
||||
position.y = current_sector.y * Game.resolution.y
|
||||
last_sector.y = current_sector.y
|
||||
Game.current_sector = last_sector
|
||||
# use pop_front() instead of [0] so that will not crash without player
|
||||
if not is_instance_valid(player):
|
||||
player = get_tree().get_nodes_in_group("player").pop_front()
|
||||
else:
|
||||
var current_sector = Game.get_sector(player.global_position)
|
||||
if scroll_h && current_sector.x != last_sector.x:
|
||||
position.x = current_sector.x * Game.resolution.x
|
||||
if respawn_h:
|
||||
var offset = Vector2(8.0 * sign(current_sector.x - last_sector.x), 0.0)
|
||||
Game.respawn_point = player.global_position
|
||||
last_sector.x = current_sector.x
|
||||
if scroll_v && current_sector.y != last_sector.y:
|
||||
position.y = current_sector.y * Game.resolution.y
|
||||
last_sector.y = current_sector.y
|
||||
Game.current_sector = last_sector
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue