-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStage.gd
More file actions
41 lines (31 loc) · 1.01 KB
/
Stage.gd
File metadata and controls
41 lines (31 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
extends Node2D
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
const Bullet = preload("res://Bullet.tscn")
const Player = preload("res://Player.tscn")
export(int) var bullet_speed = 100
var score = 0
# Called when the node enters the scene tree for the first time.
func _ready():
var player1 = Player.instance()
player1.position = $Player1SpawnPosition.position
player1.player_index = 0
player1.set_name("Player1")
add_child(player1)
if Globals.is_p2_playing():
var player2 = Player.instance()
player2.position = $Player2SpawnPosition.position
player2.player_index = 1
player2.set_name("Player2")
add_child(player2)
func _do_shoot(position, direction):
var new_bullet = Bullet.instance()
add_child(new_bullet)
var normalised_direction = direction.normalized() * bullet_speed
new_bullet.position = position
new_bullet.velocity = normalised_direction
func _on_enemy_died(point_value):
score += point_value
print("Score is: %d", score)
$CurrentLevel/UI.score_changed(score)