add car color change based on player
This commit is contained in:
parent
603358adee
commit
e370a4698f
11 changed files with 89 additions and 44 deletions
|
@ -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_node.gd" id="1_0tin3"]
|
||||||
[ext_resource type="Script" path="res://scripts/car.gd" id="1_i5tet"]
|
[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"]
|
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_bj1hp"]
|
||||||
radius = 8.0
|
radius = 8.0
|
||||||
|
@ -14,10 +15,15 @@ script = ExtResource("1_0tin3")
|
||||||
[node name="Car" type="CharacterBody2D" parent="."]
|
[node name="Car" type="CharacterBody2D" parent="."]
|
||||||
script = ExtResource("1_i5tet")
|
script = ExtResource("1_i5tet")
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="Car"]
|
[node name="sprite_features" type="Sprite2D" parent="Car"]
|
||||||
z_index = 10
|
z_index = 10
|
||||||
scale = Vector2(0.5, 0.5)
|
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"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Car"]
|
||||||
rotation = -1.57079
|
rotation = -1.57079
|
||||||
|
|
|
@ -14,41 +14,6 @@ offset_top = 213.0
|
||||||
offset_right = -68.0
|
offset_right = -68.0
|
||||||
offset_bottom = 258.0
|
offset_bottom = 258.0
|
||||||
theme_override_font_sizes/font_size = 32
|
theme_override_font_sizes/font_size = 32
|
||||||
text = "125"
|
|
||||||
vertical_alignment = 1
|
vertical_alignment = 1
|
||||||
|
|
||||||
[node name="cars" type="Node" parent="."]
|
[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
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
extends Node2D
|
extends Node2D
|
||||||
@onready var car: CharacterBody2D = $Car
|
@onready var car: CharacterBody2D = $Car
|
||||||
|
@onready var carbody: Sprite2D = $Car/sprite_body
|
||||||
|
|
||||||
|
|
||||||
func getSpeed() -> float:
|
func getSpeed() -> float:
|
||||||
|
@ -14,3 +15,4 @@ func setPosition(p:Vector2):
|
||||||
func setPlayerinformation(playerid, playercolor):
|
func setPlayerinformation(playerid, playercolor):
|
||||||
car.playerid=playerid
|
car.playerid=playerid
|
||||||
#TODO set playercolor
|
#TODO set playercolor
|
||||||
|
carbody.modulate = playercolor#Color(0, 0, 1)
|
||||||
|
|
|
@ -16,11 +16,12 @@ var zoomspeed_backup=0.05
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
var i=0
|
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 newcarscene=load("res://scenes/car.tscn")
|
||||||
var newcarinstance=newcarscene.instantiate()
|
var newcarinstance=newcarscene.instantiate()
|
||||||
cars.add_child(newcarinstance)
|
cars.add_child(newcarinstance)
|
||||||
newcarinstance.setPlayerinformation(i,0)
|
newcarinstance.setPlayerinformation(i,player.color)
|
||||||
newcarinstance.setPosition(Vector2(0,i*caroffset))
|
newcarinstance.setPosition(Vector2(0,i*caroffset))
|
||||||
i+=1
|
i+=1
|
||||||
|
|
||||||
|
@ -83,9 +84,7 @@ func _process(delta: float) -> void:
|
||||||
if camera.zoom.x<1.0:
|
if camera.zoom.x<1.0:
|
||||||
camera.zoom+=Vector2(zoomspeed_backup*delta,zoomspeed_backup*delta)
|
camera.zoom+=Vector2(zoomspeed_backup*delta,zoomspeed_backup*delta)
|
||||||
|
|
||||||
$minPos.position=minPos
|
#$Camera2D/speedlabel.text=str(carSpread)
|
||||||
$maxPos.position=maxPos
|
|
||||||
$Camera2D/speedlabel.text=str(carSpread)
|
|
||||||
|
|
||||||
#$Camera2D/speedlabel.text=str(round(maxCarSpeed))
|
#$Camera2D/speedlabel.text=str(round(maxCarSpeed))
|
||||||
|
|
||||||
|
|
|
@ -16,12 +16,17 @@ func addPlayer(key:int):
|
||||||
func removeAllPlayers():
|
func removeAllPlayers():
|
||||||
players=[]
|
players=[]
|
||||||
|
|
||||||
|
|
||||||
func getPlayerkeys() -> Array[int]:
|
func getPlayerkeys() -> Array[int]:
|
||||||
var playerkeys: Array[int] = []
|
var playerkeys: Array[int] = []
|
||||||
for player in players:
|
for player in players:
|
||||||
playerkeys.append(player.inputkey)
|
playerkeys.append(player.inputkey)
|
||||||
return playerkeys
|
return playerkeys
|
||||||
|
|
||||||
|
|
||||||
|
func getPlayers() -> Array[Player]:
|
||||||
|
return players
|
||||||
|
|
||||||
class Player:
|
class Player:
|
||||||
var inputkey:int
|
var inputkey:int
|
||||||
var color:Color
|
var color:Color
|
||||||
|
|
BIN
sprites/car.xcf
Normal file
BIN
sprites/car.xcf
Normal file
Binary file not shown.
BIN
sprites/car01.png
Normal file
BIN
sprites/car01.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.5 KiB |
BIN
sprites/car_body.png
Normal file
BIN
sprites/car_body.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
34
sprites/car_body.png.import
Normal file
34
sprites/car_body.png.import
Normal file
|
@ -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
|
BIN
sprites/car_features.png
Normal file
BIN
sprites/car_features.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
34
sprites/car_features.png.import
Normal file
34
sprites/car_features.png.import
Normal file
|
@ -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
|
Loading…
Reference in a new issue