add road startmarker

This commit is contained in:
interfisch 2024-12-28 23:58:52 +01:00
parent 45e337b295
commit 09043f2794
4 changed files with 54 additions and 9 deletions

View file

@ -1,9 +1,10 @@
[gd_scene load_steps=10 format=3 uid="uid://cu7olkgkyy2tq"]
[gd_scene load_steps=11 format=3 uid="uid://cu7olkgkyy2tq"]
[ext_resource type="Texture2D" uid="uid://csknopg1cbqbq" path="res://sprites/background/green_gradient.png" id="1_nq5g7"]
[ext_resource type="Texture2D" uid="uid://5l1t6nyjn022" path="res://sprites/road/road_border.png" id="3_mivmq"]
[ext_resource type="Script" path="res://scripts/roadborder.gd" id="4_8hrwh"]
[ext_resource type="Texture2D" uid="uid://gydxil7qf7jc" path="res://sprites/road/road_trim.png" id="5_5a0eo"]
[ext_resource type="Texture2D" uid="uid://bu1vuswjdjub3" path="res://sprites/road/road_startmarker.png" id="6_bauvc"]
[ext_resource type="Script" path="res://scripts/generate_road_polyon.gd" id="6_vdo8x"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_daqun"]
@ -31,7 +32,7 @@ texture = ExtResource("1_nq5g7")
[node name="Line2D2_right" type="Line2D" parent="."]
z_index = 1
points = PackedVector2Array(-256, 256, 320, 256, 512, 192, 640, 64, 896, 64, 1024, 0, 1088, -128, 1088, -512)
points = PackedVector2Array(-256, 64, 640, 64, 896, 64, 1024, 0, 1088, -128, 1088, -512)
width = 6.0
texture = ExtResource("3_mivmq")
texture_mode = 1
@ -47,7 +48,7 @@ texture_mode = 1
[node name="Line2D2_left" type="Line2D" parent="."]
z_index = 1
points = PackedVector2Array(-256, -256, 320, -256, 512, -192, 640, -64, 832, -64, 960, -192, 960, -384)
points = PackedVector2Array(-256, -64, 640, -64, 832, -64, 960, -192, 960, -384)
width = 6.0
texture = ExtResource("3_mivmq")
texture_mode = 1
@ -80,7 +81,7 @@ texture_mode = 1
[node name="Line2D2_right3" type="Line2D" parent="."]
z_index = 1
points = PackedVector2Array(1088, -512, 1088, -768, 576, -768, 576, -576, 384, -574, 192, -640, -64, -640, -256, -832, -352, -896, 64, -896, 320, -768, 512, -768, 768, -832, 896, -896, 960, -960, 1024, -1088, 960, -1216, 896, -1280, 576, -1280, 448, -1216, 384, -1152, 256, -1088, 128, -1152, -640, -1152, -704, -1088, -704, -896, -640, -768, -704, -640, -704, -448, -640, -320, -512, -272, 768, -272, 864, -320, 928, -416, 960, -416, 960, -384)
points = PackedVector2Array(1088, -512, 1088, -768, 576, -768, 576, -576, 384, -574, 192, -640, -64, -640, -256, -832, -352, -896, 64, -896, 320, -768, 512, -768, 768, -832, 896, -896, 960, -960, 1024, -1088, 960, -1216, 896, -1280, 736, -1312, 576, -1280, 448, -1216, 384, -1152, 304, -1088, 208, -1104, 128, -1152, -640, -1152, -704, -1088, -704, -896, -640, -768, -704, -640, -704, -448, -640, -320, -512, -272, 768, -272, 864, -320, 928, -416, 960, -416, 960, -384)
width = 6.0
texture = ExtResource("3_mivmq")
texture_mode = 1
@ -143,3 +144,6 @@ shape = SubResource("RectangleShape2D_82iti")
z_index = 20
texture_filter = 1
position = Vector2(0, 1)
[node name="startmarker" type="Sprite2D" parent="."]
texture = ExtResource("6_bauvc")

View file

@ -13,8 +13,8 @@ extends Node2D
const caroffset= 32+4 #space cars on start line
const caroffset_side= 32+16
const caroffset_rear= 64
const caroffset_side= 16
const caroffset_rear= 32+16
var viewCarMargin=Vector2(0.7,0.7) #1=zoom out full speed when car is at border. 0.9 zoom out full speed when car is 10% away from border
var viewCarMargin_zoomstart=viewCarMargin-Vector2(0.2,0.2) #start zooming
@ -67,12 +67,19 @@ func _ready() -> void:
newcarinstance.setPlayerinformation(i,player.color,player)
#newcarinstance.setPosition(Vector2(0,ceil(i/2.0)*(fmod(i,2)-0.5)*2.0*caroffset)) #all in a row, alternating up/down
newcarinstance.setPosition(Vector2(caroffset_rear*-1*i_position,0)) #TODO, nicer start placement
#caroffset_rear
#caroffset_side
newcarinstance.setPosition(Vector2(caroffset_rear*-1*i_position,(fmod(i_position,2)-0.5)*2.0*caroffset_side))
newcarinstance.setCheckpoints(checkpoints,Gamestate.getRounds())
newcarinstance.getCharacterBody().car_finished.connect(_on_car_finished)
var startmarker:Sprite2D=mapsceneinstance.get_node("startmarker")
if startmarker != null:
var newmarker:Sprite2D=startmarker.duplicate()
newmarker.position=newcarinstance.getPosition()
mapsceneinstance.add_child(newmarker)
print("added startmarker pos="+str(newmarker.position))
startmarker.queue_free() #remove template marker
print("i_position="+str(i_position)+" carpos is ="+str(newcarinstance.getPosition())+" instancepos="+str(newcarinstance.position)+" colori="+str(player.colori)+" color="+str(player.color))
i+=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 649 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bu1vuswjdjub3"
path="res://.godot/imported/road_startmarker.png-e78594634f72dcc0772ba7f09c3e8c39.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://sprites/road/road_startmarker.png"
dest_files=["res://.godot/imported/road_startmarker.png-e78594634f72dcc0772ba7f09c3e8c39.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