From ba72a1b3794899b774535166962385438c3d4077 Mon Sep 17 00:00:00 2001 From: as4s4hetic Date: Thu, 27 Jan 2022 23:12:13 +1100 Subject: [PATCH] more physics on car --- Scenes/Car.tscn | 12 +++++- Scripts/Car.gd | 50 ++++++++++++++++++++++++ Scripts/ScrollCamera.gd | 1 + Sprites/alistair/car-full-2a.png | Bin 0 -> 3959 bytes Sprites/alistair/car-full-2a.png.import | 35 +++++++++++++++++ Sprites/alistair/car-full-3a.png | Bin 0 -> 3999 bytes Sprites/alistair/car-full-3a.png.import | 35 +++++++++++++++++ Story/Ch1S1.tscn | 2 +- 8 files changed, 132 insertions(+), 3 deletions(-) create mode 100644 Scripts/Car.gd create mode 100644 Sprites/alistair/car-full-2a.png create mode 100644 Sprites/alistair/car-full-2a.png.import create mode 100644 Sprites/alistair/car-full-3a.png create mode 100644 Sprites/alistair/car-full-3a.png.import diff --git a/Scenes/Car.tscn b/Scenes/Car.tscn index 98649cc..c716ef4 100644 --- a/Scenes/Car.tscn +++ b/Scenes/Car.tscn @@ -1,10 +1,12 @@ -[gd_scene load_steps=8 format=2] +[gd_scene load_steps=10 format=2] -[ext_resource path="res://Car.gd" type="Script" id=1] +[ext_resource path="res://Scripts/Car.gd" type="Script" id=1] [ext_resource path="res://Sprites/alistair/car-full-1.png" type="Texture" id=2] [ext_resource path="res://Sprites/alistair/car-full-2.png" type="Texture" id=3] [ext_resource path="res://Sprites/alistair/car-full.png" type="Texture" id=4] [ext_resource path="res://Sprites/alistair/car-full-3.png" type="Texture" id=5] +[ext_resource path="res://Sprites/alistair/car-full-3a.png" type="Texture" id=6] +[ext_resource path="res://Sprites/alistair/car-full-2a.png" type="Texture" id=7] [sub_resource type="SpriteFrames" id=1] animations = [ { @@ -12,6 +14,11 @@ animations = [ { "loop": true, "name": "default", "speed": 5.0 +}, { +"frames": [ ExtResource( 4 ), ExtResource( 2 ), ExtResource( 7 ), ExtResource( 6 ) ], +"loop": true, +"name": "Accelerate", +"speed": 20.0 } ] [sub_resource type="CapsuleShape2D" id=2] @@ -24,6 +31,7 @@ script = ExtResource( 1 ) [node name="AnimatedSprite" type="AnimatedSprite" parent="."] position = Vector2( 0, -42 ) frames = SubResource( 1 ) +animation = "Accelerate" [node name="CollisionShape2D" type="CollisionShape2D" parent="."] position = Vector2( 0, 3 ) diff --git a/Scripts/Car.gd b/Scripts/Car.gd new file mode 100644 index 0000000..eea01ff --- /dev/null +++ b/Scripts/Car.gd @@ -0,0 +1,50 @@ +extends KinematicBody2D + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + + +# Called when the node enters the scene tree for the first time. +var moveSpeed : int = 280 +var vel = Vector2() +var facingDir = Vector2() +onready var rayCast = $RayCast2D +onready var anim = $AnimatedSprite + +func _ready(): + pass + +func _physics_process(delta): + handle_movements() + manage_animations() + +func handle_movements(): + vel = Vector2(-1, 0) + + # inputs + if Input.is_action_pressed("move_up"): + vel.y = -1 + if Input.is_action_pressed("move_down"): + vel.y = 1 + if Input.is_action_pressed("move_left"): + moveSpeed += 5 + else: + moveSpeed -= 1 + if Input.is_action_pressed("move_right"): + moveSpeed -= 5 + moveSpeed = clamp(moveSpeed, 280, 500) + + # move the player + move_and_slide(vel * moveSpeed, Vector2.ZERO) + +func play_animation (anim_name): + if anim.animation != anim_name: + anim.play(anim_name) + +func manage_animations (): + if Input.is_action_pressed("move_left"): + play_animation("Accelerate") + else: + play_animation("default") diff --git a/Scripts/ScrollCamera.gd b/Scripts/ScrollCamera.gd index 331769c..6bf7beb 100644 --- a/Scripts/ScrollCamera.gd +++ b/Scripts/ScrollCamera.gd @@ -18,3 +18,4 @@ onready var target = get_node("../Player") func _process (delta): position = target.position position.y -= 240 + position.x -= 480 diff --git a/Sprites/alistair/car-full-2a.png b/Sprites/alistair/car-full-2a.png new file mode 100644 index 0000000000000000000000000000000000000000..e55842457257575018ab6eaced6ba82aff7c996c GIT binary patch literal 3959 zcmbtXc{r49`<`BfXlxa)u@tgzHB6C=GGvKRlON5akLP%f`?;_CzO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i@_Rm^`U^B?cSMhEGbPV3+w zK4!sZ8<8O&w3%F=A?1GWZwfL>)T5&@c7JTJLj{KmNn+CZ#H075pcE zfW>(MC#p(ePtJu-pehZ>9jaZia1JFpx2#P;U&!7mF8BO3>H$UI+O>OCT zB7X}^jIHtP_}bJun7K)2Emcy!gmY1Gh2Y4&4{5o9EZ;seR<^h<0ZUo&i#lA&z!pfdLW#f0qS(3)oawXzXH7;N#_Z>0q)os4L#uaJyK8JJ;$m&w` z>J>NC$NuCd+pOyZU4B!gpBzfm8(Dr^Ax4AH>jLV(w(xmqH~QFvJhJ{qGRSFt$Ywoy zdlp1twn~7}k-nCtBZdwCxHV&Q)ZSzroIv%U4m{OT5VlbHvcx#&==!iv8d|Lg5ndZH-^&_C1KMh9=h4CmAKgmb)996?_OyZs9^vJjU13gpF^>&q#9yz0U| zY8d|hzJUGPPBr`a2(1e|4E(Xmy*^H&5S)K)xOscQ@>lM!199$4B?zZco6#Z1n>z&2Z-f|zEWHEM+<&y-K3!(deu{mIj@3YsMF{F8O9R+sgq-fbOZ-3ldH%ms cuYBAB;^*$Z_>@I9{hnlIWMxRadi%kD0X;%%-2eap literal 0 HcmV?d00001 diff --git a/Sprites/alistair/car-full-3a.png.import b/Sprites/alistair/car-full-3a.png.import new file mode 100644 index 0000000..7aaee96 --- /dev/null +++ b/Sprites/alistair/car-full-3a.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/car-full-3a.png-376bde5618312891a4e2f322b963c7d6.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Sprites/alistair/car-full-3a.png" +dest_files=[ "res://.import/car-full-3a.png-376bde5618312891a4e2f322b963c7d6.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 +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/Story/Ch1S1.tscn b/Story/Ch1S1.tscn index 1557c13..e5f3403 100644 --- a/Story/Ch1S1.tscn +++ b/Story/Ch1S1.tscn @@ -119,7 +119,7 @@ motion_mirroring = Vector2( 2880, 0 ) tile_set = ExtResource( 1 ) cell_y_sort = true format = 1 -tile_data = PoolIntArray( -262132, 536870935, 0, -262113, 536870935, 0, -196608, 24, 0, -65499, 536870934, 0, 17, 28, 0 ) +tile_data = PoolIntArray( -262132, 536870935, 0, -262113, 536870935, 0, -196608, 24, 0, -65499, 536870934, 0, 19, 536870940, 0 ) [node name="Grass" type="TileMap" parent="Background/Close"] tile_set = ExtResource( 1 )