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 0000000..e558424 Binary files /dev/null and b/Sprites/alistair/car-full-2a.png differ diff --git a/Sprites/alistair/car-full-2a.png.import b/Sprites/alistair/car-full-2a.png.import new file mode 100644 index 0000000..52b31d5 --- /dev/null +++ b/Sprites/alistair/car-full-2a.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/car-full-2a.png-0f64cdfb4ad576205590422cb4a652b5.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Sprites/alistair/car-full-2a.png" +dest_files=[ "res://.import/car-full-2a.png-0f64cdfb4ad576205590422cb4a652b5.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/Sprites/alistair/car-full-3a.png b/Sprites/alistair/car-full-3a.png new file mode 100644 index 0000000..6c46a70 Binary files /dev/null and b/Sprites/alistair/car-full-3a.png differ 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 )