Initial commit
Un bout de jeu, qui fait pas grand chose mais on progresse.
This commit is contained in:
33
vehicules/voiture.gd
Normal file
33
vehicules/voiture.gd
Normal file
@@ -0,0 +1,33 @@
|
||||
class_name Voiture
|
||||
extends Area2D
|
||||
|
||||
var prevPositionX = 0;
|
||||
var prevPositionY = 0;
|
||||
|
||||
func updatePosition(x: float, y: float) -> void:
|
||||
var velocityX = prevPositionX - x;
|
||||
var velocityY = prevPositionY - y;
|
||||
$shapeDown.set_deferred("disabled", true);
|
||||
$shapeUp.set_deferred("disabled", true);
|
||||
$shapeLeft.set_deferred("disabled", true);
|
||||
$shapeRight.set_deferred("disabled", true);
|
||||
if(abs(velocityX) > abs(velocityY)):
|
||||
if velocityX > 0 :
|
||||
$AnimatedSprite2D.animation = "driving_left";
|
||||
$shapeLeft.set_deferred("disabled", false);
|
||||
if velocityX < 0 :
|
||||
$AnimatedSprite2D.animation = "driving_right";
|
||||
$shapeRight.set_deferred("disabled", false);
|
||||
if(abs(velocityX) < abs(velocityY)):
|
||||
if velocityY > 0 :
|
||||
$AnimatedSprite2D.animation = "driving_up";
|
||||
$shapeUp.set_deferred("disabled", false);
|
||||
if velocityY < 0 :
|
||||
$AnimatedSprite2D.animation = "driving_down";
|
||||
$shapeDown.set_deferred("disabled", false);
|
||||
prevPositionX = x;
|
||||
prevPositionY = y;
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
$AnimatedSprite2D.play()
|
||||
244
vehicules/voiture.tscn
Normal file
244
vehicules/voiture.tscn
Normal file
@@ -0,0 +1,244 @@
|
||||
[gd_scene load_steps=33 format=3 uid="uid://bt1p311rn1h6q"]
|
||||
|
||||
[ext_resource type="Script" path="res://vehicules/voiture.gd" id="1_3v1b0"]
|
||||
[ext_resource type="Texture2D" uid="uid://55dsls4caujg" path="res://assest/vehicules/Car_classic_red_complete_48x48.png" id="1_hqmt6"]
|
||||
[ext_resource type="Texture2D" uid="uid://c5dis1wikcqws" path="res://assest/vehicules/Car_classic_red_complete_48x48_left.png" id="2_6v2yy"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_8fi8c"]
|
||||
atlas = ExtResource("1_hqmt6")
|
||||
region = Rect2(3408, 222, 96, 210)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_tgw3a"]
|
||||
atlas = ExtResource("1_hqmt6")
|
||||
region = Rect2(3504, 222, 96, 210)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_dj0xl"]
|
||||
atlas = ExtResource("1_hqmt6")
|
||||
region = Rect2(3600, 222, 96, 210)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_omrb2"]
|
||||
atlas = ExtResource("1_hqmt6")
|
||||
region = Rect2(3696, 222, 96, 210)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_l4q1w"]
|
||||
atlas = ExtResource("1_hqmt6")
|
||||
region = Rect2(3792, 222, 96, 210)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qjaw0"]
|
||||
atlas = ExtResource("1_hqmt6")
|
||||
region = Rect2(3888, 222, 96, 210)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_cjmr1"]
|
||||
atlas = ExtResource("2_6v2yy")
|
||||
region = Rect2(0, 0, 240, 144)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_0i1ge"]
|
||||
atlas = ExtResource("2_6v2yy")
|
||||
region = Rect2(240, 0, 240, 144)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_lss5r"]
|
||||
atlas = ExtResource("2_6v2yy")
|
||||
region = Rect2(480, 0, 240, 144)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_8ccj1"]
|
||||
atlas = ExtResource("2_6v2yy")
|
||||
region = Rect2(720, 0, 240, 144)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_lrp4n"]
|
||||
atlas = ExtResource("2_6v2yy")
|
||||
region = Rect2(960, 0, 240, 144)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qnkpb"]
|
||||
atlas = ExtResource("2_6v2yy")
|
||||
region = Rect2(1200, 0, 240, 144)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_n03o5"]
|
||||
atlas = ExtResource("1_hqmt6")
|
||||
region = Rect2(0, 192, 240, 144)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_3k4i1"]
|
||||
atlas = ExtResource("1_hqmt6")
|
||||
region = Rect2(240, 192, 240, 144)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_pg1lo"]
|
||||
atlas = ExtResource("1_hqmt6")
|
||||
region = Rect2(480, 192, 240, 144)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_3b1y7"]
|
||||
atlas = ExtResource("1_hqmt6")
|
||||
region = Rect2(720, 192, 240, 144)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_1jisb"]
|
||||
atlas = ExtResource("1_hqmt6")
|
||||
region = Rect2(960, 192, 240, 144)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_4lngy"]
|
||||
atlas = ExtResource("1_hqmt6")
|
||||
region = Rect2(1200, 192, 240, 144)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_xng4i"]
|
||||
atlas = ExtResource("1_hqmt6")
|
||||
region = Rect2(1440, 210, 96, 210)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_yy3vy"]
|
||||
atlas = ExtResource("1_hqmt6")
|
||||
region = Rect2(1536, 210, 96, 210)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_cax1g"]
|
||||
atlas = ExtResource("1_hqmt6")
|
||||
region = Rect2(1632, 210, 96, 210)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_6dv7n"]
|
||||
atlas = ExtResource("1_hqmt6")
|
||||
region = Rect2(1728, 210, 96, 210)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_7f8f4"]
|
||||
atlas = ExtResource("1_hqmt6")
|
||||
region = Rect2(1824, 210, 96, 210)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_vy1dr"]
|
||||
atlas = ExtResource("1_hqmt6")
|
||||
region = Rect2(1920, 210, 96, 210)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_77j28"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_8fi8c")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_tgw3a")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_dj0xl")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_omrb2")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_l4q1w")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_qjaw0")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"driving_down",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_cjmr1")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_0i1ge")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_lss5r")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_8ccj1")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_lrp4n")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_qnkpb")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"driving_left",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_n03o5")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_3k4i1")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_pg1lo")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_3b1y7")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_1jisb")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_4lngy")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"driving_right",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_xng4i")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_yy3vy")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_cax1g")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_6dv7n")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_7f8f4")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_vy1dr")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"driving_up",
|
||||
"speed": 5.0
|
||||
}]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_5yhvy"]
|
||||
radius = 35.5
|
||||
height = 158.0
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_bevht"]
|
||||
radius = 38.0026
|
||||
height = 150.043
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_w52g8"]
|
||||
radius = 29.0752
|
||||
height = 172.0
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_j5vcu"]
|
||||
radius = 33.0
|
||||
height = 174.0
|
||||
|
||||
[node name="Area2D" type="Area2D"]
|
||||
position = Vector2(-664, 181)
|
||||
script = ExtResource("1_3v1b0")
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
rotation = -0.00268924
|
||||
sprite_frames = SubResource("SpriteFrames_77j28")
|
||||
animation = &"driving_right"
|
||||
autoplay = "driving_right"
|
||||
|
||||
[node name="shapeDown" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(1.5, 16)
|
||||
shape = SubResource("CapsuleShape2D_5yhvy")
|
||||
|
||||
[node name="shapeUp" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(1, -20)
|
||||
rotation = -0.00268924
|
||||
scale = Vector2(1, 1)
|
||||
shape = SubResource("CapsuleShape2D_bevht")
|
||||
|
||||
[node name="shapeLeft" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(-29, 29)
|
||||
rotation = 1.5708
|
||||
scale = Vector2(1, 1)
|
||||
shape = SubResource("CapsuleShape2D_w52g8")
|
||||
|
||||
[node name="shapeRight" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(28, 27)
|
||||
rotation = 1.5708
|
||||
scale = Vector2(1, 1)
|
||||
shape = SubResource("CapsuleShape2D_j5vcu")
|
||||
20
vehicules/voiture_pnj.tscn
Normal file
20
vehicules/voiture_pnj.tscn
Normal file
@@ -0,0 +1,20 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://cl201baro5y5"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/pathFollow.gd" id="1_fbnn2"]
|
||||
[ext_resource type="PackedScene" uid="uid://bt1p311rn1h6q" path="res://vehicules/voiture.tscn" id="2_4yiv6"]
|
||||
|
||||
[node name="voiture_pnj" type="PathFollow2D"]
|
||||
position = Vector2(-411, 81)
|
||||
rotates = false
|
||||
script = ExtResource("1_fbnn2")
|
||||
|
||||
[node name="voiture" parent="." instance=ExtResource("2_4yiv6")]
|
||||
position = Vector2(-1, 0)
|
||||
|
||||
[node name="RayCast2D" type="RayCast2D" parent="."]
|
||||
position = Vector2(1, 0)
|
||||
target_position = Vector2(297, 58)
|
||||
|
||||
[node name="RayCast2D2" type="RayCast2D" parent="."]
|
||||
position = Vector2(1, 49)
|
||||
target_position = Vector2(298, -47)
|
||||
Reference in New Issue
Block a user