Compare commits
7 Commits
056e346a96
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 39451c5553 | |||
|
|
9726fb8fcf | ||
| 4565755868 | |||
| d439d67813 | |||
| a8280df733 | |||
| 1b29065bf8 | |||
| b64430e10b |
@@ -1,6 +1,6 @@
|
|||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
signal race_started
|
signal completed()
|
||||||
|
|
||||||
export (int) var delay = 3
|
export (int) var delay = 3
|
||||||
var timer
|
var timer
|
||||||
@@ -32,7 +32,7 @@ func _timeout():
|
|||||||
elif time_left == 0:
|
elif time_left == 0:
|
||||||
# Go !
|
# Go !
|
||||||
$Number.set_text("GO")
|
$Number.set_text("GO")
|
||||||
emit_signal("race_started")
|
emit_signal("completed")
|
||||||
else:
|
else:
|
||||||
$Number.set_text("%d" % time_left)
|
$Number.set_text("%d" % time_left)
|
||||||
|
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
[gd_scene load_steps=4 format=2]
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://Countdown.gd" type="Script" id=1]
|
[ext_resource path="res://Countdown.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://Oswald-Bold.otf" type="DynamicFontData" id=2]
|
[ext_resource path="res://assets/Oswald-Bold.otf" type="DynamicFontData" id=2]
|
||||||
|
|
||||||
[sub_resource type="DynamicFont" id=1]
|
[sub_resource type="DynamicFont" id=1]
|
||||||
size = 255
|
size = 255
|
||||||
outline_size = 20
|
outline_size = 8
|
||||||
outline_color = Color( 0.145098, 0.145098, 0.145098, 1 )
|
outline_color = Color( 0.129412, 0.129412, 0.129412, 1 )
|
||||||
use_filter = true
|
use_filter = true
|
||||||
font_data = ExtResource( 2 )
|
font_data = ExtResource( 2 )
|
||||||
|
|
||||||
|
|||||||
17
Global.gd
17
Global.gd
@@ -1,5 +1,20 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
|
signal laps_changed(value)
|
||||||
|
|
||||||
|
enum InputMode { MOUSE, KEYBOARD }
|
||||||
|
enum GameMode { TRAIN, EASY }
|
||||||
|
enum PlayerSkin { CAR, POLICE, BUS }
|
||||||
|
|
||||||
var race_started = false
|
var race_started = false
|
||||||
var laps = 0
|
var laps = 0 setget set_laps
|
||||||
|
|
||||||
|
func set_laps(value):
|
||||||
|
laps = value
|
||||||
|
emit_signal("laps_changed", value)
|
||||||
|
|
||||||
|
var settings = {
|
||||||
|
"input_mode": InputMode.MOUSE,
|
||||||
|
"game_mode": GameMode.EASY,
|
||||||
|
"player_skin": PlayerSkin.CAR,
|
||||||
|
}
|
||||||
|
|||||||
2
Gui.gd
2
Gui.gd
@@ -4,7 +4,7 @@ onready var lap_counter = get_node("Laps/Value")
|
|||||||
|
|
||||||
# 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():
|
func _ready():
|
||||||
pass # Replace with function body.
|
Global.connect("laps_changed", self, "_on_lap_completed")
|
||||||
|
|
||||||
func _on_lap_completed(laps):
|
func _on_lap_completed(laps):
|
||||||
lap_counter.set_text("%d" % laps)
|
lap_counter.set_text("%d" % laps)
|
||||||
|
|||||||
34
Gui.tscn
34
Gui.tscn
@@ -1,16 +1,6 @@
|
|||||||
[gd_scene load_steps=4 format=2]
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://Oswald-Bold.otf" type="DynamicFontData" id=1]
|
[ext_resource path="res://font.tres" type="DynamicFont" id=1]
|
||||||
|
|
||||||
[sub_resource type="DynamicFont" id=1]
|
|
||||||
size = 19
|
|
||||||
font_data = ExtResource( 1 )
|
|
||||||
|
|
||||||
[sub_resource type="DynamicFont" id=2]
|
|
||||||
size = 34
|
|
||||||
outline_size = 2
|
|
||||||
outline_color = Color( 0.25098, 0.25098, 0.25098, 1 )
|
|
||||||
font_data = ExtResource( 1 )
|
|
||||||
|
|
||||||
[node name="GUI" type="MarginContainer"]
|
[node name="GUI" type="MarginContainer"]
|
||||||
margin_left = 10.5631
|
margin_left = 10.5631
|
||||||
@@ -19,20 +9,18 @@ margin_right = 159.563
|
|||||||
margin_bottom = 59.2427
|
margin_bottom = 59.2427
|
||||||
|
|
||||||
[node name="Laps" type="HBoxContainer" parent="."]
|
[node name="Laps" type="HBoxContainer" parent="."]
|
||||||
margin_right = 148.0
|
margin_right = 155.0
|
||||||
margin_bottom = 50.0
|
margin_bottom = 66.0
|
||||||
|
|
||||||
[node name="Text" type="Label" parent="Laps"]
|
[node name="Text" type="Label" parent="Laps"]
|
||||||
margin_top = 11.0
|
margin_right = 125.0
|
||||||
margin_right = 50.0
|
margin_bottom = 66.0
|
||||||
margin_bottom = 38.0
|
custom_fonts/font = ExtResource( 1 )
|
||||||
custom_fonts/font = SubResource( 1 )
|
|
||||||
text = "Laps : "
|
text = "Laps : "
|
||||||
|
|
||||||
[node name="Value" type="Label" parent="Laps"]
|
[node name="Value" type="Label" parent="Laps"]
|
||||||
margin_left = 54.0
|
margin_left = 129.0
|
||||||
margin_top = 1.0
|
margin_right = 155.0
|
||||||
margin_right = 72.0
|
margin_bottom = 66.0
|
||||||
margin_bottom = 49.0
|
custom_fonts/font = ExtResource( 1 )
|
||||||
custom_fonts/font = SubResource( 2 )
|
|
||||||
text = "0"
|
text = "0"
|
||||||
|
|||||||
12
Main.gd
12
Main.gd
@@ -1,14 +1,20 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
get_tree().paused = true
|
||||||
|
|
||||||
func start_game():
|
func start_game():
|
||||||
print("Game starting")
|
|
||||||
$Menu.set_visible(false)
|
$Menu.set_visible(false)
|
||||||
yield($Countdown.start(), "race_started")
|
if not Global.race_started:
|
||||||
|
print("Game starting")
|
||||||
Global.race_started = true
|
Global.race_started = true
|
||||||
|
$GUI.set_visible(true)
|
||||||
|
yield($Countdown.start(), "completed")
|
||||||
|
get_tree().paused = false
|
||||||
|
|
||||||
func pause_game():
|
func pause_game():
|
||||||
$Menu.set_visible(true)
|
$Menu.set_visible(true)
|
||||||
Global.race_started = false
|
get_tree().paused = true
|
||||||
|
|
||||||
func _input(event):
|
func _input(event):
|
||||||
if event.is_action_pressed("ui_cancel"):
|
if event.is_action_pressed("ui_cancel"):
|
||||||
|
|||||||
10
Main.tscn
10
Main.tscn
@@ -1,9 +1,11 @@
|
|||||||
[gd_scene load_steps=5 format=2]
|
[gd_scene load_steps=7 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://Main.gd" type="Script" id=1]
|
[ext_resource path="res://Main.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://RaceTrack.tscn" type="PackedScene" id=2]
|
[ext_resource path="res://RaceTrack.tscn" type="PackedScene" id=2]
|
||||||
[ext_resource path="res://Menu.tscn" type="PackedScene" id=3]
|
[ext_resource path="res://Menu.tscn" type="PackedScene" id=3]
|
||||||
[ext_resource path="res://Countdown.tscn" type="PackedScene" id=4]
|
[ext_resource path="res://Countdown.tscn" type="PackedScene" id=4]
|
||||||
|
[ext_resource path="res://Gui.tscn" type="PackedScene" id=5]
|
||||||
|
[ext_resource path="res://Gui.gd" type="Script" id=6]
|
||||||
|
|
||||||
[node name="Main" type="Node"]
|
[node name="Main" type="Node"]
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
@@ -11,9 +13,13 @@ script = ExtResource( 1 )
|
|||||||
[node name="RaceTrack" parent="." instance=ExtResource( 2 )]
|
[node name="RaceTrack" parent="." instance=ExtResource( 2 )]
|
||||||
|
|
||||||
[node name="Menu" parent="." instance=ExtResource( 3 )]
|
[node name="Menu" parent="." instance=ExtResource( 3 )]
|
||||||
|
pause_mode = 2
|
||||||
|
|
||||||
[node name="Countdown" parent="." instance=ExtResource( 4 )]
|
[node name="Countdown" parent="." instance=ExtResource( 4 )]
|
||||||
|
pause_mode = 2
|
||||||
visible = false
|
visible = false
|
||||||
delay = 3
|
delay = 3
|
||||||
|
|
||||||
|
[node name="GUI" parent="." instance=ExtResource( 5 )]
|
||||||
|
script = ExtResource( 6 )
|
||||||
[connection signal="game_started" from="Menu" to="." method="start_game"]
|
[connection signal="game_started" from="Menu" to="." method="start_game"]
|
||||||
[connection signal="track_changed" from="Menu" to="RaceTrack" method="_on_Menu_track_changed"]
|
|
||||||
|
|||||||
127
Menu.gd
127
Menu.gd
@@ -1,57 +1,114 @@
|
|||||||
extends Control
|
extends Control
|
||||||
|
|
||||||
signal game_started()
|
signal game_started()
|
||||||
signal track_changed()
|
|
||||||
signal skin_changed(skin)
|
signal skin_changed(skin)
|
||||||
|
|
||||||
enum Actions { PLAY, CHANGE_TRACK, QUIT }
|
enum Actions {
|
||||||
var _focus = null setget _set_focus
|
PLAY,
|
||||||
|
ENTER_OPTIONS,
|
||||||
|
EXIT_OPTIONS,
|
||||||
|
NEXT_TRACK,
|
||||||
|
PREV_TRACK,
|
||||||
|
# PREV_SKIN,
|
||||||
|
# NEXT_SKIN,
|
||||||
|
PREV_INPUT_MODE,
|
||||||
|
NEXT_INPUT_MODE,
|
||||||
|
PREV_GAME_MODE,
|
||||||
|
NEXT_GAME_MODE,
|
||||||
|
QUIT,
|
||||||
|
}
|
||||||
|
var actions = {} # Registered actions
|
||||||
|
var _focus = null # The node that has focus
|
||||||
|
|
||||||
|
|
||||||
func _set_focus(value):
|
|
||||||
_focus = value
|
|
||||||
print("New focus: ", value)
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
|
||||||
func _ready():
|
func _ready():
|
||||||
pass # Replace with function body.
|
_connect_action("Main/Jouer", Actions.PLAY)
|
||||||
|
_connect_action("Main/Options", Actions.ENTER_OPTIONS)
|
||||||
|
_connect_action("Main/Quitter", Actions.QUIT)
|
||||||
|
|
||||||
|
_connect_action("Options/Return", Actions.EXIT_OPTIONS)
|
||||||
|
_connect_action("Options/TrackSelection/LeftArrow", Actions.PREV_TRACK)
|
||||||
|
_connect_action("Options/TrackSelection/RightArrow", Actions.NEXT_TRACK)
|
||||||
|
_connect_action("Options/GameMode/LeftArrow", Actions.PREV_GAME_MODE)
|
||||||
|
_connect_action("Options/GameMode/RightArrow", Actions.NEXT_GAME_MODE)
|
||||||
|
_connect_action("Options/InputMode/LeftArrow", Actions.PREV_INPUT_MODE)
|
||||||
|
_connect_action("Options/InputMode/RightArrow", Actions.NEXT_INPUT_MODE)
|
||||||
|
_update_options_values()
|
||||||
|
|
||||||
|
TrackSelection.connect("track_changed", self, "_on_track_changed")
|
||||||
|
_on_track_changed()
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
||||||
#func _process(delta):
|
|
||||||
# pass
|
|
||||||
|
|
||||||
func _input(event):
|
func _input(event):
|
||||||
if event is InputEventMouseButton:
|
# TODO: Handle navigation
|
||||||
if _focus != null:
|
if event is InputEventMouseButton and _focus != null:
|
||||||
if event.button_index == BUTTON_LEFT and event.pressed:
|
if event.button_index == BUTTON_LEFT and event.pressed:
|
||||||
match _focus:
|
match actions[_focus]:
|
||||||
Actions.PLAY:
|
Actions.PLAY:
|
||||||
emit_signal("game_started")
|
emit_signal("game_started")
|
||||||
Actions.CHANGE_TRACK:
|
Actions.ENTER_OPTIONS:
|
||||||
emit_signal("track_changed")
|
$Main.set_visible(false)
|
||||||
|
$Options.set_visible(true)
|
||||||
|
Actions.EXIT_OPTIONS:
|
||||||
|
$Main.set_visible(true)
|
||||||
|
$Options.set_visible(false)
|
||||||
Actions.QUIT:
|
Actions.QUIT:
|
||||||
get_tree().quit()
|
get_tree().quit()
|
||||||
|
Actions.PREV_TRACK:
|
||||||
|
TrackSelection.set_previous_track()
|
||||||
|
Actions.NEXT_TRACK:
|
||||||
|
TrackSelection.set_next_track()
|
||||||
|
Actions.NEXT_GAME_MODE,Actions.PREV_GAME_MODE:
|
||||||
|
if Global.settings.game_mode == Global.GameMode.TRAIN:
|
||||||
|
Global.settings.game_mode = Global.GameMode.EASY
|
||||||
|
else:
|
||||||
|
Global.settings.game_mode = Global.GameMode.TRAIN
|
||||||
|
_update_options_values()
|
||||||
|
|
||||||
func _on_Jouer_mouse_exited():
|
Actions.NEXT_INPUT_MODE,Actions.PREV_INPUT_MODE:
|
||||||
get_node("Main/Jouer").set("custom_colors/font_color", Color.white)
|
if Global.settings.input_mode == Global.InputMode.MOUSE:
|
||||||
|
Global.settings.input_mode = Global.InputMode.KEYBOARD
|
||||||
|
else:
|
||||||
|
Global.settings.input_mode = Global.InputMode.MOUSE
|
||||||
|
_update_options_values()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func _on_track_changed():
|
||||||
|
get_node("Options/TrackSelection/Value").set_text(TrackSelection.get_current_track_name())
|
||||||
|
|
||||||
|
|
||||||
|
func _connect_action(node_path, action):
|
||||||
|
var node = get_node(node_path)
|
||||||
|
node.connect("mouse_entered", self, "set_focus", [node])
|
||||||
|
node.connect("mouse_exited", self, "leave_focus", [node])
|
||||||
|
actions[node] = action
|
||||||
|
|
||||||
|
|
||||||
|
func set_focus(node):
|
||||||
|
_set_active(true, node)
|
||||||
|
_focus = node
|
||||||
|
|
||||||
|
|
||||||
|
func leave_focus(node):
|
||||||
|
_set_active(false, node)
|
||||||
_focus = null
|
_focus = null
|
||||||
|
|
||||||
|
|
||||||
func _on_Jouer_mouse_entered():
|
func _set_active(is_active, node):
|
||||||
get_node("Main/Jouer").set("custom_colors/font_color", Color.orange)
|
# Updates the focus effect for node
|
||||||
_set_focus(Actions.PLAY)
|
var color = Color.orange if is_active else Color.white
|
||||||
|
node.set("custom_colors/font_color", color)
|
||||||
func _on_Options_mouse_exited():
|
|
||||||
get_node("Main/Options").set("custom_colors/font_color", Color.white)
|
|
||||||
_focus = null
|
|
||||||
|
|
||||||
func _on_Options_mouse_entered():
|
|
||||||
get_node("Main/Options").set("custom_colors/font_color", Color.orange)
|
|
||||||
_set_focus(Actions.CHANGE_TRACK)
|
|
||||||
|
|
||||||
|
|
||||||
func _on_Quitter_mouse_entered():
|
func _update_options_values():
|
||||||
get_node("Main/Quitter").set("custom_colors/font_color", Color.orange)
|
var new_text
|
||||||
_set_focus(Actions.QUIT)
|
match Global.settings.game_mode:
|
||||||
|
Global.GameMode.EASY: new_text = "Facile"
|
||||||
|
Global.GameMode.TRAIN: new_text = "Entraînement"
|
||||||
|
get_node("Options/GameMode/Value").set_text(new_text)
|
||||||
|
|
||||||
func _on_Quitter_mouse_exited():
|
match Global.settings.input_mode:
|
||||||
get_node("Main/Quitter").set("custom_colors/font_color", Color.white)
|
Global.InputMode.MOUSE: new_text = "Souris"
|
||||||
_focus = null
|
Global.InputMode.KEYBOARD: new_text = "Clavier"
|
||||||
|
get_node("Options/InputMode/Value").set_text(new_text)
|
||||||
|
|||||||
222
Menu.tscn
222
Menu.tscn
@@ -1,14 +1,7 @@
|
|||||||
[gd_scene load_steps=5 format=2]
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://Menu.gd" type="Script" id=1]
|
[ext_resource path="res://Menu.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://Oswald-Bold.otf" type="DynamicFontData" id=2]
|
[ext_resource path="res://font.tres" type="DynamicFont" id=2]
|
||||||
[ext_resource path="res://font.tres" type="DynamicFont" id=3]
|
|
||||||
|
|
||||||
[sub_resource type="DynamicFont" id=1]
|
|
||||||
resource_name = "BaseFont"
|
|
||||||
size = 60
|
|
||||||
use_filter = true
|
|
||||||
font_data = ExtResource( 2 )
|
|
||||||
|
|
||||||
[node name="Menu" type="Control"]
|
[node name="Menu" type="Control"]
|
||||||
margin_right = 1920.0
|
margin_right = 1920.0
|
||||||
@@ -19,36 +12,201 @@ script = ExtResource( 1 )
|
|||||||
[node name="Title" type="Label" parent="."]
|
[node name="Title" type="Label" parent="."]
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
anchor_right = 0.5
|
anchor_right = 0.5
|
||||||
margin_left = -222.36
|
margin_left = -960.0
|
||||||
margin_top = 201.721
|
margin_top = 202.0
|
||||||
margin_right = 20.6399
|
margin_bottom = 285.0
|
||||||
margin_bottom = 284.721
|
|
||||||
rect_scale = Vector2( 2, 2 )
|
rect_scale = Vector2( 2, 2 )
|
||||||
custom_fonts/font = SubResource( 1 )
|
custom_fonts/font = ExtResource( 2 )
|
||||||
custom_colors/font_color = Color( 0.921569, 0.564706, 0.0627451, 1 )
|
custom_colors/font_color = Color( 0.921569, 0.564706, 0.0627451, 1 )
|
||||||
custom_colors/font_color_shadow = Color( 0.423529, 0.2, 0.0352941, 1 )
|
custom_colors/font_color_shadow = Color( 0.423529, 0.2, 0.0352941, 1 )
|
||||||
custom_constants/shadow_offset_x = 2
|
custom_constants/shadow_offset_x = 2
|
||||||
custom_constants/shadow_offset_y = 3
|
custom_constants/shadow_offset_y = 3
|
||||||
custom_constants/shadow_as_outline = 0
|
custom_constants/shadow_as_outline = 0
|
||||||
text = "Car Racer"
|
text = "Car Racer"
|
||||||
|
align = 1
|
||||||
|
valign = 1
|
||||||
|
|
||||||
|
[node name="Options" type="VBoxContainer" parent="."]
|
||||||
|
visible = false
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
margin_left = -960.0
|
||||||
|
margin_top = -89.937
|
||||||
|
margin_bottom = 421.063
|
||||||
|
rect_scale = Vector2( 2, 2 )
|
||||||
|
|
||||||
|
[node name="TrackSelection" type="HBoxContainer" parent="Options"]
|
||||||
|
editor/display_folded = true
|
||||||
|
margin_right = 960.0
|
||||||
|
margin_bottom = 66.0
|
||||||
|
custom_constants/separation = 20
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="Options/TrackSelection"]
|
||||||
|
margin_left = 213.0
|
||||||
|
margin_right = 539.0
|
||||||
|
margin_bottom = 66.0
|
||||||
|
mouse_filter = 0
|
||||||
|
custom_fonts/font = ExtResource( 2 )
|
||||||
|
text = "Piste de course :"
|
||||||
|
align = 1
|
||||||
|
valign = 1
|
||||||
|
|
||||||
|
[node name="LeftArrow" type="Label" parent="Options/TrackSelection"]
|
||||||
|
margin_left = 559.0
|
||||||
|
margin_right = 578.0
|
||||||
|
margin_bottom = 66.0
|
||||||
|
mouse_filter = 0
|
||||||
|
custom_fonts/font = ExtResource( 2 )
|
||||||
|
custom_colors/font_color_shadow = Color( 0.835294, 0.552941, 0.145098, 1 )
|
||||||
|
custom_constants/shadow_offset_x = 2
|
||||||
|
custom_constants/shadow_offset_y = 3
|
||||||
|
text = "<"
|
||||||
|
|
||||||
|
[node name="Value" type="Label" parent="Options/TrackSelection"]
|
||||||
|
margin_left = 598.0
|
||||||
|
margin_right = 708.0
|
||||||
|
margin_bottom = 66.0
|
||||||
|
custom_fonts/font = ExtResource( 2 )
|
||||||
|
text = "Démo"
|
||||||
|
|
||||||
|
[node name="RightArrow" type="Label" parent="Options/TrackSelection"]
|
||||||
|
margin_left = 728.0
|
||||||
|
margin_right = 747.0
|
||||||
|
margin_bottom = 66.0
|
||||||
|
mouse_filter = 0
|
||||||
|
custom_fonts/font = ExtResource( 2 )
|
||||||
|
custom_colors/font_color_shadow = Color( 0.835294, 0.552941, 0.145098, 1 )
|
||||||
|
custom_constants/shadow_offset_x = 2
|
||||||
|
custom_constants/shadow_offset_y = 3
|
||||||
|
text = ">"
|
||||||
|
|
||||||
|
[node name="GameMode" type="HBoxContainer" parent="Options"]
|
||||||
|
editor/display_folded = true
|
||||||
|
margin_top = 70.0
|
||||||
|
margin_right = 960.0
|
||||||
|
margin_bottom = 136.0
|
||||||
|
custom_constants/separation = 20
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="Options/GameMode"]
|
||||||
|
margin_left = 195.0
|
||||||
|
margin_right = 403.0
|
||||||
|
margin_bottom = 66.0
|
||||||
|
mouse_filter = 0
|
||||||
|
custom_fonts/font = ExtResource( 2 )
|
||||||
|
text = "Difficulté :"
|
||||||
|
align = 1
|
||||||
|
valign = 1
|
||||||
|
|
||||||
|
[node name="LeftArrow" type="Label" parent="Options/GameMode"]
|
||||||
|
margin_left = 423.0
|
||||||
|
margin_right = 442.0
|
||||||
|
margin_bottom = 66.0
|
||||||
|
mouse_filter = 0
|
||||||
|
custom_fonts/font = ExtResource( 2 )
|
||||||
|
custom_colors/font_color_shadow = Color( 0.835294, 0.552941, 0.145098, 1 )
|
||||||
|
custom_constants/shadow_offset_x = 2
|
||||||
|
custom_constants/shadow_offset_y = 3
|
||||||
|
text = "<"
|
||||||
|
|
||||||
|
[node name="Value" type="Label" parent="Options/GameMode"]
|
||||||
|
margin_left = 462.0
|
||||||
|
margin_right = 725.0
|
||||||
|
margin_bottom = 66.0
|
||||||
|
custom_fonts/font = ExtResource( 2 )
|
||||||
|
text = "Entraînement"
|
||||||
|
|
||||||
|
[node name="RightArrow" type="Label" parent="Options/GameMode"]
|
||||||
|
margin_left = 745.0
|
||||||
|
margin_right = 764.0
|
||||||
|
margin_bottom = 66.0
|
||||||
|
mouse_filter = 0
|
||||||
|
custom_fonts/font = ExtResource( 2 )
|
||||||
|
custom_colors/font_color_shadow = Color( 0.835294, 0.552941, 0.145098, 1 )
|
||||||
|
custom_constants/shadow_offset_x = 2
|
||||||
|
custom_constants/shadow_offset_y = 3
|
||||||
|
text = ">"
|
||||||
|
|
||||||
|
[node name="InputMode" type="HBoxContainer" parent="Options"]
|
||||||
|
editor/display_folded = true
|
||||||
|
margin_top = 140.0
|
||||||
|
margin_right = 960.0
|
||||||
|
margin_bottom = 206.0
|
||||||
|
custom_constants/separation = 20
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="Options/InputMode"]
|
||||||
|
margin_left = 245.0
|
||||||
|
margin_right = 493.0
|
||||||
|
margin_bottom = 66.0
|
||||||
|
mouse_filter = 0
|
||||||
|
custom_fonts/font = ExtResource( 2 )
|
||||||
|
text = "Contrôlleur :"
|
||||||
|
align = 1
|
||||||
|
valign = 1
|
||||||
|
|
||||||
|
[node name="LeftArrow" type="Label" parent="Options/InputMode"]
|
||||||
|
margin_left = 513.0
|
||||||
|
margin_right = 532.0
|
||||||
|
margin_bottom = 66.0
|
||||||
|
mouse_filter = 0
|
||||||
|
custom_fonts/font = ExtResource( 2 )
|
||||||
|
custom_colors/font_color_shadow = Color( 0.835294, 0.552941, 0.145098, 1 )
|
||||||
|
custom_constants/shadow_offset_x = 2
|
||||||
|
custom_constants/shadow_offset_y = 3
|
||||||
|
text = "<"
|
||||||
|
|
||||||
|
[node name="Value" type="Label" parent="Options/InputMode"]
|
||||||
|
margin_left = 552.0
|
||||||
|
margin_right = 675.0
|
||||||
|
margin_bottom = 66.0
|
||||||
|
custom_fonts/font = ExtResource( 2 )
|
||||||
|
text = "Souris"
|
||||||
|
|
||||||
|
[node name="RightArrow" type="Label" parent="Options/InputMode"]
|
||||||
|
margin_left = 695.0
|
||||||
|
margin_right = 714.0
|
||||||
|
margin_bottom = 66.0
|
||||||
|
mouse_filter = 0
|
||||||
|
custom_fonts/font = ExtResource( 2 )
|
||||||
|
custom_colors/font_color_shadow = Color( 0.835294, 0.552941, 0.145098, 1 )
|
||||||
|
custom_constants/shadow_offset_x = 2
|
||||||
|
custom_constants/shadow_offset_y = 3
|
||||||
|
text = ">"
|
||||||
|
|
||||||
|
[node name="Return" type="Label" parent="Options"]
|
||||||
|
margin_top = 210.0
|
||||||
|
margin_right = 960.0
|
||||||
|
margin_bottom = 276.0
|
||||||
|
mouse_filter = 0
|
||||||
|
custom_fonts/font = ExtResource( 2 )
|
||||||
|
custom_colors/font_color = Color( 1, 1, 1, 1 )
|
||||||
|
custom_colors/font_color_shadow = Color( 0.823529, 0.517647, 0.0823529, 1 )
|
||||||
|
custom_constants/shadow_offset_x = 2
|
||||||
|
custom_constants/shadow_offset_y = 3
|
||||||
|
text = "Retour"
|
||||||
|
align = 1
|
||||||
|
valign = 1
|
||||||
|
|
||||||
[node name="Main" type="VBoxContainer" parent="."]
|
[node name="Main" type="VBoxContainer" parent="."]
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
anchor_top = 0.5
|
anchor_top = 0.5
|
||||||
anchor_right = 0.5
|
anchor_right = 0.5
|
||||||
anchor_bottom = 0.5
|
anchor_bottom = 0.5
|
||||||
margin_left = -139.571
|
margin_left = -960.0
|
||||||
margin_top = -76.9716
|
margin_top = -76.972
|
||||||
margin_right = 9.42896
|
margin_bottom = 180.028
|
||||||
margin_bottom = 129.028
|
|
||||||
rect_scale = Vector2( 2, 2 )
|
rect_scale = Vector2( 2, 2 )
|
||||||
mouse_default_cursor_shape = 9
|
mouse_default_cursor_shape = 9
|
||||||
|
|
||||||
[node name="Jouer" type="Label" parent="Main"]
|
[node name="Jouer" type="Label" parent="Main"]
|
||||||
margin_right = 149.0
|
margin_right = 960.0
|
||||||
margin_bottom = 66.0
|
margin_bottom = 66.0
|
||||||
mouse_filter = 0
|
mouse_filter = 0
|
||||||
custom_fonts/font = ExtResource( 3 )
|
custom_fonts/font = ExtResource( 2 )
|
||||||
custom_colors/font_color = Color( 1, 1, 1, 1 )
|
custom_colors/font_color = Color( 1, 1, 1, 1 )
|
||||||
custom_colors/font_color_shadow = Color( 0.823529, 0.517647, 0.0823529, 1 )
|
custom_colors/font_color_shadow = Color( 0.823529, 0.517647, 0.0823529, 1 )
|
||||||
custom_constants/shadow_offset_x = 2
|
custom_constants/shadow_offset_x = 2
|
||||||
@@ -59,10 +217,10 @@ valign = 1
|
|||||||
|
|
||||||
[node name="Options" type="Label" parent="Main"]
|
[node name="Options" type="Label" parent="Main"]
|
||||||
margin_top = 70.0
|
margin_top = 70.0
|
||||||
margin_right = 149.0
|
margin_right = 960.0
|
||||||
margin_bottom = 136.0
|
margin_bottom = 136.0
|
||||||
mouse_filter = 0
|
mouse_filter = 0
|
||||||
custom_fonts/font = ExtResource( 3 )
|
custom_fonts/font = ExtResource( 2 )
|
||||||
custom_colors/font_color = Color( 1, 1, 1, 1 )
|
custom_colors/font_color = Color( 1, 1, 1, 1 )
|
||||||
custom_colors/font_color_shadow = Color( 0.823529, 0.517647, 0.0823529, 1 )
|
custom_colors/font_color_shadow = Color( 0.823529, 0.517647, 0.0823529, 1 )
|
||||||
custom_constants/shadow_offset_x = 2
|
custom_constants/shadow_offset_x = 2
|
||||||
@@ -72,29 +230,13 @@ align = 1
|
|||||||
|
|
||||||
[node name="Quitter" type="Label" parent="Main"]
|
[node name="Quitter" type="Label" parent="Main"]
|
||||||
margin_top = 140.0
|
margin_top = 140.0
|
||||||
margin_right = 149.0
|
margin_right = 960.0
|
||||||
margin_bottom = 206.0
|
margin_bottom = 206.0
|
||||||
mouse_filter = 0
|
mouse_filter = 0
|
||||||
custom_fonts/font = ExtResource( 3 )
|
custom_fonts/font = ExtResource( 2 )
|
||||||
custom_colors/font_color = Color( 1, 1, 1, 1 )
|
custom_colors/font_color = Color( 1, 1, 1, 1 )
|
||||||
custom_colors/font_color_shadow = Color( 0.823529, 0.517647, 0.0823529, 1 )
|
custom_colors/font_color_shadow = Color( 0.823529, 0.517647, 0.0823529, 1 )
|
||||||
custom_constants/shadow_offset_x = 2
|
custom_constants/shadow_offset_x = 2
|
||||||
custom_constants/shadow_offset_y = 3
|
custom_constants/shadow_offset_y = 3
|
||||||
text = "Quitter"
|
text = "Quitter"
|
||||||
align = 1
|
align = 1
|
||||||
|
|
||||||
[node name="Options" type="VBoxContainer" parent="."]
|
|
||||||
anchor_left = 0.5
|
|
||||||
anchor_top = 0.5
|
|
||||||
anchor_right = 0.5
|
|
||||||
anchor_bottom = 0.5
|
|
||||||
margin_left = -20.0
|
|
||||||
margin_top = -20.0
|
|
||||||
margin_right = 20.0
|
|
||||||
margin_bottom = 20.0
|
|
||||||
[connection signal="mouse_entered" from="Main/Jouer" to="." method="_on_Jouer_mouse_entered"]
|
|
||||||
[connection signal="mouse_exited" from="Main/Jouer" to="." method="_on_Jouer_mouse_exited"]
|
|
||||||
[connection signal="mouse_entered" from="Main/Options" to="." method="_on_Options_mouse_entered"]
|
|
||||||
[connection signal="mouse_exited" from="Main/Options" to="." method="_on_Options_mouse_exited"]
|
|
||||||
[connection signal="mouse_entered" from="Main/Quitter" to="." method="_on_Quitter_mouse_entered"]
|
|
||||||
[connection signal="mouse_exited" from="Main/Quitter" to="." method="_on_Quitter_mouse_exited"]
|
|
||||||
|
|||||||
17
PlayerCar.gd
17
PlayerCar.gd
@@ -1,17 +0,0 @@
|
|||||||
extends Node2D
|
|
||||||
|
|
||||||
export (String, "bus", "police", "car") var skin
|
|
||||||
|
|
||||||
|
|
||||||
enum { RIGHT, DOWN_RIGHT, DOWN, DOWN_LEFT, LEFT, UP_LEFT, UP, UP_RIGHT }
|
|
||||||
|
|
||||||
# TODO:
|
|
||||||
# - Move track related logic inside TrackPlayer script ?
|
|
||||||
onready var track = get_node("/root/Track2/RaceTrack/TrackPlayer/")
|
|
||||||
|
|
||||||
|
|
||||||
func _ready():
|
|
||||||
# Set player sprite
|
|
||||||
$CarSprite.set_animation(skin)
|
|
||||||
|
|
||||||
|
|
||||||
@@ -17,17 +17,17 @@
|
|||||||
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/car02/car02iso_0000.png" type="Texture" id=15]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/car02/car02iso_0000.png" type="Texture" id=15]
|
||||||
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/car02/car02iso_0005.png" type="Texture" id=16]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/car02/car02iso_0005.png" type="Texture" id=16]
|
||||||
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/car02/car02iso_0006.png" type="Texture" id=17]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/car02/car02iso_0006.png" type="Texture" id=17]
|
||||||
[ext_resource path="res://track1/policeCar/policeiso_0003.png" type="Texture" id=18]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/policeCar/policeiso_0000.png" type="Texture" id=18]
|
||||||
[ext_resource path="res://track1/policeCar/policeiso_0004.png" type="Texture" id=19]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/policeCar/policeiso_0001.png" type="Texture" id=19]
|
||||||
[ext_resource path="res://track1/policeCar/policeiso_0001.png" type="Texture" id=20]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/policeCar/policeiso_0002.png" type="Texture" id=20]
|
||||||
[ext_resource path="res://track1/policeCar/policeiso_0002.png" type="Texture" id=21]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/policeCar/policeiso_0003.png" type="Texture" id=21]
|
||||||
[ext_resource path="res://track1/policeCar/policeiso_0007.png" type="Texture" id=22]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/policeCar/policeiso_0004.png" type="Texture" id=22]
|
||||||
[ext_resource path="res://track1/policeCar/policeiso_0000.png" type="Texture" id=23]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/policeCar/policeiso_0005.png" type="Texture" id=23]
|
||||||
[ext_resource path="res://track1/policeCar/policeiso_0005.png" type="Texture" id=24]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/policeCar/policeiso_0006.png" type="Texture" id=24]
|
||||||
[ext_resource path="res://track1/policeCar/policeiso_0006.png" type="Texture" id=25]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/policeCar/policeiso_0007.png" type="Texture" id=25]
|
||||||
[ext_resource path="res://CarSprite.gd" type="Script" id=26]
|
[ext_resource path="res://CarSprite.gd" type="Script" id=26]
|
||||||
|
|
||||||
[sub_resource type="SpriteFrames" id=1]
|
[sub_resource type="SpriteFrames" id=6]
|
||||||
animations = [ {
|
animations = [ {
|
||||||
"frames": [ ExtResource( 2 ), ExtResource( 3 ), ExtResource( 4 ), ExtResource( 5 ), ExtResource( 6 ), ExtResource( 7 ), ExtResource( 8 ), ExtResource( 9 ) ],
|
"frames": [ ExtResource( 2 ), ExtResource( 3 ), ExtResource( 4 ), ExtResource( 5 ), ExtResource( 6 ), ExtResource( 7 ), ExtResource( 8 ), ExtResource( 9 ) ],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
@@ -56,6 +56,6 @@ __meta__ = {
|
|||||||
[node name="CarSprite" type="AnimatedSprite" parent="."]
|
[node name="CarSprite" type="AnimatedSprite" parent="."]
|
||||||
position = Vector2( -3.20422, 3.0376 )
|
position = Vector2( -3.20422, 3.0376 )
|
||||||
scale = Vector2( 0.8, 0.8 )
|
scale = Vector2( 0.8, 0.8 )
|
||||||
frames = SubResource( 1 )
|
frames = SubResource( 6 )
|
||||||
animation = "car"
|
animation = "car"
|
||||||
script = ExtResource( 26 )
|
script = ExtResource( 26 )
|
||||||
|
|||||||
57
RaceTrack.gd
57
RaceTrack.gd
@@ -1,57 +0,0 @@
|
|||||||
extends Node
|
|
||||||
|
|
||||||
signal player_moved(track_offset)
|
|
||||||
signal wrong_way(coords)
|
|
||||||
|
|
||||||
# TODO:
|
|
||||||
# - Find a mean to import tracks (arrays of cell coordinates).
|
|
||||||
# ( - Autopopulate the map according to track data )
|
|
||||||
# - Build the track Curve2D from track and tiles data
|
|
||||||
# - Keyboard controls !!
|
|
||||||
|
|
||||||
var laps
|
|
||||||
var current_cell
|
|
||||||
var track = null
|
|
||||||
onready var map = $TileMap
|
|
||||||
|
|
||||||
func get_track_offset(coords):
|
|
||||||
var offset = float(track.find(coords)) / float(len(track))
|
|
||||||
return offset
|
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
|
||||||
func _ready():
|
|
||||||
_reset_state()
|
|
||||||
|
|
||||||
func _reset_state():
|
|
||||||
track = TrackSelection.get_current_track()
|
|
||||||
laps = 0
|
|
||||||
current_cell = track[0]
|
|
||||||
|
|
||||||
|
|
||||||
func _input(event):
|
|
||||||
if not Global.race_started:
|
|
||||||
return -1
|
|
||||||
# Check if the mouse if following the tiles track
|
|
||||||
if event is InputEventMouseMotion:
|
|
||||||
var hover_cell = map.world_to_map(event.position)
|
|
||||||
if hover_cell != current_cell: # The mouse moved to a new cell
|
|
||||||
# Check the tile is on path
|
|
||||||
if track.find(hover_cell) != -1:
|
|
||||||
# Check if a lap is finished
|
|
||||||
if hover_cell == track[0] and current_cell == track[-1]:
|
|
||||||
laps += 1
|
|
||||||
# Check we are following the path
|
|
||||||
if track[track.find(hover_cell) - 1] == current_cell:
|
|
||||||
emit_signal("player_moved", laps + get_track_offset(hover_cell))
|
|
||||||
emit_signal("wrong_way", Vector2(-1, -1))
|
|
||||||
current_cell = hover_cell
|
|
||||||
else:
|
|
||||||
emit_signal("wrong_way", map.map_to_world(hover_cell))
|
|
||||||
|
|
||||||
func _on_Menu_track_changed():
|
|
||||||
print("Options clicked")
|
|
||||||
TrackSelection.set_next_track()
|
|
||||||
_reset_state()
|
|
||||||
$TileMap._reset()
|
|
||||||
$TrackPath._reset()
|
|
||||||
|
|
||||||
160
RaceTrack.tscn
160
RaceTrack.tscn
@@ -1,40 +1,38 @@
|
|||||||
[gd_scene load_steps=41 format=2]
|
[gd_scene load_steps=40 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://RaceTrack.gd" type="Script" id=1]
|
[ext_resource path="res://race_track.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://assets/track_tiles/track.png" type="Texture" id=2]
|
[ext_resource path="res://assets/track_tiles/track.png" type="Texture" id=2]
|
||||||
[ext_resource path="res://TileMap.gd" type="Script" id=3]
|
[ext_resource path="res://TileMap.gd" type="Script" id=3]
|
||||||
[ext_resource path="res://TrackPath.gd" type="Script" id=4]
|
[ext_resource path="res://track_path.gd" type="Script" id=4]
|
||||||
[ext_resource path="res://OpponentCar.gd" type="Script" id=5]
|
[ext_resource path="res://opponent_car.gd" type="Script" id=5]
|
||||||
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/car02/car02iso_0003.png" type="Texture" id=6]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/bus/busiso_0007.png" type="Texture" id=6]
|
||||||
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/car02/car02iso_0004.png" type="Texture" id=7]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/bus/busiso_0004.png" type="Texture" id=7]
|
||||||
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/car02/car02iso_0001.png" type="Texture" id=8]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/bus/busiso_0001.png" type="Texture" id=8]
|
||||||
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/car02/car02iso_0002.png" type="Texture" id=9]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/bus/busiso_0002.png" type="Texture" id=9]
|
||||||
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/car02/car02iso_0007.png" type="Texture" id=10]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/bus/busiso_0003.png" type="Texture" id=10]
|
||||||
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/car02/car02iso_0000.png" type="Texture" id=11]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/bus/busiso_0000.png" type="Texture" id=11]
|
||||||
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/car02/car02iso_0005.png" type="Texture" id=12]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/bus/busiso_0005.png" type="Texture" id=12]
|
||||||
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/car02/car02iso_0006.png" type="Texture" id=13]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/bus/busiso_0006.png" type="Texture" id=13]
|
||||||
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/bus/busiso_0007.png" type="Texture" id=14]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/policeCar/policeiso_0003.png" type="Texture" id=14]
|
||||||
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/bus/busiso_0004.png" type="Texture" id=15]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/policeCar/policeiso_0004.png" type="Texture" id=15]
|
||||||
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/bus/busiso_0001.png" type="Texture" id=16]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/policeCar/policeiso_0001.png" type="Texture" id=16]
|
||||||
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/bus/busiso_0002.png" type="Texture" id=17]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/policeCar/policeiso_0002.png" type="Texture" id=17]
|
||||||
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/bus/busiso_0003.png" type="Texture" id=18]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/policeCar/policeiso_0007.png" type="Texture" id=18]
|
||||||
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/bus/busiso_0000.png" type="Texture" id=19]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/policeCar/policeiso_0000.png" type="Texture" id=19]
|
||||||
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/bus/busiso_0005.png" type="Texture" id=20]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/policeCar/policeiso_0005.png" type="Texture" id=20]
|
||||||
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/bus/busiso_0006.png" type="Texture" id=21]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/policeCar/policeiso_0006.png" type="Texture" id=21]
|
||||||
[ext_resource path="res://track1/policeCar/policeiso_0003.png" type="Texture" id=22]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/car02/car02iso_0003.png" type="Texture" id=22]
|
||||||
[ext_resource path="res://track1/policeCar/policeiso_0004.png" type="Texture" id=23]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/car02/car02iso_0004.png" type="Texture" id=23]
|
||||||
[ext_resource path="res://track1/policeCar/policeiso_0001.png" type="Texture" id=24]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/car02/car02iso_0001.png" type="Texture" id=24]
|
||||||
[ext_resource path="res://track1/policeCar/policeiso_0002.png" type="Texture" id=25]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/car02/car02iso_0002.png" type="Texture" id=25]
|
||||||
[ext_resource path="res://track1/policeCar/policeiso_0007.png" type="Texture" id=26]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/car02/car02iso_0007.png" type="Texture" id=26]
|
||||||
[ext_resource path="res://track1/policeCar/policeiso_0000.png" type="Texture" id=27]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/car02/car02iso_0000.png" type="Texture" id=27]
|
||||||
[ext_resource path="res://track1/policeCar/policeiso_0005.png" type="Texture" id=28]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/car02/car02iso_0005.png" type="Texture" id=28]
|
||||||
[ext_resource path="res://track1/policeCar/policeiso_0006.png" type="Texture" id=29]
|
[ext_resource path="res://assets/2D_Car_Pack_DevilsWorkShop_V01/car02/car02iso_0006.png" type="Texture" id=29]
|
||||||
[ext_resource path="res://CarSprite.gd" type="Script" id=30]
|
[ext_resource path="res://car_sprite.gd" type="Script" id=30]
|
||||||
[ext_resource path="res://Player.gd" type="Script" id=31]
|
[ext_resource path="res://player_car.gd" type="Script" id=31]
|
||||||
[ext_resource path="res://PlayerCar.tscn" type="PackedScene" id=32]
|
[ext_resource path="res://assets/France_road_sign_B1.svg" type="Texture" id=32]
|
||||||
[ext_resource path="res://wrong_way.tscn" type="PackedScene" id=33]
|
[ext_resource path="res://wrong_way.gd" type="Script" id=33]
|
||||||
[ext_resource path="res://Gui.tscn" type="PackedScene" id=34]
|
|
||||||
[ext_resource path="res://Gui.gd" type="Script" id=35]
|
|
||||||
|
|
||||||
[sub_resource type="Gradient" id=1]
|
[sub_resource type="Gradient" id=1]
|
||||||
colors = PoolColorArray( 0.284025, 0.4375, 0.0803223, 1, 0.30305, 0.480469, 0.0675659, 1 )
|
colors = PoolColorArray( 0.284025, 0.4375, 0.0803223, 1, 0.30305, 0.480469, 0.0675659, 1 )
|
||||||
@@ -52,6 +50,10 @@ width = 1920
|
|||||||
0/tile_mode = 0
|
0/tile_mode = 0
|
||||||
0/occluder_offset = Vector2( 0, 0 )
|
0/occluder_offset = Vector2( 0, 0 )
|
||||||
0/navigation_offset = Vector2( 0, 0 )
|
0/navigation_offset = Vector2( 0, 0 )
|
||||||
|
0/shape_offset = Vector2( 0, 0 )
|
||||||
|
0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||||
|
0/shape_one_way = false
|
||||||
|
0/shape_one_way_margin = 0.0
|
||||||
0/shapes = [ ]
|
0/shapes = [ ]
|
||||||
0/z_index = 0
|
0/z_index = 0
|
||||||
1/name = "dr"
|
1/name = "dr"
|
||||||
@@ -62,6 +64,10 @@ width = 1920
|
|||||||
1/tile_mode = 0
|
1/tile_mode = 0
|
||||||
1/occluder_offset = Vector2( 0, 0 )
|
1/occluder_offset = Vector2( 0, 0 )
|
||||||
1/navigation_offset = Vector2( 0, 0 )
|
1/navigation_offset = Vector2( 0, 0 )
|
||||||
|
1/shape_offset = Vector2( 0, 0 )
|
||||||
|
1/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||||
|
1/shape_one_way = false
|
||||||
|
1/shape_one_way_margin = 0.0
|
||||||
1/shapes = [ ]
|
1/shapes = [ ]
|
||||||
1/z_index = 0
|
1/z_index = 0
|
||||||
2/name = "lr"
|
2/name = "lr"
|
||||||
@@ -72,6 +78,10 @@ width = 1920
|
|||||||
2/tile_mode = 0
|
2/tile_mode = 0
|
||||||
2/occluder_offset = Vector2( 0, 0 )
|
2/occluder_offset = Vector2( 0, 0 )
|
||||||
2/navigation_offset = Vector2( 0, 0 )
|
2/navigation_offset = Vector2( 0, 0 )
|
||||||
|
2/shape_offset = Vector2( 0, 0 )
|
||||||
|
2/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||||
|
2/shape_one_way = false
|
||||||
|
2/shape_one_way_margin = 0.0
|
||||||
2/shapes = [ ]
|
2/shapes = [ ]
|
||||||
2/z_index = 0
|
2/z_index = 0
|
||||||
3/name = "start"
|
3/name = "start"
|
||||||
@@ -82,6 +92,10 @@ width = 1920
|
|||||||
3/tile_mode = 0
|
3/tile_mode = 0
|
||||||
3/occluder_offset = Vector2( 0, 0 )
|
3/occluder_offset = Vector2( 0, 0 )
|
||||||
3/navigation_offset = Vector2( 0, 0 )
|
3/navigation_offset = Vector2( 0, 0 )
|
||||||
|
3/shape_offset = Vector2( 0, 0 )
|
||||||
|
3/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||||
|
3/shape_one_way = false
|
||||||
|
3/shape_one_way_margin = 0.0
|
||||||
3/shapes = [ ]
|
3/shapes = [ ]
|
||||||
3/z_index = 0
|
3/z_index = 0
|
||||||
4/name = "ud"
|
4/name = "ud"
|
||||||
@@ -92,6 +106,10 @@ width = 1920
|
|||||||
4/tile_mode = 0
|
4/tile_mode = 0
|
||||||
4/occluder_offset = Vector2( 0, 0 )
|
4/occluder_offset = Vector2( 0, 0 )
|
||||||
4/navigation_offset = Vector2( 0, 0 )
|
4/navigation_offset = Vector2( 0, 0 )
|
||||||
|
4/shape_offset = Vector2( 0, 0 )
|
||||||
|
4/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||||
|
4/shape_one_way = false
|
||||||
|
4/shape_one_way_margin = 0.0
|
||||||
4/shapes = [ ]
|
4/shapes = [ ]
|
||||||
4/z_index = 0
|
4/z_index = 0
|
||||||
5/name = "ul"
|
5/name = "ul"
|
||||||
@@ -102,6 +120,10 @@ width = 1920
|
|||||||
5/tile_mode = 0
|
5/tile_mode = 0
|
||||||
5/occluder_offset = Vector2( 0, 0 )
|
5/occluder_offset = Vector2( 0, 0 )
|
||||||
5/navigation_offset = Vector2( 0, 0 )
|
5/navigation_offset = Vector2( 0, 0 )
|
||||||
|
5/shape_offset = Vector2( 0, 0 )
|
||||||
|
5/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||||
|
5/shape_one_way = false
|
||||||
|
5/shape_one_way_margin = 0.0
|
||||||
5/shapes = [ ]
|
5/shapes = [ ]
|
||||||
5/z_index = 0
|
5/z_index = 0
|
||||||
6/name = "ur"
|
6/name = "ur"
|
||||||
@@ -112,28 +134,50 @@ width = 1920
|
|||||||
6/tile_mode = 0
|
6/tile_mode = 0
|
||||||
6/occluder_offset = Vector2( 0, 0 )
|
6/occluder_offset = Vector2( 0, 0 )
|
||||||
6/navigation_offset = Vector2( 0, 0 )
|
6/navigation_offset = Vector2( 0, 0 )
|
||||||
|
6/shape_offset = Vector2( 0, 0 )
|
||||||
|
6/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||||
|
6/shape_one_way = false
|
||||||
|
6/shape_one_way_margin = 0.0
|
||||||
6/shapes = [ ]
|
6/shapes = [ ]
|
||||||
6/z_index = 0
|
6/z_index = 0
|
||||||
|
|
||||||
[sub_resource type="Curve2D" id=4]
|
[sub_resource type="Curve2D" id=4]
|
||||||
_data = {
|
_data = {
|
||||||
"points": PoolVector2Array( 0, 0, 0, 0, 606.951, 579.696, 0, 0, 0, 0, 755.584, 596.499 )
|
"points": PoolVector2Array( 0, 0, 0, 0, 606.951, 579.696 )
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="SpriteFrames" id=5]
|
[sub_resource type="SpriteFrames" id=5]
|
||||||
animations = [ {
|
animations = [ {
|
||||||
"frames": [ ExtResource( 6 ), ExtResource( 7 ), ExtResource( 8 ), ExtResource( 9 ), ExtResource( 10 ), ExtResource( 11 ), ExtResource( 12 ), ExtResource( 13 ) ],
|
"frames": [ ExtResource( 6 ), ExtResource( 7 ), ExtResource( 8 ), ExtResource( 9 ), ExtResource( 10 ), ExtResource( 11 ), ExtResource( 12 ), ExtResource( 13 ) ],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
|
"name": "bus",
|
||||||
|
"speed": 5.0
|
||||||
|
}, {
|
||||||
|
"frames": [ ExtResource( 22 ), ExtResource( 23 ), ExtResource( 24 ), ExtResource( 25 ), ExtResource( 26 ), ExtResource( 27 ), ExtResource( 28 ), ExtResource( 29 ) ],
|
||||||
|
"loop": true,
|
||||||
"name": "car",
|
"name": "car",
|
||||||
"speed": 5.0
|
"speed": 5.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ ExtResource( 14 ), ExtResource( 15 ), ExtResource( 16 ), ExtResource( 17 ), ExtResource( 18 ), ExtResource( 19 ), ExtResource( 20 ), ExtResource( 21 ) ],
|
"frames": [ ExtResource( 14 ), ExtResource( 15 ), ExtResource( 16 ), ExtResource( 17 ), ExtResource( 18 ), ExtResource( 19 ), ExtResource( 20 ), ExtResource( 21 ) ],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
|
"name": "police",
|
||||||
|
"speed": 5.0
|
||||||
|
} ]
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id=6]
|
||||||
|
animations = [ {
|
||||||
|
"frames": [ ExtResource( 6 ), ExtResource( 7 ), ExtResource( 8 ), ExtResource( 9 ), ExtResource( 10 ), ExtResource( 11 ), ExtResource( 12 ), ExtResource( 13 ) ],
|
||||||
|
"loop": true,
|
||||||
"name": "bus",
|
"name": "bus",
|
||||||
"speed": 5.0
|
"speed": 5.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ ExtResource( 22 ), ExtResource( 23 ), ExtResource( 24 ), ExtResource( 25 ), ExtResource( 26 ), ExtResource( 27 ), ExtResource( 28 ), ExtResource( 29 ) ],
|
"frames": [ ExtResource( 22 ), ExtResource( 23 ), ExtResource( 24 ), ExtResource( 25 ), ExtResource( 26 ), ExtResource( 27 ), ExtResource( 28 ), ExtResource( 29 ) ],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
|
"name": "car",
|
||||||
|
"speed": 5.0
|
||||||
|
}, {
|
||||||
|
"frames": [ ExtResource( 14 ), ExtResource( 15 ), ExtResource( 16 ), ExtResource( 17 ), ExtResource( 18 ), ExtResource( 19 ), ExtResource( 20 ), ExtResource( 21 ) ],
|
||||||
|
"loop": true,
|
||||||
"name": "police",
|
"name": "police",
|
||||||
"speed": 5.0
|
"speed": 5.0
|
||||||
} ]
|
} ]
|
||||||
@@ -141,11 +185,14 @@ animations = [ {
|
|||||||
[node name="RaceTrack" type="Node"]
|
[node name="RaceTrack" type="Node"]
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="TextureRect" type="TextureRect" parent="."]
|
[node name="Background" type="TextureRect" parent="."]
|
||||||
margin_right = 1920.0
|
margin_right = 1920.0
|
||||||
margin_bottom = 1080.0
|
margin_bottom = 1080.0
|
||||||
texture = SubResource( 2 )
|
texture = SubResource( 2 )
|
||||||
expand = true
|
expand = true
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
[node name="TileMap" type="TileMap" parent="."]
|
[node name="TileMap" type="TileMap" parent="."]
|
||||||
tile_set = SubResource( 3 )
|
tile_set = SubResource( 3 )
|
||||||
@@ -160,16 +207,13 @@ script = ExtResource( 4 )
|
|||||||
|
|
||||||
[node name="Opponent" type="PathFollow2D" parent="TrackPath"]
|
[node name="Opponent" type="PathFollow2D" parent="TrackPath"]
|
||||||
position = Vector2( 606.951, 579.696 )
|
position = Vector2( 606.951, 579.696 )
|
||||||
rotation = 0.112561
|
rotation = 0.112563
|
||||||
script = ExtResource( 5 )
|
script = ExtResource( 5 )
|
||||||
|
|
||||||
[node name="OpponentCar" type="Node2D" parent="TrackPath/Opponent"]
|
[node name="CarSprite" type="AnimatedSprite" parent="TrackPath/Opponent"]
|
||||||
position = Vector2( 0, 22 )
|
visible = false
|
||||||
scale = Vector2( 0.25, 0.25 )
|
position = Vector2( -0.801025, 22.7594 )
|
||||||
|
scale = Vector2( 0.2, 0.2 )
|
||||||
[node name="CarSprite" type="AnimatedSprite" parent="TrackPath/Opponent/OpponentCar"]
|
|
||||||
position = Vector2( -3.20422, 3.0376 )
|
|
||||||
scale = Vector2( 0.8, 0.8 )
|
|
||||||
frames = SubResource( 5 )
|
frames = SubResource( 5 )
|
||||||
animation = "car"
|
animation = "car"
|
||||||
script = ExtResource( 30 )
|
script = ExtResource( 30 )
|
||||||
@@ -177,19 +221,27 @@ skin = "police"
|
|||||||
|
|
||||||
[node name="Player" type="PathFollow2D" parent="TrackPath"]
|
[node name="Player" type="PathFollow2D" parent="TrackPath"]
|
||||||
position = Vector2( 606.951, 579.696 )
|
position = Vector2( 606.951, 579.696 )
|
||||||
rotation = 0.112561
|
rotation = 0.112563
|
||||||
script = ExtResource( 31 )
|
script = ExtResource( 31 )
|
||||||
|
|
||||||
[node name="PlayerCar" parent="TrackPath/Player" instance=ExtResource( 32 )]
|
[node name="CarSprite" type="AnimatedSprite" parent="TrackPath/Player"]
|
||||||
position = Vector2( 1.89564, -22.3528 )
|
position = Vector2( 1.09454, -21.5934 )
|
||||||
scale = Vector2( 0.25, 0.25 )
|
scale = Vector2( 0.2, 0.2 )
|
||||||
script = null
|
frames = SubResource( 6 )
|
||||||
|
animation = "car"
|
||||||
|
script = ExtResource( 30 )
|
||||||
|
|
||||||
[node name="Wrong Way" parent="." instance=ExtResource( 33 )]
|
[node name="Wrong Way" type="TextureRect" parent="."]
|
||||||
visible = false
|
visible = false
|
||||||
|
margin_left = 445.793
|
||||||
[node name="GUI" parent="." instance=ExtResource( 34 )]
|
margin_top = 558.431
|
||||||
script = ExtResource( 35 )
|
margin_right = 930.792
|
||||||
|
margin_bottom = 1043.43
|
||||||
|
rect_scale = Vector2( 0.1, 0.1 )
|
||||||
|
size_flags_horizontal = 0
|
||||||
|
size_flags_vertical = 0
|
||||||
|
texture = ExtResource( 32 )
|
||||||
|
stretch_mode = 4
|
||||||
|
script = ExtResource( 33 )
|
||||||
[connection signal="player_moved" from="." to="TrackPath/Player" method="_on_RaceTrack_player_moved"]
|
[connection signal="player_moved" from="." to="TrackPath/Player" method="_on_RaceTrack_player_moved"]
|
||||||
[connection signal="wrong_way" from="." to="Wrong Way" method="_on_RaceTrack_wrong_way"]
|
[connection signal="wrong_way" from="." to="Wrong Way" method="_on_RaceTrack_wrong_way"]
|
||||||
[connection signal="lap_completed" from="TrackPath/Player" to="GUI" method="_on_lap_completed"]
|
|
||||||
|
|||||||
57
TileMap.gd
57
TileMap.gd
@@ -4,12 +4,12 @@ enum { LEFT, RIGHT, UP, DOWN }
|
|||||||
# Enum for tiles from tile_set
|
# Enum for tiles from tile_set
|
||||||
enum { DOWN_LEFT, DOWN_RIGHT, LEFT_RIGHT, START, UP_DOWN, UP_LEFT, UP_RIGHT }
|
enum { DOWN_LEFT, DOWN_RIGHT, LEFT_RIGHT, START, UP_DOWN, UP_LEFT, UP_RIGHT }
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
func _ready():
|
||||||
func _reset():
|
TrackSelection.connect("track_changed", self, "reload_track")
|
||||||
_reload_track()
|
reload_track()
|
||||||
|
|
||||||
func _reload_track():
|
func reload_track():
|
||||||
_clear_tiles()
|
clear_tiles()
|
||||||
var track = TrackSelection.get_current_track()
|
var track = TrackSelection.get_current_track()
|
||||||
for idx in range(track.size()):
|
for idx in range(track.size()):
|
||||||
var cell = track[idx]
|
var cell = track[idx]
|
||||||
@@ -19,37 +19,28 @@ func _reload_track():
|
|||||||
else:
|
else:
|
||||||
var prev = track[idx - 1]
|
var prev = track[idx - 1]
|
||||||
var next = track[wrapi(idx + 1, 0, track.size())]
|
var next = track[wrapi(idx + 1, 0, track.size())]
|
||||||
tile = _find_tile(cell.direction_to(prev), cell.direction_to(next))
|
tile = find_tile(cell.direction_to(prev), cell.direction_to(next))
|
||||||
set_cell(cell.x, cell.y, tile)
|
set_cell(cell.x, cell.y, tile)
|
||||||
|
|
||||||
func _find_tile(prev, next):
|
func find_tile(prev, next):
|
||||||
""" Find the right tile given prev and next directions """
|
""" Find the right tile given prev and next directions """
|
||||||
prev = _as_dir(prev)
|
prev = as_direction(prev)
|
||||||
next = _as_dir(next)
|
next = as_direction(next)
|
||||||
# Could be smarter
|
match [prev, next]:
|
||||||
if prev == LEFT:
|
[LEFT, DOWN]: return DOWN_LEFT
|
||||||
match next:
|
[LEFT, UP]: return UP_LEFT
|
||||||
DOWN: return DOWN_LEFT
|
[LEFT, RIGHT]: return LEFT_RIGHT
|
||||||
UP: return UP_LEFT
|
[RIGHT, DOWN]: return DOWN_RIGHT
|
||||||
RIGHT: return LEFT_RIGHT
|
[RIGHT, UP]: return UP_RIGHT
|
||||||
elif prev == RIGHT:
|
[RIGHT, LEFT]: return LEFT_RIGHT
|
||||||
match next:
|
[UP, DOWN]: return UP_DOWN
|
||||||
DOWN: return DOWN_RIGHT
|
[UP, LEFT]: return UP_LEFT
|
||||||
UP: return UP_RIGHT
|
[UP, RIGHT]: return UP_RIGHT
|
||||||
LEFT: return LEFT_RIGHT
|
[DOWN, UP]: return UP_DOWN
|
||||||
elif prev == UP:
|
[DOWN, LEFT]: return DOWN_LEFT
|
||||||
match next:
|
[DOWN, RIGHT]: return DOWN_RIGHT
|
||||||
DOWN: return UP_DOWN
|
|
||||||
LEFT: return UP_LEFT
|
|
||||||
RIGHT: return UP_RIGHT
|
|
||||||
elif prev == DOWN:
|
|
||||||
match next:
|
|
||||||
UP: return UP_DOWN
|
|
||||||
LEFT: return DOWN_LEFT
|
|
||||||
RIGHT: return DOWN_RIGHT
|
|
||||||
|
|
||||||
|
func as_direction(vector):
|
||||||
func _as_dir(vector):
|
|
||||||
""" Returns the vector direction as a LEFT, RIGHT, UP or DOWN variant """
|
""" Returns the vector direction as a LEFT, RIGHT, UP or DOWN variant """
|
||||||
if abs(vector.x) + abs(vector.y) != 1:
|
if abs(vector.x) + abs(vector.y) != 1:
|
||||||
return -1 # This is not a valid variant
|
return -1 # This is not a valid variant
|
||||||
@@ -67,6 +58,6 @@ func _as_dir(vector):
|
|||||||
#func _process(delta):
|
#func _process(delta):
|
||||||
# pass
|
# pass
|
||||||
|
|
||||||
func _clear_tiles():
|
func clear_tiles():
|
||||||
for cell in get_used_cells():
|
for cell in get_used_cells():
|
||||||
self.set_cell(cell.x, cell.y, -1)
|
self.set_cell(cell.x, cell.y, -1)
|
||||||
114
assets/France_road_sign_B1.svg
Normal file
114
assets/France_road_sign_B1.svg
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
id="svg2985"
|
||||||
|
version="1.1"
|
||||||
|
inkscape:version="0.48.4 r9939"
|
||||||
|
width="485.33627"
|
||||||
|
height="485.33627"
|
||||||
|
sodipodi:docname="600px-France_road_sign_B1j.svg[1].png">
|
||||||
|
<metadata
|
||||||
|
id="metadata2991">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<defs
|
||||||
|
id="defs2989" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1"
|
||||||
|
objecttolerance="10"
|
||||||
|
gridtolerance="10"
|
||||||
|
guidetolerance="10"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:window-width="1272"
|
||||||
|
inkscape:window-height="745"
|
||||||
|
id="namedview2987"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:snap-global="true"
|
||||||
|
inkscape:snap-grids="true"
|
||||||
|
inkscape:snap-bbox="true"
|
||||||
|
inkscape:bbox-paths="true"
|
||||||
|
inkscape:bbox-nodes="true"
|
||||||
|
inkscape:snap-bbox-edge-midpoints="true"
|
||||||
|
inkscape:snap-bbox-midpoints="true"
|
||||||
|
inkscape:object-paths="true"
|
||||||
|
inkscape:snap-intersection-paths="true"
|
||||||
|
inkscape:object-nodes="true"
|
||||||
|
inkscape:snap-smooth-nodes="true"
|
||||||
|
inkscape:snap-midpoints="true"
|
||||||
|
inkscape:snap-object-midpoints="true"
|
||||||
|
inkscape:snap-center="false"
|
||||||
|
fit-margin-top="0"
|
||||||
|
fit-margin-left="0"
|
||||||
|
fit-margin-right="0"
|
||||||
|
fit-margin-bottom="0"
|
||||||
|
inkscape:zoom="0.59970176"
|
||||||
|
inkscape:cx="390.56499"
|
||||||
|
inkscape:cy="244.34365"
|
||||||
|
inkscape:window-x="86"
|
||||||
|
inkscape:window-y="-8"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:current-layer="layer1">
|
||||||
|
<inkscape:grid
|
||||||
|
type="xygrid"
|
||||||
|
id="grid2995"
|
||||||
|
empspacing="5"
|
||||||
|
visible="true"
|
||||||
|
enabled="true"
|
||||||
|
snapvisiblegridlinesonly="true"
|
||||||
|
originx="-57.33186px"
|
||||||
|
originy="-57.33186px" />
|
||||||
|
</sodipodi:namedview>
|
||||||
|
<g
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1"
|
||||||
|
inkscape:label="1"
|
||||||
|
style="display:inline"
|
||||||
|
transform="translate(-57.33186,-57.33186)">
|
||||||
|
<path
|
||||||
|
sodipodi:type="arc"
|
||||||
|
style="color:#000000;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.5;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||||
|
id="path2997"
|
||||||
|
sodipodi:cx="300"
|
||||||
|
sodipodi:cy="300"
|
||||||
|
sodipodi:rx="240"
|
||||||
|
sodipodi:ry="240"
|
||||||
|
d="M 540,300 C 540,432.54834 432.54834,540 300,540 167.45166,540 60,432.54834 60,300 60,167.45166 167.45166,60 300,60 432.54834,60 540,167.45166 540,300 z"
|
||||||
|
transform="matrix(1.0058783,0,0,1.0058783,-1.76349,-1.76349)" />
|
||||||
|
<path
|
||||||
|
sodipodi:type="arc"
|
||||||
|
style="color:#000000;fill:#ff0000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.5;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||||
|
id="path4005"
|
||||||
|
sodipodi:cx="304.75"
|
||||||
|
sodipodi:cy="214.75"
|
||||||
|
sodipodi:rx="44.75"
|
||||||
|
sodipodi:ry="44.75"
|
||||||
|
d="m 349.5,214.75 c 0,24.71474 -20.03526,44.75 -44.75,44.75 -24.71474,0 -44.75,-20.03526 -44.75,-44.75 0,-24.71474 20.03526,-44.75 44.75,-44.75 24.71474,0 44.75,20.03526 44.75,44.75 z"
|
||||||
|
transform="matrix(5.1364411,0,0,5.1364411,-1265.3304,-803.05073)" />
|
||||||
|
<rect
|
||||||
|
style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.5;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||||
|
id="rect4001"
|
||||||
|
width="345"
|
||||||
|
height="80.599998"
|
||||||
|
x="127.5"
|
||||||
|
y="259.70001" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 4.0 KiB |
34
assets/France_road_sign_B1.svg.import
Normal file
34
assets/France_road_sign_B1.svg.import
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture"
|
||||||
|
path="res://.import/France_road_sign_B1.svg-69d4cf188193981c0635f7ce7bfdfc6d.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/France_road_sign_B1.svg"
|
||||||
|
dest_files=[ "res://.import/France_road_sign_B1.svg-69d4cf188193981c0635f7ce7bfdfc6d.stex" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_mode=0
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
flags/repeat=0
|
||||||
|
flags/filter=true
|
||||||
|
flags/mipmaps=false
|
||||||
|
flags/anisotropic=false
|
||||||
|
flags/srgb=2
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/HDR_as_SRGB=false
|
||||||
|
process/invert_color=false
|
||||||
|
stream=false
|
||||||
|
size_limit=0
|
||||||
|
detect_3d=true
|
||||||
|
svg/scale=1.0
|
||||||
8
assets/tracks/Circuit_de_bernede.txt
Normal file
8
assets/tracks/Circuit_de_bernede.txt
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
...............
|
||||||
|
.xxsxxxxxxxx...
|
||||||
|
.x.........xxx.
|
||||||
|
.x...xxxxx...x.
|
||||||
|
.x...x...x...x.
|
||||||
|
.xxxxx...xxxxx.
|
||||||
|
...............
|
||||||
|
...............
|
||||||
8
assets/tracks/track2.txt
Normal file
8
assets/tracks/track2.txt
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
...............
|
||||||
|
.xxxsxxxxxxxxx.
|
||||||
|
.x...........x.
|
||||||
|
.x...........x.
|
||||||
|
.xxxxxxxx....x.
|
||||||
|
........x....x.
|
||||||
|
........xxxxxx.
|
||||||
|
...............
|
||||||
@@ -4,9 +4,8 @@ name="Linux/X11"
|
|||||||
platform="Linux/X11"
|
platform="Linux/X11"
|
||||||
runnable=true
|
runnable=true
|
||||||
custom_features=""
|
custom_features=""
|
||||||
export_filter="scenes"
|
export_filter="all_resources"
|
||||||
export_files=PoolStringArray( "res://Track1.tscn" )
|
include_filter="*.txt"
|
||||||
include_filter=""
|
|
||||||
exclude_filter=""
|
exclude_filter=""
|
||||||
export_path="/mnt/Data/Projets/godot/CarRacer/release.x86_64"
|
export_path="/mnt/Data/Projets/godot/CarRacer/release.x86_64"
|
||||||
patch_list=PoolStringArray( )
|
patch_list=PoolStringArray( )
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[gd_resource type="DynamicFont" load_steps=2 format=2]
|
[gd_resource type="DynamicFont" load_steps=2 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://Oswald-Bold.otf" type="DynamicFontData" id=1]
|
[ext_resource path="res://assets/Oswald-Bold.otf" type="DynamicFontData" id=1]
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
resource_name = "BaseFont"
|
resource_name = "BaseFont"
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
extends PathFollow2D
|
extends PathFollow2D
|
||||||
|
|
||||||
signal lap_completed(laps)
|
export (float) var speed = 0.250
|
||||||
|
|
||||||
export (float) var speed = 0.125
|
|
||||||
|
|
||||||
var position_on_track := 0.0
|
var position_on_track := 0.0
|
||||||
var target_on_track := 0.0
|
var target_on_track := 0.0
|
||||||
@@ -11,7 +9,6 @@ func _process(delta):
|
|||||||
# Check if a lap was completed
|
# Check if a lap was completed
|
||||||
if int(position_on_track) > Global.laps:
|
if int(position_on_track) > Global.laps:
|
||||||
Global.laps += 1
|
Global.laps += 1
|
||||||
emit_signal("lap_completed", Global.laps)
|
|
||||||
|
|
||||||
# Move the player until target_on_track
|
# Move the player until target_on_track
|
||||||
elif target_on_track - position_on_track > 0.01:
|
elif target_on_track - position_on_track > 0.01:
|
||||||
@@ -25,10 +25,6 @@ config/icon="res://icon.png"
|
|||||||
Global="*res://Global.gd"
|
Global="*res://Global.gd"
|
||||||
TrackSelection="*res://track_selection.gd"
|
TrackSelection="*res://track_selection.gd"
|
||||||
|
|
||||||
[debug]
|
|
||||||
|
|
||||||
settings/stdout/print_fps=true
|
|
||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|
||||||
window/size/width=1920
|
window/size/width=1920
|
||||||
|
|||||||
101
race_track.gd
Normal file
101
race_track.gd
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
extends Node
|
||||||
|
# This is where the racing logic is handled (player car input and movement,
|
||||||
|
# ensuring valid path, ...)
|
||||||
|
# We keep informations on player progress here.
|
||||||
|
signal player_moved(track_offset)
|
||||||
|
signal wrong_way(coords)
|
||||||
|
|
||||||
|
|
||||||
|
# TODO :
|
||||||
|
# - Keyboard controls !!
|
||||||
|
|
||||||
|
var laps # This is duplicated here becayse of the track offset logic
|
||||||
|
var current_cell
|
||||||
|
var next_cell
|
||||||
|
var track = null
|
||||||
|
onready var map = $TileMap
|
||||||
|
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
TrackSelection.connect("track_changed", self, "_reset_state")
|
||||||
|
_reset_state()
|
||||||
|
|
||||||
|
|
||||||
|
func _input(event):
|
||||||
|
match Global.settings.input_mode:
|
||||||
|
Global.InputMode.MOUSE:
|
||||||
|
_handle_mouse_input(event)
|
||||||
|
Global.InputMode.KEYBOARD:
|
||||||
|
_handle_keyboard_input(event)
|
||||||
|
|
||||||
|
|
||||||
|
func step_next():
|
||||||
|
""" Step this module state to the next cell """
|
||||||
|
current_cell = next_cell
|
||||||
|
var current_idx = track.find(current_cell)
|
||||||
|
var next_idx = current_idx + 1 if current_idx < track.size() - 1 else 0
|
||||||
|
next_cell = track[next_idx]
|
||||||
|
emit_signal("player_moved", laps + get_track_offset(current_cell))
|
||||||
|
emit_signal("wrong_way", Vector2(-1, -1)) # Cancel any wrong way sign
|
||||||
|
|
||||||
|
func _handle_keyboard_input(event):
|
||||||
|
if event is InputEventKey:
|
||||||
|
var direction_to_next = current_cell.direction_to(next_cell)
|
||||||
|
if event.is_action_pressed("ui_up"):
|
||||||
|
print_debug("Up key")
|
||||||
|
if direction_to_next == Vector2(0, -1):
|
||||||
|
step_next()
|
||||||
|
else:
|
||||||
|
emit_signal("wrong_way", map.map_to_world(Vector2(current_cell.x, current_cell.y - 1)))
|
||||||
|
elif event.is_action_pressed("ui_right"):
|
||||||
|
print_debug("Right key")
|
||||||
|
if direction_to_next == Vector2(1, 0):
|
||||||
|
step_next()
|
||||||
|
else:
|
||||||
|
emit_signal("wrong_way", map.map_to_world(Vector2(current_cell.x + 1, current_cell.y)))
|
||||||
|
elif event.is_action_pressed("ui_left"):
|
||||||
|
print_debug("Left key")
|
||||||
|
if direction_to_next == Vector2(-1, 0):
|
||||||
|
step_next()
|
||||||
|
else:
|
||||||
|
emit_signal("wrong_way", map.map_to_world(Vector2(current_cell.x - 1, current_cell.y)))
|
||||||
|
elif event.is_action_pressed("ui_down"):
|
||||||
|
print_debug("Key down")
|
||||||
|
if direction_to_next == Vector2(0, 1):
|
||||||
|
step_next()
|
||||||
|
else:
|
||||||
|
emit_signal("wrong_way", map.map_to_world(Vector2(current_cell.x, current_cell.y + 1)))
|
||||||
|
|
||||||
|
|
||||||
|
func _handle_mouse_input(event):
|
||||||
|
# Check if the mouse if following the tiles track
|
||||||
|
if event is InputEventMouseMotion:
|
||||||
|
var hover_cell = map.world_to_map(event.position)
|
||||||
|
if hover_cell != current_cell: # The mouse moved to a new cell
|
||||||
|
var cell_idx = track.find(hover_cell)
|
||||||
|
# Check the tile is on path
|
||||||
|
if cell_idx != -1:
|
||||||
|
# Check we are following the path
|
||||||
|
if hover_cell == next_cell:
|
||||||
|
# Check if lap is completed. This is required
|
||||||
|
# because the input can be way ahead player car sprite
|
||||||
|
if next_cell == track[0]:
|
||||||
|
laps += 1
|
||||||
|
# We use the loop property of PathFollow2D to embed
|
||||||
|
# laps count inside the offset.
|
||||||
|
step_next()
|
||||||
|
else:
|
||||||
|
emit_signal("wrong_way", map.map_to_world(hover_cell))
|
||||||
|
|
||||||
|
|
||||||
|
func get_track_offset(coords):
|
||||||
|
# Returns the offset in Path2D of a track cell.
|
||||||
|
var offset = float(track.find(coords)) / float(len(track))
|
||||||
|
return offset
|
||||||
|
|
||||||
|
|
||||||
|
func _reset_state():
|
||||||
|
track = TrackSelection.get_current_track()
|
||||||
|
laps = 0
|
||||||
|
current_cell = track[0]
|
||||||
|
next_cell = track[1]
|
||||||
@@ -6,8 +6,12 @@ var tile_size : int = 128
|
|||||||
var half_size : int = tile_size / 2
|
var half_size : int = tile_size / 2
|
||||||
onready var map = get_node("../TileMap/")
|
onready var map = get_node("../TileMap/")
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
TrackSelection.connect("track_changed", self, "_reset_state")
|
||||||
|
_reset_state()
|
||||||
|
|
||||||
# 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 _reset():
|
func _reset_state():
|
||||||
var track = TrackSelection.get_current_track()
|
var track = TrackSelection.get_current_track()
|
||||||
_build_track(track)
|
_build_track(track)
|
||||||
$Opponent.set_offset(0.0)
|
$Opponent.set_offset(0.0)
|
||||||
@@ -50,7 +54,7 @@ func _build_track(tiles):
|
|||||||
# pass
|
# pass
|
||||||
|
|
||||||
func _point_at(_curve, pos, dir):
|
func _point_at(_curve, pos, dir):
|
||||||
# Use only control_in since it gives smoother turns
|
# Using only control_in gives smoother turns
|
||||||
var half_size = tile_size / 2
|
var half_size = tile_size / 2
|
||||||
var control_in
|
var control_in
|
||||||
match dir:
|
match dir:
|
||||||
@@ -1,24 +1,35 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
# This is an autoload script handling things related to track data and state.
|
||||||
|
|
||||||
|
signal track_changed()
|
||||||
|
|
||||||
const TRACKS_PATH = "res://assets/tracks/"
|
const TRACKS_PATH = "res://assets/tracks/"
|
||||||
|
|
||||||
var _tracks = []
|
var _tracks = []
|
||||||
var _selected : int = 1
|
var _selected : int
|
||||||
|
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
_load_tracks()
|
_load_tracks()
|
||||||
|
_selected = 0
|
||||||
|
emit_signal("track_changed")
|
||||||
|
|
||||||
|
|
||||||
func set_next_track():
|
func set_next_track():
|
||||||
_selected = wrapi(_selected + 1, 0, _tracks.size())
|
_selected = wrapi(_selected + 1, 0, _tracks.size())
|
||||||
print("set_next_track : ", _selected)
|
emit_signal("track_changed")
|
||||||
|
|
||||||
|
|
||||||
func set_previous_track():
|
func set_previous_track():
|
||||||
_selected = wrapi(_selected - 1, 0, _tracks.size())
|
_selected = wrapi(_selected - 1, 0, _tracks.size())
|
||||||
|
emit_signal("track_changed")
|
||||||
|
|
||||||
|
|
||||||
func get_current_track():
|
func get_current_track():
|
||||||
return _tracks[_selected]
|
return _tracks[_selected]["path"]
|
||||||
|
|
||||||
|
|
||||||
|
func get_current_track_name():
|
||||||
|
return _tracks[_selected]["name"]
|
||||||
|
|
||||||
|
|
||||||
func _load_tracks():
|
func _load_tracks():
|
||||||
@@ -27,8 +38,12 @@ func _load_tracks():
|
|||||||
var file = File.new()
|
var file = File.new()
|
||||||
file.open(path, File.READ)
|
file.open(path, File.READ)
|
||||||
var track = _load_from_txt(file.get_as_text())
|
var track = _load_from_txt(file.get_as_text())
|
||||||
|
var track_name = path.get_file().rstrip(".%s" % path.get_extension())
|
||||||
if track.size() > 1:
|
if track.size() > 1:
|
||||||
loaded.append(track)
|
loaded.append({
|
||||||
|
"name": track_name,
|
||||||
|
"path": track,
|
||||||
|
})
|
||||||
else:
|
else:
|
||||||
print("Error in track file : ", path)
|
print("Error in track file : ", path)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
extends Label
|
extends TextureRect
|
||||||
|
|
||||||
# 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():
|
func _ready():
|
||||||
@@ -10,4 +10,4 @@ func _on_RaceTrack_wrong_way(coords):
|
|||||||
set_visible(false)
|
set_visible(false)
|
||||||
else:
|
else:
|
||||||
set_visible(true)
|
set_visible(true)
|
||||||
set_position(coords)
|
set_position(Vector2(coords.x + 32, coords.y + 32))
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
[gd_scene load_steps=4 format=2]
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://Oswald-Bold.otf" type="DynamicFontData" id=1]
|
[ext_resource path="res://assets/Oswald-Bold.otf" type="DynamicFontData" id=1]
|
||||||
[ext_resource path="res://Wrong Way.gd" type="Script" id=2]
|
[ext_resource path="res://wrong_way.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[sub_resource type="DynamicFont" id=5]
|
[sub_resource type="DynamicFont" id=5]
|
||||||
size = 40
|
size = 40
|
||||||
|
|||||||
Reference in New Issue
Block a user