mirror of
https://github.com/PfandBoss/SemesterGameJam2022.git
synced 2025-11-12 04:16:12 +01:00
add map
This commit is contained in:
@@ -10,12 +10,17 @@ var t = 0.0
|
||||
@onready var p1_train = $Player1 as Train
|
||||
@onready var p2_train = $Player2 as Train
|
||||
|
||||
|
||||
@onready var StartNode = $StartNode
|
||||
var p1_node : MapNode
|
||||
var p2_node : MapNode
|
||||
|
||||
func _ready():
|
||||
p1_node = StartNode
|
||||
p2_node = StartNode
|
||||
p2_train.get_node("CharacterBody3D").is_player1 = false
|
||||
p2_train.is_P1 = false
|
||||
p1_train.hit.connect(_on_hit_player)
|
||||
p2_train.hit.connect(_on_hit_player)
|
||||
|
||||
|
||||
func _on_hit_player(player1,dmg):
|
||||
@@ -25,5 +30,19 @@ func _on_hit_player(player1,dmg):
|
||||
p1_train.current_speed -= dmg
|
||||
|
||||
func _process(delta):
|
||||
p1_train.current_distance += p1_train.current_speed * delta
|
||||
p2_train.current_distance += p2_train.current_speed * delta
|
||||
|
||||
if(p1_train.current_distance >= p1_node.LENGTH):
|
||||
var distance_delta = p1_train.current_distance - p1_node.LENGTH
|
||||
p1_node = p1_node._on_train_exit(p1_train)
|
||||
p1_train.current_distance = distance_delta
|
||||
|
||||
if(p2_train.current_distance >= p2_node.LENGTH):
|
||||
var distance_delta = p2_train.current_distance - p2_node.LENGTH
|
||||
p2_node = p2_node._on_train_exit(p2_train)
|
||||
p2_train.current_distance = distance_delta
|
||||
|
||||
|
||||
if Input.is_action_pressed("test"):
|
||||
emit_signal("shoot")
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
extends MapNode
|
||||
class_name StraightMapNode
|
||||
|
||||
var next : MapNode
|
||||
@export var next : MapNode
|
||||
|
||||
func _on_train_exit(train):
|
||||
next._on_train_entered(train)
|
||||
super._on_train_exit(train)
|
||||
return next
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
extends StraightMapNode
|
||||
class_name TurnMapNode
|
||||
|
||||
signal turnEvent
|
||||
|
||||
var is_left_turn = false
|
||||
var turn = false
|
||||
var turn_node : MapNode
|
||||
@export var is_left_turn = false
|
||||
@export var turn_node : MapNode
|
||||
|
||||
func _on_train_entered(train):
|
||||
super._on_train_entered(train)
|
||||
@@ -14,5 +15,7 @@ func _on_train_exit(train):
|
||||
if(turn):
|
||||
turn_node._on_train_entered(train)
|
||||
current_trains.erase(train)
|
||||
return turn_node
|
||||
else:
|
||||
super._on_train_exit(train)
|
||||
return next
|
||||
|
||||
@@ -15,7 +15,9 @@ func _ready():
|
||||
func interact():
|
||||
if currentStashValue >= 1:
|
||||
currentStashValue -= 1
|
||||
|
||||
return
|
||||
|
||||
func _on_signal_storing():
|
||||
if currentStashValue < maxStashValue:
|
||||
currentStashValue += 1
|
||||
|
||||
@@ -5,7 +5,8 @@ signal hit(player, dmg)
|
||||
signal game_over
|
||||
|
||||
var is_P1 = true
|
||||
var current_speed = 10
|
||||
var current_distance = 0
|
||||
var current_speed = 5
|
||||
var CANNONS = []
|
||||
var STORAGES = []
|
||||
#@onready var ENGINE = $Module/Engine
|
||||
@@ -25,7 +26,6 @@ func _on_signal_shooting():
|
||||
for cannon in CANNONS:
|
||||
if cannon.shoot():
|
||||
hit.emit(is_P1,cannon.DAMAGE)
|
||||
print("Shot P2")
|
||||
|
||||
func is_dead():
|
||||
if current_speed <= 0:
|
||||
|
||||
Reference in New Issue
Block a user