add current project files

This commit is contained in:
interfisch 2024-11-03 19:16:30 +01:00
parent 28e3258157
commit b90473b305
32 changed files with 1703 additions and 0 deletions

2
.gitattributes vendored Normal file
View file

@ -0,0 +1,2 @@
# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf

1
icon.svg Normal file
View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128"><rect width="124" height="124" x="2" y="2" fill="#363d52" stroke="#212532" stroke-width="4" rx="14"/><g fill="#fff" transform="translate(12.322 12.322)scale(.101)"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 814 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H446l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c0 34 58 34 58 0v-86c0-34-58-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042" transform="translate(12.322 12.322)scale(.101)"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></svg>

After

Width:  |  Height:  |  Size: 994 B

37
icon.svg.import Normal file
View file

@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://8yyue0hxh8we"
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://icon.svg"
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

27
project.godot Normal file
View file

@ -0,0 +1,27 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=5
[application]
config/name="CustomInputTest"
run/main_scene="res://scenes/menu.tscn"
config/features=PackedStringArray("4.3", "Forward Plus")
config/icon="res://icon.svg"
[autoload]
Gamestate="*res://scripts/gamestate.gd"
[layer_names]
2d_physics/layer_1="walls"
2d_physics/layer_2="walldetection"
2d_physics/layer_3="Finish"
2d_physics/layer_4="Checkpoint"

43
scenes/car.tscn Normal file
View file

@ -0,0 +1,43 @@
[gd_scene load_steps=5 format=3 uid="uid://0g7qqh7naniv"]
[ext_resource type="Script" path="res://scripts/car_node.gd" id="1_0tin3"]
[ext_resource type="Script" path="res://scripts/car.gd" id="1_i5tet"]
[ext_resource type="Texture2D" uid="uid://c2wq5xkfmca1r" path="res://sprites/car.png" id="2_48rvw"]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_bj1hp"]
radius = 8.0
height = 34.0
[node name="Car" type="Node2D"]
script = ExtResource("1_0tin3")
[node name="Car" type="CharacterBody2D" parent="."]
script = ExtResource("1_i5tet")
[node name="Sprite2D" type="Sprite2D" parent="Car"]
z_index = 10
scale = Vector2(0.5, 0.5)
texture = ExtResource("2_48rvw")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Car"]
rotation = -1.57079
shape = SubResource("CapsuleShape2D_bj1hp")
[node name="RayCast_FL" type="RayCast2D" parent="Car"]
target_position = Vector2(256, -128)
collision_mask = 2
[node name="RayCast_FR" type="RayCast2D" parent="Car"]
target_position = Vector2(256, 128)
collision_mask = 2
[node name="resetTimer" type="Timer" parent="Car"]
wait_time = 2.0
one_shot = true
[node name="RayCast_Car" type="RayCast2D" parent="Car"]
position = Vector2(-15, 0)
target_position = Vector2(31, 0)
collision_mask = 4
[connection signal="timeout" from="Car/resetTimer" to="Car" method="_on_reset_timer_timeout"]

54
scenes/game.tscn Normal file
View file

@ -0,0 +1,54 @@
[gd_scene load_steps=2 format=3 uid="uid://cotth8e5rtioe"]
[ext_resource type="Script" path="res://scripts/game.gd" id="1_7syh4"]
[node name="Game" type="Node2D"]
script = ExtResource("1_7syh4")
[node name="Camera2D" type="Camera2D" parent="."]
[node name="speedlabel" type="Label" parent="Camera2D"]
z_index = 8
offset_left = -484.0
offset_top = 213.0
offset_right = -68.0
offset_bottom = 258.0
theme_override_font_sizes/font_size = 32
text = "125"
vertical_alignment = 1
[node name="cars" type="Node" parent="."]
[node name="minPos" type="Label" parent="."]
z_index = 7
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -20.0
offset_top = -11.5
offset_right = 20.0
offset_bottom = 11.5
grow_horizontal = 2
grow_vertical = 2
text = "Min"
horizontal_alignment = 1
vertical_alignment = 1
[node name="maxPos" type="Label" parent="."]
z_index = 7
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -20.0
offset_top = -11.5
offset_right = 20.0
offset_bottom = 11.5
grow_horizontal = 2
grow_vertical = 2
text = "Max"
horizontal_alignment = 1
vertical_alignment = 1

367
scenes/map_01.tscn Normal file

File diff suppressed because one or more lines are too long

345
scenes/map_02.tscn Normal file

File diff suppressed because one or more lines are too long

91
scenes/menu.tscn Normal file
View file

@ -0,0 +1,91 @@
[gd_scene load_steps=3 format=3 uid="uid://b1uhymisifcho"]
[ext_resource type="Script" path="res://scripts/menu.gd" id="1_fushn"]
[ext_resource type="Script" path="res://scripts/menudisplay.gd" id="2_jc4pv"]
[node name="Menu" type="Node"]
script = ExtResource("1_fushn")
[node name="MenuDisplay" type="Node2D" parent="."]
script = ExtResource("2_jc4pv")
[node name="Playerlist" type="Label" parent="MenuDisplay"]
offset_left = 131.0
offset_top = 58.0
offset_right = 745.0
offset_bottom = 572.0
theme_override_font_sizes/font_size = 32
[node name="countdown" type="Label" parent="MenuDisplay"]
offset_left = 874.0
offset_top = 122.0
offset_right = 931.0
offset_bottom = 259.0
theme_override_font_sizes/font_size = 100
text = "5"
[node name="MarginContainer" type="MarginContainer" parent="MenuDisplay"]
offset_left = 317.0
offset_top = 90.0
offset_right = 357.0
offset_bottom = 130.0
[node name="VBoxContainer_Playerlist" type="VBoxContainer" parent="MenuDisplay/MarginContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="MenuDisplay/MarginContainer/VBoxContainer_Playerlist"]
layout_mode = 2
theme_override_font_sizes/font_size = 32
text = "Press key"
uppercase = true
[node name="Label2" type="Label" parent="MenuDisplay/MarginContainer/VBoxContainer_Playerlist"]
layout_mode = 2
theme_override_font_sizes/font_size = 32
text = "to join"
uppercase = true
[node name="Label3" type="Label" parent="MenuDisplay/MarginContainer/VBoxContainer_Playerlist"]
layout_mode = 2
theme_override_font_sizes/font_size = 32
uppercase = true
[node name="Label4" type="Label" parent="MenuDisplay/MarginContainer/VBoxContainer_Playerlist"]
layout_mode = 2
theme_override_font_sizes/font_size = 32
uppercase = true
[node name="Label5" type="Label" parent="MenuDisplay/MarginContainer/VBoxContainer_Playerlist"]
layout_mode = 2
theme_override_font_sizes/font_size = 32
uppercase = true
[node name="Label6" type="Label" parent="MenuDisplay/MarginContainer/VBoxContainer_Playerlist"]
layout_mode = 2
theme_override_font_sizes/font_size = 32
uppercase = true
[node name="Label7" type="Label" parent="MenuDisplay/MarginContainer/VBoxContainer_Playerlist"]
layout_mode = 2
theme_override_font_sizes/font_size = 32
uppercase = true
[node name="Label8" type="Label" parent="MenuDisplay/MarginContainer/VBoxContainer_Playerlist"]
layout_mode = 2
theme_override_font_sizes/font_size = 32
uppercase = true
[node name="Label9" type="Label" parent="MenuDisplay/MarginContainer/VBoxContainer_Playerlist"]
layout_mode = 2
theme_override_font_sizes/font_size = 32
uppercase = true
[node name="Label10" type="Label" parent="MenuDisplay/MarginContainer/VBoxContainer_Playerlist"]
layout_mode = 2
theme_override_font_sizes/font_size = 32
uppercase = true
[node name="Timer" type="Timer" parent="."]
wait_time = 5.0
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]

192
scripts/car.gd Normal file
View file

@ -0,0 +1,192 @@
extends CharacterBody2D
#Tutorial: https://www.youtube.com/watch?v=mJ1ZfGDTMCY t=15s
const COLLISIONMASK_FINISH=3 #set in road_overlay
const COLLISIONMASK_CHECKPOINT=4 #set in road_overlay
const STANDSTILLSPEED=0.5
var wheel_base = 60*0.5
var engine_power = 350
var friction = -0.5
var drag = -0.0005
var braking = -200
var max_speed_reverse = 100
var slip_speed = 200
var traction_fast = 0.1 #traction when above slip_speed
var traction_slow = 0.5
#Automatic Steering settings
var steering_speed_slow = 50 #speed for slow steering
var steering_angle_slow = 50 #maximum angle slow speed
var steering_distance_far_slow=200
var steering_distance_close_slow=20
var steering_speed_fast = 300 #speed for fast steering
var steering_angle_fast = 5 #maximum angle fast speed
var steering_distance_far_fast=256
var steering_distance_close_fast=128
# resetCar
var resetcar_stoppedspeed = 30 #activate timer when below this speed
var resetcar_movingspeed=resetcar_stoppedspeed+10 #stop timer when above this speed
var resetcar_distance=128 #196 is roughly when car is in the middle of a two wide road
var resetcar_steerangle=120
#Variables
var acceleration = Vector2.ZERO
var steer_direction=0
var autoreset=false
@onready var ray_cast_fl: RayCast2D = $RayCast_FL
@onready var ray_cast_fr: RayCast2D = $RayCast_FR
@onready var reset_timer: Timer = $resetTimer
@onready var ray_cast_car: RayCast2D = $RayCast_Car #for tracking markers
var playerid=0
func _physics_process(delta: float) -> void:
acceleration=Vector2.ZERO
check_markers()
get_input()
apply_friction()
calculate_steering(delta)
velocity +=acceleration*delta
#velocity = transform.x * 200
#vel = move_and_slide()
move_and_slide()
if get_slide_collision_count()>0:
velocity/=2
#for i in get_slide_collision_count():
# var collision = get_slide_collision(i)
# print("Collided with: ", collision.get_collider().name)
if velocity.length() < resetcar_stoppedspeed: #moving slow, possibly crash?
if reset_timer.is_stopped():
reset_timer.start()
if velocity.length() > resetcar_movingspeed:
reset_timer.stop()
func _on_reset_timer_timeout() -> void:
print("resetting car")
autoreset=true
func apply_friction():
if velocity.length() < STANDSTILLSPEED: #standstill
velocity=Vector2.ZERO
var friction_force=velocity*friction
var drag_force=velocity*velocity.length()*drag
acceleration+=drag_force+friction_force
func get_input():
const distance_inf=1000
var distance_fl=distance_inf
var distance_fr=distance_inf
if ray_cast_fl.is_colliding():
var origin=ray_cast_fl.global_transform.origin
var collision_point = ray_cast_fl.get_collision_point()
distance_fl = origin.distance_to(collision_point)
#print("DistanceFL "+str(distance_fl))
if ray_cast_fr.is_colliding():
var origin=ray_cast_fr.global_transform.origin
var collision_point = ray_cast_fr.get_collision_point()
distance_fr = origin.distance_to(collision_point)
#print("DistanceFR "+str(distance_fr))
var distance_min= min(distance_fl,distance_fr)
var turndirection = 1 if distance_fl<distance_fr else -1
var steering_angle=constrain( remap(velocity.length(),steering_speed_fast,steering_speed_slow,steering_angle_fast,steering_angle_slow),steering_angle_fast,steering_angle_slow) #set maximum steering_angle based on speed
var steering_distance_far=constrain( remap(velocity.length(),steering_speed_fast,steering_speed_slow,steering_distance_far_fast,steering_distance_far_slow),steering_distance_far_fast,steering_distance_far_slow)
var steering_distance_close=constrain( remap(velocity.length(),steering_speed_fast,steering_speed_slow,steering_distance_close_fast,steering_distance_close_slow),steering_distance_close_fast,steering_distance_close_slow)
if distance_min<steering_distance_far: #wall close, start steering away
steer_direction = turndirection*deg_to_rad(constrain(remap(distance_min,steering_distance_far,steering_distance_close,0,steering_angle), 0,steering_angle))
else:
steer_direction=0 #drive straight
# Manual steering here
var turn = 0
if Input.is_action_pressed("ui_right"):
turn += 1
if Input.is_action_pressed("ui_left"):
turn -= 1
if turn!=0:
steer_direction = turn*deg_to_rad(steering_angle)
if Input.is_action_pressed("ui_up") or Input.is_action_pressed(Gamestate.userinput_prefix+str(playerid)):
#velocity = transform.x * 500
acceleration = transform.x * engine_power
if autoreset:
print("Cancel autoreset")
autoreset=false
if Input.is_action_pressed("ui_down"):
acceleration = transform.x * braking
if autoreset:
acceleration = transform.x * braking #drive backwards
if distance_min>=resetcar_distance: #nothing in front of car
steer_direction=resetcar_steerangle #keep steering so turn around if standing in the middle of a track
else:
steer_direction*=-1 #invert steering
else:
if steer_direction>1:
resetcar_steerangle=max(-resetcar_steerangle,+resetcar_steerangle) #calculate steering direction for next autoreset
if steer_direction<1:
resetcar_steerangle=min(-resetcar_steerangle,+resetcar_steerangle) #calculate steering direction for next autoreset
func calculate_steering(delta:float):
var rear_wheel = position - transform.x *wheel_base/2.0
var front_wheel = position + transform.x *wheel_base/2.0
rear_wheel += velocity*delta
front_wheel += velocity.rotated(steer_direction)*delta
var new_heading = (front_wheel-rear_wheel).normalized()
var traction = traction_slow
if velocity.length() > slip_speed:
traction = traction_fast
var d = new_heading.dot(velocity.normalized())
if d > 0:
velocity = velocity.lerp(new_heading * velocity.length(), traction)
elif d<0:
velocity = - new_heading * min(velocity.length(),max_speed_reverse)
rotation = new_heading.angle()
func check_markers():
if ray_cast_car.is_colliding():
#print("Marker: "+str(ray_cast_car.get_collider()))
if ray_cast_car.get_collision_mask_value(COLLISIONMASK_FINISH):
print("Player "+str(playerid)+" Finished")
if ray_cast_car.get_collision_mask_value(COLLISIONMASK_CHECKPOINT):
print("Player "+str(playerid)+" Checkpint")
func constrain(val,a,b):
var vmin=min(a,b)
var vmax=max(a,b)
return min(vmax,max(vmin,val))

16
scripts/car_node.gd Normal file
View file

@ -0,0 +1,16 @@
extends Node2D
@onready var car: CharacterBody2D = $Car
func getSpeed() -> float:
return car.velocity.length()
func getPosition():
return car.position
func setPosition(p:Vector2):
car.position=p
func setPlayerinformation(playerid, playercolor):
car.playerid=playerid
#TODO set playercolor

120
scripts/game.gd Normal file
View file

@ -0,0 +1,120 @@
extends Node2D
@onready var camera: Camera2D = $Camera2D
#@onready var car: Node2D = $car_0
@onready var cars: Node = $cars
const caroffset=32+12 #space cars on start line
var viewCarMargin=Vector2(0.1,0.1) #proportions of viewsize. 0,0 = adjust when cars are outside view, 1,1=infinite zoom out
var viewCarMargin_zoomstart=viewCarMargin+Vector2(0.1,0.1)
var zoomspeed=0.3
var zoomspeed_backup=0.05
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
var i=0
for playerkey in Gamestate.getPlayerkeys(): #create all players
var newcarscene=load("res://scenes/car.tscn")
var newcarinstance=newcarscene.instantiate()
cars.add_child(newcarinstance)
newcarinstance.setPlayerinformation(i,0)
newcarinstance.setPosition(Vector2(0,i*caroffset))
i+=1
#Load Map
var mapscene=load("res://scenes/map_01.tscn")
var mapsceneinstance=mapscene.instantiate()
add_child(mapsceneinstance)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
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
var maxPos=Vector2.ZERO
for c in cars:
var carpos = c.getPosition()
meanCarPosition+=carpos
maxCarSpeed=max(maxCarSpeed,c.getSpeed())
if displayedCarCount==0:
minPos.x=carpos.x
minPos.y=carpos.y
maxPos.x=carpos.x
maxPos.y=carpos.y
else:
minPos.x=min(minPos.x,carpos.x)
minPos.y=min(minPos.y,carpos.y)
maxPos.x=max(maxPos.x,carpos.x)
maxPos.y=max(maxPos.y,carpos.y)
displayedCarCount+=1
meanCarPosition/=displayedCarCount
#camera.position=car.getPosition()
camera.position=meanCarPosition
#rint("zoom = "+str(camera.zoom))
#camera.zoom=Vector2(1.5,1.5)
'''var allCarsInView=checkPositionInsideView(minPos) and checkPositionInsideView(maxPos)
if not allCarsInView:
camera.zoom-=Vector2(0.1*delta,0.1*delta)
else:
if camera.zoom<Vector2(1.0,1.0):
camera.zoom+=Vector2(0.1*delta,0.1*delta)
'''
var viewCarMargin_zoombackup=viewCarMargin_zoomstart+Vector2(0.1,0.1)
var viewsize = camera.get_viewport_rect().size/camera.zoom
var carSpread=Vector2(maxPos.x-minPos.x,maxPos.y-minPos.y)
var calculatedViewCarMargin=Vector2(viewsize.x-carSpread.x,viewsize.y-carSpread.y)
var mapped_zoomspeed_x=constrain(remap(calculatedViewCarMargin.x , viewCarMargin_zoomstart.x*viewsize.x,viewCarMargin.x*viewsize.x,0,zoomspeed),0,zoomspeed)
var mapped_zoomspeed_y=constrain(remap(calculatedViewCarMargin.y , viewCarMargin_zoomstart.y*viewsize.y,viewCarMargin.y*viewsize.y,0,zoomspeed),0,zoomspeed)
var mapped_zoomspeed=max(mapped_zoomspeed_x,mapped_zoomspeed_y)
print("calculatedViewCarMargin="+str(calculatedViewCarMargin))
print("viewCarMargin_zoomstart*viewsize="+str(viewCarMargin_zoomstart*viewsize))
print("viewCarMargin_zoombackup*viewsize="+str(viewCarMargin_zoombackup*viewsize))
if calculatedViewCarMargin.x<(viewCarMargin_zoomstart.x*viewsize.x) or calculatedViewCarMargin.y<(viewCarMargin_zoomstart.y*viewsize.y): #cars not in view
camera.zoom-=Vector2(mapped_zoomspeed*delta,mapped_zoomspeed*delta)
elif calculatedViewCarMargin.x>(viewCarMargin_zoombackup.x*viewsize.x) and calculatedViewCarMargin.y>(viewCarMargin_zoombackup.y*viewsize.y): #cars in view again
if camera.zoom.x<1.0:
camera.zoom+=Vector2(zoomspeed_backup*delta,zoomspeed_backup*delta)
$minPos.position=minPos
$maxPos.position=maxPos
$Camera2D/speedlabel.text=str(carSpread)
#$Camera2D/speedlabel.text=str(round(maxCarSpeed))
func _input(ev):
#if ev is InputEventKey and
if Input.is_action_just_pressed("ui_cancel"):
get_tree().change_scene_to_file("res://scenes/menu.tscn")
func checkPositionInsideView(checkpos: Vector2) -> bool:
var viewsize = camera.get_viewport_rect().size
var canvas_pos = camera.get_viewport().get_canvas_transform().affine_inverse() * -checkpos
print("cp="+str(canvas_pos) + " viewsize="+str(viewsize))
if canvas_pos.x < 0 and canvas_pos.x > -viewsize.x:
if canvas_pos.y < 0 and canvas_pos.y > -viewsize.y:
return true
return false
func constrain(val,a,b):
var vmin=min(a,b)
var vmax=max(a,b)
return min(vmax,max(vmin,val))

40
scripts/gamestate.gd Normal file
View file

@ -0,0 +1,40 @@
extends Node
#var playerkeys: Array[int] = []
var players: Array[Player] = []
var userinput_prefix="inputP"
func addPlayer(key:int):
if not getPlayerkeys().has(key):
#playerkeys.append(key)
players.append(Player.new(key,len(players)))
#print("Added Key"+str(key))
#print("List:"+str(getPlayerkeys()))
func removeAllPlayers():
players=[]
func getPlayerkeys() -> Array[int]:
var playerkeys: Array[int] = []
for player in players:
playerkeys.append(player.inputkey)
return playerkeys
class Player:
var inputkey:int
var color:Color
func _init(key:int, i:int=-1):
inputkey=key
var sat = 0.8
var val = 0.5
if i<0:
color=Color.from_hsv(randf_range(0.0,1.0), sat,val,1.0)
else:
color=Color.from_hsv(fmod(0.3*i,1.0), sat,val,1.0)
print("i is "+str(i)+" h="+str(fmod(0.3*i,1.0))+" assigned color "+str(color))

56
scripts/menu.gd Normal file
View file

@ -0,0 +1,56 @@
extends Node
@onready var countdown: Label = $MenuDisplay/countdown
func _ready():
removeAssignedKeys()
Gamestate.removeAllPlayers()
func assignKeys():
var i=0
for playerkey in Gamestate.getPlayerkeys():
InputMap.add_action(Gamestate.userinput_prefix+str(i))
var ev = InputEventKey.new()
ev.keycode=playerkey
InputMap.action_add_event(Gamestate.userinput_prefix+str(i), ev)
i+=1
func removeAssignedKeys():
for action in InputMap.get_actions():
if action.get_basename().begins_with(Gamestate.userinput_prefix):
print("Removed Action "+str(action.get_basename()))
InputMap.erase_action(action)
func _unhandled_key_input(event: InputEvent) -> void:
if event is InputEventKey:
if event.pressed:
#print("Key keycode:"+str(event.keycode))
Gamestate.addPlayer(event.keycode)
$MenuDisplay.update_playerlist(Gamestate.players)
if len(Gamestate.getPlayerkeys())>=1:
$Timer.start()
else:
$Timer.stop()
func _on_timer_timeout() -> void:
print("Game starting")
get_tree().change_scene_to_file("res://scenes/game.tscn")
$Timer.stop()
assignKeys()
func _process(delta: float) -> void:
if $Timer.is_stopped() or $Timer.time_left>3.5:
$MenuDisplay.updateCountdown(-1) #do not display countdown
else:
$MenuDisplay.updateCountdown(round($Timer.time_left)) #update countdown time
func _input(ev):
#if ev is InputEventKey and
if Input.is_action_just_pressed("ui_cancel"):
get_tree().quit()

36
scripts/menudisplay.gd Normal file
View file

@ -0,0 +1,36 @@
extends Node2D
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func updateCountdown(t):
if (t<0):
$countdown.visible=false
else:
$countdown.visible=true
$countdown.text=str(t)
func update_playerlist(players:Array[Gamestate.Player]):
$Playerlist.text=""
var Playerlabels=$MarginContainer/VBoxContainer_Playerlist.get_children()
var i=0
for label in Playerlabels:
#print(type_string(typeof(label)))
if i<len(players):
var p=players[i]
label.text=str(OS.get_keycode_string(p.inputkey))
label.set("theme_override_colors/font_color",p.color)
else:
label.text=""
i+=1
#for p in players:
#$Playerlist.text+=str(OS.get_keycode_string(p.inputkey))+"\n"
#todo add playercolor here

BIN
sprites/car.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

BIN
sprites/car.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

34
sprites/car.png.import Normal file
View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c2wq5xkfmca1r"
path="res://.godot/imported/car.png-b2ca7bee34d0a72d15f9ed0bc2f7996f.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://sprites/car.png"
dest_files=["res://.godot/imported/car.png-b2ca7bee34d0a72d15f9ed0bc2f7996f.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View file

@ -0,0 +1,9 @@
#!/bin/sh
mkdir tmp
for i in {0..32}; do magick road_1x1.xcf["${i}"] "tmp/road1x1_${i}.png"; done
for i in {0..32}; do magick road_2x2.xcf["${i}"] "tmp/road2x2_${i}.png"; done
for i in {0..32}; do magick markings_1x1.xcf["${i}"] "tmp/markings1x1_${i}.png"; done
magick convert tmp/road1x1_{0..7}.png +append \( tmp/road1x1_{8..15}.png +append \) -append \( tmp/road1x1_{16..23}.png +append \) -append \( tmp/road1x1_{24..31}.png +append \) -append spritesheet_road1x1.png
#magick convert erstereihe +append \( zweite reihe +append \) -append \( drittereihe +append \) -append out.png
magick convert tmp/road2x2_{0..3}.png +append \( tmp/road2x2_{4..7}.png +append \) -append \( tmp/road2x2_{8..11}.png +append \) -append \( tmp/road2x2_{12..15}.png +append \) -append spritesheet_road2x2.png
magick convert tmp/markings1x1_{0..7}.png +append \( tmp/markings1x1_{8..15}.png +append \) -append \( tmp/markings1x1_{16..23}.png +append \) -append \( tmp/markings1x1_{24..31}.png +append \) -append spritesheet_markings1x1.png

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,24 @@
[gd_resource type="TileSet" load_steps=3 format=3 uid="uid://fy1cu3bt11db"]
[ext_resource type="Texture2D" uid="uid://cj7noshq5wkuu" path="res://sprites/spritesheet_road/spritesheet_road1x1.png" id="1_5axip"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_5wrcn"]
texture = ExtResource("1_5axip")
texture_region_size = Vector2i(128, 128)
0:0/0 = 0
2:0/0 = 0
4:0/0 = 0
6:0/0 = 0
1:1/0 = 0
3:1/0 = 0
4:1/0 = 0
6:1/0 = 0
0:2/0 = 0
3:2/0 = 0
5:2/0 = 0
7:2/0 = 0
1:3/0 = 0
[resource]
tile_size = Vector2i(128, 128)
sources/2 = SubResource("TileSetAtlasSource_5wrcn")

View file

@ -0,0 +1,19 @@
[gd_resource type="TileSet" load_steps=3 format=3 uid="uid://dqj1nt8840fpl"]
[ext_resource type="Texture2D" uid="uid://cd0r2a2yf42my" path="res://sprites/spritesheet_road/spritesheet_markings1x1.png" id="2_j34ny"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_3gx66"]
texture = ExtResource("2_j34ny")
texture_region_size = Vector2i(128, 128)
0:0/0 = 0
0:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-64, -35, 56, -35, 56, -13, -64, -13)
1:0/0 = 0
1:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-64, -35, 64, -35, 64, -13, -64, -13)
[resource]
tile_size = Vector2i(128, 128)
physics_layer_0/collision_layer = 4
physics_layer_0/collision_mask = 4
physics_layer_1/collision_layer = 8
physics_layer_1/collision_mask = 8
sources/1 = SubResource("TileSetAtlasSource_3gx66")

Binary file not shown.

After

Width:  |  Height:  |  Size: 513 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cd0r2a2yf42my"
path="res://.godot/imported/spritesheet_markings1x1.png-318cf7d4994901cc2453850644e375a8.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://sprites/spritesheet_road/spritesheet_markings1x1.png"
dest_files=["res://.godot/imported/spritesheet_markings1x1.png-318cf7d4994901cc2453850644e375a8.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b2v5npg0c34q7"
path="res://.godot/imported/spritesheet_road.png-49b5a496005015fda3b690973524b950.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://sprites/spritesheet_road/spritesheet_road.png"
dest_files=["res://.godot/imported/spritesheet_road.png-49b5a496005015fda3b690973524b950.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cj7noshq5wkuu"
path="res://.godot/imported/spritesheet_road1x1.png-341814343481e7df4fffd6be2a184048.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://sprites/spritesheet_road/spritesheet_road1x1.png"
dest_files=["res://.godot/imported/spritesheet_road1x1.png-341814343481e7df4fffd6be2a184048.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View file

@ -0,0 +1,54 @@
[gd_resource type="TileSet" load_steps=5 format=3 uid="uid://dfo0ra568q52r"]
[ext_resource type="Texture2D" uid="uid://dphq0r5wk8a8p" path="res://sprites/spritesheet_road - Kopie/spritesheet_road2x2.png" id="1_fh6vp"]
[ext_resource type="Texture2D" uid="uid://cj7noshq5wkuu" path="res://sprites/spritesheet_road - Kopie/spritesheet_road1x1.png" id="2_p3txp"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_bl4c0"]
texture = ExtResource("1_fh6vp")
texture_region_size = Vector2i(128, 128)
2:0/size_in_atlas = Vector2i(2, 2)
2:0/0 = 0
6:0/size_in_atlas = Vector2i(2, 2)
6:0/0 = 0
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_m1hpr"]
texture = ExtResource("2_p3txp")
texture_region_size = Vector2i(128, 128)
1:0/0 = 0
1:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(52, -64, 52, 64, 58, 64, 58, -64)
3:0/0 = 0
3:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(52, 64, 50.3181, 48.2707, 46.3808, 33.1517, 40.8687, 17.8751, 32.0492, 1.81114, 16.7727, -16.3002, 0.866196, -30.0019, -16.1427, -39.4513, -33.3092, -46.2234, -47.7983, -50.0031, -64, -51.893, -64, -57.7201, -47.9557, -56.6177, -31.2618, -52.6804, -13.7804, -45.7509, 5.74839, -35.0416, 21.4974, -20.8674, 37.7189, -1.65364, 46.6958, 15.5128, 52.8379, 31.7343, 56.3027, 47.3258, 57.5627, 64)
5:0/0 = 0
5:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-57, 64, -59.295, 59.61, -64, 57.2477, -64, 52.3655, -55.0428, 55.8303, -52.3655, 64)
0:1/0 = 0
0:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(52, -64, 52, 64, 58, 64, 58, -64)
0:1/0/physics_layer_0/polygon_1/points = PackedVector2Array(-52, -64, -52, 64, -58, 64, -58, -64)
2:1/0 = 0
2:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(52, 64, 50.3181, 48.2707, 46.3808, 33.1517, 40.8687, 17.8751, 32.0492, 1.81114, 16.7727, -16.3002, 0.866196, -30.0019, -16.1427, -39.4513, -33.3092, -46.2234, -47.7983, -50.0031, -64, -51.893, -64, -57.7201, -47.9557, -56.6177, -31.2618, -52.6804, -13.7804, -45.7509, 5.74839, -35.0416, 21.4974, -20.8674, 37.7189, -1.65364, 46.6958, 15.5128, 52.8379, 31.7343, 56.3027, 47.3258, 57.5627, 64)
2:1/0/physics_layer_0/polygon_1/points = PackedVector2Array(-57.7201, 64, -59.295, 59.61, -64, 57.2477, -64, 52.3655, -55.0428, 55.8303, -52.3655, 64)
4:1/0 = 0
4:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(52, -64, 52, 64, 58, 64, 58, -64)
4:1/0/physics_layer_0/polygon_1/points = PackedVector2Array(-57, 64, -59.295, 59.61, -64, 57.2477, -64, 52.3655, -55.0428, 55.8303, -52.3655, 64)
5:1/0 = 0
5:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(52, -64, 52, 64, 58, 64, 58, -64)
5:1/0/physics_layer_0/polygon_1/points = PackedVector2Array(-57, 64, -59.295, 59.61, -64, 57.2477, -64, 52.3655, -55.0428, 55.8303, -52.3655, 64)
7:1/0 = 0
7:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(52, -64, 52, -48, 48, -32, 40, -16, 37, 0, 40, 16, 48, 32, 52, 48, 52, 64, 58, 64, 58, 48, 54, 32, 43, 0, 54, -32, 58, -48, 58, -64)
7:1/0/physics_layer_0/polygon_1/points = PackedVector2Array(-52, -64, -52, -48, -48, -32, -40, -16, -37, 0, -40, 16, -48, 32, -52, 48, -52, 64, -58, 64, -58, 48, -54, 32, -43, 0, -54, -32, -58, -48, -58, -64)
1:2/0 = 0
1:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(-64, -9.69697, -9.69697, -64, -17.4545, -64, -64, -17.4545)
1:2/0/physics_layer_0/polygon_1/points = PackedVector2Array(64, 9.69697, 9.69697, 64, 18.7475, 64, 64, 18.7475)
3:2/0 = 0
3:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(17.4545, -64, -64, 17.4545, -64, 9.69697, 9.69697, -64)
5:2/0 = 0
5:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(-52.3636, 64, -52.3636, -16.1616, -49.7778, -22.6263, -45.899, -29.0909, -9.69697, -64, -18.7475, -64, -51.0707, -31.6768, -56.2424, -23.9192, -57.5354, -16.1616, -57.5354, 64)
5:2/0/physics_layer_0/polygon_1/points = PackedVector2Array(57.5354, 64, 57.5354, 31.6768, 64, 17.4545, 64, 9.69697, 56.2424, 17.4545, 52.3636, 27.798, 52.3636, 32.9697, 52.3636, 64)
6:2/0 = 0
6:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(-52.3636, 64, -52.3636, -16.1616, -49.7778, -22.6263, -45.899, -29.0909, -9.69697, -64, -18.7475, -64, -51.0707, -31.6768, -56.2424, -23.9192, -57.5354, -16.1616, -57.5354, 64)
6:2/0/physics_layer_0/polygon_1/points = PackedVector2Array(57.5354, 64, 57.5354, 31.6768, 64, 17.4545, 64, 9.69697, 56.2424, 17.4545, 52.3636, 27.798, 52.3636, 32.9697, 52.3636, 64)
[resource]
tile_size = Vector2i(128, 128)
physics_layer_0/collision_layer = 3
sources/2 = SubResource("TileSetAtlasSource_m1hpr")
sources/0 = SubResource("TileSetAtlasSource_bl4c0")

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dphq0r5wk8a8p"
path="res://.godot/imported/spritesheet_road2x2.png-c1b2a174c746e568db750b4cb20e73d0.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://sprites/spritesheet_road/spritesheet_road2x2.png"
dest_files=["res://.godot/imported/spritesheet_road2x2.png-c1b2a174c746e568db750b4cb20e73d0.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1