diff --git a/scenes/car.tscn b/scenes/car.tscn index 359c9d0..6b89f76 100644 --- a/scenes/car.tscn +++ b/scenes/car.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=5 format=3 uid="uid://0g7qqh7naniv"] +[gd_scene load_steps=6 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"] +[ext_resource type="Texture2D" uid="uid://mqdujngircok" path="res://sprites/car_features.png" id="3_ts6mm"] +[ext_resource type="Texture2D" uid="uid://e5aeyl47wi8p" path="res://sprites/car_body.png" id="4_lps13"] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_bj1hp"] radius = 8.0 @@ -14,10 +15,15 @@ script = ExtResource("1_0tin3") [node name="Car" type="CharacterBody2D" parent="."] script = ExtResource("1_i5tet") -[node name="Sprite2D" type="Sprite2D" parent="Car"] +[node name="sprite_features" type="Sprite2D" parent="Car"] z_index = 10 scale = Vector2(0.5, 0.5) -texture = ExtResource("2_48rvw") +texture = ExtResource("3_ts6mm") + +[node name="sprite_body" type="Sprite2D" parent="Car"] +z_index = 10 +scale = Vector2(0.5, 0.5) +texture = ExtResource("4_lps13") [node name="CollisionShape2D" type="CollisionShape2D" parent="Car"] rotation = -1.57079 diff --git a/scenes/game.tscn b/scenes/game.tscn index 7c30e91..341d834 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -14,41 +14,6 @@ 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 diff --git a/scripts/car_node.gd b/scripts/car_node.gd index f2de8a5..394e33f 100644 --- a/scripts/car_node.gd +++ b/scripts/car_node.gd @@ -1,5 +1,6 @@ extends Node2D @onready var car: CharacterBody2D = $Car +@onready var carbody: Sprite2D = $Car/sprite_body func getSpeed() -> float: @@ -14,3 +15,4 @@ func setPosition(p:Vector2): func setPlayerinformation(playerid, playercolor): car.playerid=playerid #TODO set playercolor + carbody.modulate = playercolor#Color(0, 0, 1) diff --git a/scripts/game.gd b/scripts/game.gd index 8f964b6..559f295 100644 --- a/scripts/game.gd +++ b/scripts/game.gd @@ -16,11 +16,12 @@ 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 + #for playerkey in Gamestate.getPlayerkeys(): #create all players + for player in Gamestate.getPlayers(): var newcarscene=load("res://scenes/car.tscn") var newcarinstance=newcarscene.instantiate() cars.add_child(newcarinstance) - newcarinstance.setPlayerinformation(i,0) + newcarinstance.setPlayerinformation(i,player.color) newcarinstance.setPosition(Vector2(0,i*caroffset)) i+=1 @@ -83,9 +84,7 @@ func _process(delta: float) -> void: 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(carSpread) #$Camera2D/speedlabel.text=str(round(maxCarSpeed)) diff --git a/scripts/gamestate.gd b/scripts/gamestate.gd index af3ab14..7795d2c 100644 --- a/scripts/gamestate.gd +++ b/scripts/gamestate.gd @@ -16,12 +16,17 @@ func addPlayer(key:int): func removeAllPlayers(): players=[] + func getPlayerkeys() -> Array[int]: var playerkeys: Array[int] = [] for player in players: playerkeys.append(player.inputkey) return playerkeys + +func getPlayers() -> Array[Player]: + return players + class Player: var inputkey:int var color:Color diff --git a/sprites/car.xcf b/sprites/car.xcf new file mode 100644 index 0000000..05877ae Binary files /dev/null and b/sprites/car.xcf differ diff --git a/sprites/car01.png b/sprites/car01.png new file mode 100644 index 0000000..7da50eb Binary files /dev/null and b/sprites/car01.png differ diff --git a/sprites/car_body.png b/sprites/car_body.png new file mode 100644 index 0000000..eabfbd2 Binary files /dev/null and b/sprites/car_body.png differ diff --git a/sprites/car_body.png.import b/sprites/car_body.png.import new file mode 100644 index 0000000..599836f --- /dev/null +++ b/sprites/car_body.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://e5aeyl47wi8p" +path="res://.godot/imported/car_body.png-f9c20cebf3cba852ae8dc4138d118e5d.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://sprites/car_body.png" +dest_files=["res://.godot/imported/car_body.png-f9c20cebf3cba852ae8dc4138d118e5d.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 diff --git a/sprites/car_features.png b/sprites/car_features.png new file mode 100644 index 0000000..7a05d61 Binary files /dev/null and b/sprites/car_features.png differ diff --git a/sprites/car_features.png.import b/sprites/car_features.png.import new file mode 100644 index 0000000..9faa5ad --- /dev/null +++ b/sprites/car_features.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://mqdujngircok" +path="res://.godot/imported/car_features.png-6af3e9800dc5060b0e97dabc6c3181d0.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://sprites/car_features.png" +dest_files=["res://.godot/imported/car_features.png-6af3e9800dc5060b0e97dabc6c3181d0.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