From 09043f2794686964c4be4516661926719ffe849f Mon Sep 17 00:00:00 2001 From: Fisch Date: Sat, 28 Dec 2024 23:58:52 +0100 Subject: [PATCH] add road startmarker --- scenes/map_05.tscn | 12 +++++--- scripts/game.gd | 17 ++++++++---- sprites/road/road_startmarker.png | Bin 0 -> 649 bytes sprites/road/road_startmarker.png.import | 34 +++++++++++++++++++++++ 4 files changed, 54 insertions(+), 9 deletions(-) create mode 100644 sprites/road/road_startmarker.png create mode 100644 sprites/road/road_startmarker.png.import diff --git a/scenes/map_05.tscn b/scenes/map_05.tscn index 1e09363..ee55897 100644 --- a/scenes/map_05.tscn +++ b/scenes/map_05.tscn @@ -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") diff --git a/scripts/game.gd b/scripts/game.gd index 05d4757..d85bb93 100644 --- a/scripts/game.gd +++ b/scripts/game.gd @@ -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 diff --git a/sprites/road/road_startmarker.png b/sprites/road/road_startmarker.png new file mode 100644 index 0000000000000000000000000000000000000000..f6542bca8ecc1e22eb256e3be4453c39a2269d9a GIT binary patch literal 649 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3HE3&8=%;U|?*?baoE#baqxKD9TUE%t>Wn z(3n^|(bnUzgGAf?WnQjYd}4wxCoC-8)ZJwONoR|!Qg;yB(aDw> z`fIux!&wB6X{-(GoLQx{dq(r~AG_N7-9#ZLG!@%5(D`EyS5aoZTDJTdxwL@{aOox?@^o4XbYofmKy30+*H z_y>bXTN zL(!GhPo*C`5SXD6{B76q-RxDrzvcTbueZOPUUb%e->b{OXkkn8c6VX;4}uH!E}sk( z;VkfoEM{Qf76xHPhFNnYfP(BLp1!W^FL-3c%p_$LF316eBuiW)N}Tg^b5rw57@Uhz z6H8K46v{J8G8EiBeFMT9`NV;W55(M0bFi{8T-ItN*LSX4VN zIkex?UisjYw$p^VyW3tJE$(_+Sr+&GLv@+-4+qPmm!ex(fo5QU53eG=KH6O0Ag17% Z6)K~{`>