keep rounds and map for next selection
This commit is contained in:
parent
01bb4f3a4f
commit
3c66799413
5 changed files with 25 additions and 15 deletions
|
@ -20,12 +20,12 @@ var viewCarMargin_zoombackup=viewCarMargin_zoomstart-Vector2(0.1,0.1) #start zoo
|
|||
var zoomspeed=0.5
|
||||
var zoomspeed_backup=0.1 #relative to screen size
|
||||
var zoom_normal=1.5
|
||||
const CAMERA_POSITION_SPEED=0.5 #0.0 - 1.0, higher=faster
|
||||
const CAMERA_POSITION_SPEED=0.02 #0.0 - 1.0, higher=faster
|
||||
|
||||
var running=false
|
||||
|
||||
|
||||
var time_close_keypressed=1#seconds to wait after key pressed at endscreen
|
||||
var time_close_keypressed=1 #seconds to wait after key pressed at endscreen
|
||||
|
||||
var game_ended=false
|
||||
|
||||
|
@ -39,7 +39,7 @@ func _ready() -> void:
|
|||
|
||||
#Load Map
|
||||
var checkpoints :Array[String]=[]
|
||||
var mapscene=load(Gamestate.getSelectedMap())
|
||||
var mapscene=load(Gamestate.getSelectedMapSceneName())
|
||||
var mapsceneinstance=mapscene.instantiate()
|
||||
add_child(mapsceneinstance)
|
||||
for mapc in mapsceneinstance.get_children():
|
||||
|
@ -71,7 +71,6 @@ func _process(delta: float) -> void:
|
|||
countdown_label.text=str(round(countdown.time_left))
|
||||
|
||||
var cars=cars.get_children()
|
||||
var meanCarPosition=Vector2.ZERO
|
||||
var displayedCarCount=0
|
||||
var maxCarSpeed=0
|
||||
var minPos=Vector2.ZERO #min/max x and y position of all cars
|
||||
|
@ -85,7 +84,6 @@ func _process(delta: float) -> void:
|
|||
for c in cars:
|
||||
if !c.hasFinished() or !oneDriving:
|
||||
var carpos = c.getPosition()
|
||||
meanCarPosition+=carpos
|
||||
|
||||
maxCarSpeed=max(maxCarSpeed,c.getSpeed())
|
||||
if displayedCarCount==0:
|
||||
|
@ -101,10 +99,9 @@ func _process(delta: float) -> void:
|
|||
|
||||
displayedCarCount+=1
|
||||
|
||||
meanCarPosition/=displayedCarCount
|
||||
|
||||
#camera.position=lerp(camera.position,meanCarPosition,CAMERA_POSITION_SPEED)
|
||||
camera.position=meanCarPosition
|
||||
camera.position=lerp(camera.position,(minPos+maxPos)/2.0,CAMERA_POSITION_SPEED)
|
||||
|
||||
|
||||
|
||||
var viewsize = camera.get_viewport_rect().size
|
||||
|
|
|
@ -13,7 +13,7 @@ var map_scene_name=""
|
|||
var map_scene_name_prefix="res://scenes/map_"
|
||||
var map_scene_name_postfix=".tscn"
|
||||
|
||||
var rounds=1
|
||||
var rounds=3
|
||||
|
||||
func getRounds():
|
||||
return rounds
|
||||
|
@ -22,11 +22,14 @@ func setRounds(r):
|
|||
print("Rounds set to "+str(r))
|
||||
rounds=r
|
||||
|
||||
func getSelectedMap():
|
||||
func getSelectedMap(): #return only short map name "00"
|
||||
return map_scene_name
|
||||
|
||||
func getSelectedMapSceneName(): #returns full scene path "res://scenes/map_00.tscn"
|
||||
return map_scene_name_prefix+map_scene_name+map_scene_name_postfix
|
||||
|
||||
func setSelectedMap(mapname):
|
||||
map_scene_name=map_scene_name_prefix+mapname+map_scene_name_postfix
|
||||
map_scene_name=mapname
|
||||
|
||||
func checkColoriFree(i):
|
||||
var free=true
|
||||
|
|
|
@ -12,6 +12,12 @@ func _ready() -> void:
|
|||
|
||||
if len(Gamestate.getSelectedMap())<=0: #no map selected (ie on startup)
|
||||
get_children()[0].emit_signal("pressed") #preselect first map in list
|
||||
else:
|
||||
for c in get_children():
|
||||
if c.name==button_prefix+Gamestate.getSelectedMap():
|
||||
c.emit_signal("pressed")
|
||||
break
|
||||
|
||||
|
||||
|
||||
func _on_btn_map(btn):
|
||||
|
|
|
@ -7,6 +7,7 @@ extends Node
|
|||
func _ready():
|
||||
removeAssignedKeys()
|
||||
Gamestate.removeAllPlayers()
|
||||
$Timer.stop()
|
||||
|
||||
func assignKeys():
|
||||
var i=0
|
||||
|
@ -68,7 +69,9 @@ func _on_btn_fullscreen_toggled(toggled_on: bool) -> void:
|
|||
|
||||
|
||||
func _on_rounds_selection_item_selected(index: int) -> void:
|
||||
$Timer.start()
|
||||
if not $Timer.is_stopped(): #only restart
|
||||
$Timer.start()
|
||||
|
||||
func _on_map_container_map_changed() -> void:
|
||||
$Timer.start()
|
||||
if not $Timer.is_stopped(): #only restart
|
||||
$Timer.start()
|
||||
|
|
|
@ -3,8 +3,9 @@ extends OptionButton
|
|||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
select(3-1) #preselect rounds
|
||||
Gamestate.setRounds(3)
|
||||
var selectedRounds=Gamestate.getRounds()
|
||||
select(selectedRounds-1) #preselect rounds
|
||||
Gamestate.setRounds(selectedRounds)
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue