Added all the things
This commit is contained in:
commit
417044bfda
11
.gitignore
vendored
Normal file
11
.gitignore
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
# Godot-specific ignores
|
||||
.import/
|
||||
export.cfg
|
||||
export_presets.cfg
|
||||
|
||||
# Imported translations (automatically generated from CSV files)
|
||||
*.translation
|
||||
|
||||
# Mono-specific ignores
|
||||
.mono/
|
||||
data_*/
|
BIN
10-pixel-art-square-mike-taylor.jpg
Normal file
BIN
10-pixel-art-square-mike-taylor.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 42 KiB |
35
10-pixel-art-square-mike-taylor.jpg.import
Normal file
35
10-pixel-art-square-mike-taylor.jpg.import
Normal file
|
@ -0,0 +1,35 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/10-pixel-art-square-mike-taylor.jpg-885b8df56355b977dcb318a4e8ff3a07.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://10-pixel-art-square-mike-taylor.jpg"
|
||||
dest_files=[ "res://.import/10-pixel-art-square-mike-taylor.jpg-885b8df56355b977dcb318a4e8ff3a07.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
|
7
default_env.tres
Normal file
7
default_env.tres
Normal file
|
@ -0,0 +1,7 @@
|
|||
[gd_resource type="Environment" load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="ProceduralSky" id=1]
|
||||
|
||||
[resource]
|
||||
background_mode = 2
|
||||
background_sky = SubResource( 1 )
|
35
icon.png.import
Normal file
35
icon.png.import
Normal file
|
@ -0,0 +1,35 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.png"
|
||||
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.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
|
59
project.godot
Normal file
59
project.godot
Normal file
|
@ -0,0 +1,59 @@
|
|||
; Engine configuration file.
|
||||
; It's best edited using the editor UI and not directly,
|
||||
; since the parameters that go here are not all obvious.
|
||||
;
|
||||
; Format:
|
||||
; [section] ; section goes between []
|
||||
; param=value ; assign values to parameters
|
||||
|
||||
config_version=4
|
||||
|
||||
_global_script_classes=[ {
|
||||
"base": "KinematicBody2D",
|
||||
"class": "Neighbor",
|
||||
"language": "GDScript",
|
||||
"path": "res://scripts/neighbor.gd"
|
||||
}, {
|
||||
"base": "KinematicBody2D",
|
||||
"class": "Player",
|
||||
"language": "GDScript",
|
||||
"path": "res://scripts/player.gd"
|
||||
}, {
|
||||
"base": "KinematicBody2D",
|
||||
"class": "Trolley",
|
||||
"language": "GDScript",
|
||||
"path": "res://scripts/trolley.gd"
|
||||
} ]
|
||||
_global_script_class_icons={
|
||||
"Neighbor": "",
|
||||
"Player": "",
|
||||
"Trolley": ""
|
||||
}
|
||||
|
||||
[application]
|
||||
|
||||
config/name="roger"
|
||||
run/main_scene="res://scenes/stage.tscn"
|
||||
config/icon="res://icon.png"
|
||||
|
||||
[display]
|
||||
|
||||
window/size/width=1280
|
||||
window/size/height=960
|
||||
|
||||
[layer_names]
|
||||
|
||||
2d_physics/layer_1="player"
|
||||
2d_physics/layer_2="npc"
|
||||
2d_physics/layer_3="obstacle"
|
||||
|
||||
[physics]
|
||||
|
||||
common/enable_pause_aware_picking=true
|
||||
|
||||
[rendering]
|
||||
|
||||
quality/driver/driver_name="GLES2"
|
||||
vram_compression/import_etc=true
|
||||
vram_compression/import_etc2=false
|
||||
environment/default_environment="res://default_env.tres"
|
44
scenes/house.tscn
Normal file
44
scenes/house.tscn
Normal file
|
@ -0,0 +1,44 @@
|
|||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://scripts/house.gd" type="Script" id=1]
|
||||
[ext_resource path="res://roger-roger/chadHouse.png" type="Texture" id=2]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=3]
|
||||
radius = 12.2857
|
||||
height = 2.57142
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=4]
|
||||
extents = Vector2( 86, 63.5 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=2]
|
||||
extents = Vector2( 3.5, 2 )
|
||||
|
||||
[node name="House" type="Node2D"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
position = Vector2( 0, -125 )
|
||||
scale = Vector2( 5, 5 )
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="HouseBody" type="StaticBody2D" parent="."]
|
||||
collision_layer = 4
|
||||
collision_mask = 7
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="HouseBody"]
|
||||
position = Vector2( -7, -90 )
|
||||
scale = Vector2( 7, 7 )
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="HouseBody"]
|
||||
position = Vector2( -6, -49.5 )
|
||||
shape = SubResource( 4 )
|
||||
|
||||
[node name="DoorBody" type="StaticBody2D" parent="."]
|
||||
scale = Vector2( 7, 7 )
|
||||
collision_layer = 4
|
||||
collision_mask = 2
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="DoorBody"]
|
||||
position = Vector2( -0.857143, 1.57143 )
|
||||
shape = SubResource( 2 )
|
63
scenes/neighbor.tscn
Normal file
63
scenes/neighbor.tscn
Normal file
|
@ -0,0 +1,63 @@
|
|||
[gd_scene load_steps=14 format=2]
|
||||
|
||||
[ext_resource path="res://roger-roger/runningSprites/aberlin/AberlinFinal.png" type="Texture" id=1]
|
||||
[ext_resource path="res://roger-roger/runningSprites/aberlin/Aberlin2.png" type="Texture" id=2]
|
||||
[ext_resource path="res://roger-roger/runningSprites/aberlin/Aberlin5.png" type="Texture" id=3]
|
||||
[ext_resource path="res://roger-roger/runningSprites/aberlin/Aberlin6.png" type="Texture" id=4]
|
||||
[ext_resource path="res://roger-roger/runningSprites/aberlin/Aberlin4.png" type="Texture" id=5]
|
||||
[ext_resource path="res://roger-roger/runningSprites/aberlin/Aberlin3.png" type="Texture" id=6]
|
||||
[ext_resource path="res://roger-roger/runningSprites/aberlin/Aberlin1.png" type="Texture" id=7]
|
||||
[ext_resource path="res://roger-roger/runningSprites/aberlin/AberlinStart.png" type="Texture" id=8]
|
||||
[ext_resource path="res://roger-roger/LadyAberlin.png" type="Texture" id=9]
|
||||
[ext_resource path="res://scripts/neighbor.gd" type="Script" id=10]
|
||||
|
||||
[sub_resource type="CircleShape2D" id=3]
|
||||
radius = 215.037
|
||||
|
||||
[sub_resource type="SpriteFrames" id=1]
|
||||
animations = [ {
|
||||
"frames": [ ExtResource( 9 ) ],
|
||||
"loop": true,
|
||||
"name": "idle",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [ ExtResource( 8 ), ExtResource( 7 ), ExtResource( 2 ), ExtResource( 6 ), ExtResource( 5 ), ExtResource( 3 ), ExtResource( 4 ), ExtResource( 1 ) ],
|
||||
"loop": true,
|
||||
"name": "run",
|
||||
"speed": 8.0
|
||||
}, {
|
||||
"frames": [ ExtResource( 7 ), ExtResource( 2 ), ExtResource( 9 ) ],
|
||||
"loop": true,
|
||||
"name": "walk",
|
||||
"speed": 5.0
|
||||
} ]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=2]
|
||||
radius = 12.0
|
||||
height = 10.0
|
||||
|
||||
[node name="Neighbor" type="KinematicBody2D"]
|
||||
script = ExtResource( 10 )
|
||||
|
||||
[node name="RogerArea2D" type="Area2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="RogerArea2D"]
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||
position = Vector2( 1, -29 )
|
||||
scale = Vector2( 5, 5 )
|
||||
frames = SubResource( 1 )
|
||||
animation = "walk"
|
||||
frame = 2
|
||||
playing = true
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2( -1, 0 )
|
||||
rotation = 1.5708
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="WanderTimer" type="Timer" parent="."]
|
||||
|
||||
[connection signal="body_entered" from="RogerArea2D" to="." method="_on_RogerArea2D_body_entered"]
|
||||
[connection signal="timeout" from="WanderTimer" to="." method="_on_WanderTimer_timeout"]
|
50
scenes/player.tscn
Normal file
50
scenes/player.tscn
Normal file
|
@ -0,0 +1,50 @@
|
|||
[gd_scene load_steps=13 format=2]
|
||||
|
||||
[ext_resource path="res://roger-roger/runningSprites/Rogers5.png" type="Texture" id=1]
|
||||
[ext_resource path="res://roger-roger/runningSprites/Rogers4.png" type="Texture" id=2]
|
||||
[ext_resource path="res://roger-roger/runningSprites/Rogers6.png" type="Texture" id=3]
|
||||
[ext_resource path="res://roger-roger/runningSprites/Rogers2.png" type="Texture" id=4]
|
||||
[ext_resource path="res://roger-roger/runningSprites/Rogers3.png" type="Texture" id=5]
|
||||
[ext_resource path="res://roger-roger/runningSprites/RogersFinal.png" type="Texture" id=6]
|
||||
[ext_resource path="res://roger-roger/runningSprites/Rogers1.png" type="Texture" id=7]
|
||||
[ext_resource path="res://roger-roger/runningSprites/RogersStart.png" type="Texture" id=8]
|
||||
[ext_resource path="res://scripts/player.gd" type="Script" id=9]
|
||||
[ext_resource path="res://roger-roger/mrRogers.png" type="Texture" id=10]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=2]
|
||||
radius = 13.0
|
||||
height = 10.0001
|
||||
|
||||
[sub_resource type="SpriteFrames" id=1]
|
||||
animations = [ {
|
||||
"frames": [ ExtResource( 10 ) ],
|
||||
"loop": true,
|
||||
"name": "idle",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [ ExtResource( 8 ), ExtResource( 7 ), ExtResource( 4 ), ExtResource( 5 ), ExtResource( 2 ), ExtResource( 1 ), ExtResource( 3 ), ExtResource( 6 ) ],
|
||||
"loop": true,
|
||||
"name": "run",
|
||||
"speed": 8.0
|
||||
} ]
|
||||
|
||||
[node name="Player" type="KinematicBody2D"]
|
||||
collision_mask = 7
|
||||
script = ExtResource( 9 )
|
||||
ACCELERATION = 2000
|
||||
FRICTION = 2500
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2( 0, 4 )
|
||||
rotation = 1.5708
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||
position = Vector2( 2, -25 )
|
||||
scale = Vector2( 5, 5 )
|
||||
frames = SubResource( 1 )
|
||||
animation = "idle"
|
||||
playing = true
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
current = true
|
180
scenes/stage.tscn
Normal file
180
scenes/stage.tscn
Normal file
File diff suppressed because one or more lines are too long
9
scenes/tree.tscn
Normal file
9
scenes/tree.tscn
Normal file
|
@ -0,0 +1,9 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://roger-roger/tree.png" type="Texture" id=1]
|
||||
|
||||
[node name="Tree" type="Node2D"]
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
scale = Vector2( 6, 6 )
|
||||
texture = ExtResource( 1 )
|
36
scenes/trolley.tscn
Normal file
36
scenes/trolley.tscn
Normal file
|
@ -0,0 +1,36 @@
|
|||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://roger-roger/trolley-lg.png" type="Texture" id=1]
|
||||
[ext_resource path="res://scripts/trolley.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=2]
|
||||
extents = Vector2( 38, 10 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=3]
|
||||
extents = Vector2( 44.5, 8.25 )
|
||||
|
||||
[node name="Trolley" type="KinematicBody2D"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="TrolleySeatArea" type="Area2D" parent="."]
|
||||
collision_layer = 0
|
||||
|
||||
[node name="SeatAreaShape" type="CollisionShape2D" parent="TrolleySeatArea"]
|
||||
position = Vector2( -1, -41 )
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
position = Vector2( 0, -70 )
|
||||
scale = Vector2( 6, 6 )
|
||||
texture = ExtResource( 1 )
|
||||
|
||||
[node name="TrolleyShape" type="CollisionPolygon2D" parent="."]
|
||||
position = Vector2( 0, -64 )
|
||||
scale = Vector2( 0.8, 0.8 )
|
||||
polygon = PoolVector2Array( 172, -5, 198, 106, 150, 106, 122, 127, 74, 109, 46, 83, 43.75, 16.25, -46.25, 16.25, -48, 48, -48, 84, -78, 110, -114, 127, -148, 107, -197, 107, -163, 5, -163, -72, 165, -72 )
|
||||
|
||||
[node name="TrolleyClosedShape" type="CollisionShape2D" parent="."]
|
||||
position = Vector2( 0, -2.25 )
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[connection signal="body_entered" from="TrolleySeatArea" to="." method="_on_TrolleySeatArea_body_entered"]
|
6
scripts/house.gd
Normal file
6
scripts/house.gd
Normal file
|
@ -0,0 +1,6 @@
|
|||
extends Node2D
|
||||
|
||||
onready var sprite = $Sprite
|
||||
|
||||
func _ready() -> void:
|
||||
sprite.set_modulate(Color(1.0, 0.0, 0.0))
|
127
scripts/neighbor.gd
Normal file
127
scripts/neighbor.gd
Normal file
|
@ -0,0 +1,127 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
class_name Neighbor
|
||||
|
||||
signal neighbor_following_roger
|
||||
|
||||
onready var roger_area := $RogerArea2D
|
||||
onready var sprite := $AnimatedSprite
|
||||
onready var wander_timer := $WanderTimer
|
||||
|
||||
export var MAX_SPEED := 225
|
||||
export var ACCELERATION := 1000
|
||||
export var FRICTION := 2000
|
||||
|
||||
var state = State.IDLE
|
||||
var neighbor_velocity := Vector2.ZERO
|
||||
var leader: KinematicBody2D
|
||||
var follower: KinematicBody2D
|
||||
var rng := RandomNumberGenerator.new()
|
||||
var is_wandering := false
|
||||
var wander_direction := Vector2.ZERO
|
||||
|
||||
enum State {
|
||||
MOVE,
|
||||
WANDER,
|
||||
IDLE
|
||||
}
|
||||
|
||||
func reset_leads() -> void:
|
||||
if follower != null:
|
||||
follower.reset_leads()
|
||||
leader = null
|
||||
follower = null
|
||||
|
||||
func _ready() -> void:
|
||||
sprite.set_modulate(Color(.5,0,0))
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
match state:
|
||||
State.MOVE:
|
||||
move_state(delta)
|
||||
State.WANDER:
|
||||
wander_state(delta)
|
||||
State.IDLE:
|
||||
idle_state(delta)
|
||||
|
||||
func move_state(delta: float) -> void:
|
||||
# var player := get_parent().get_node("Player") as Player
|
||||
# leader.follower = self
|
||||
if leader == null:
|
||||
state = State.IDLE
|
||||
return
|
||||
var result_vector := leader.global_position - global_position
|
||||
if result_vector.length() > 100:
|
||||
move_neighbor(result_vector)
|
||||
else:
|
||||
state = State.IDLE
|
||||
if result_vector.length() > 250:
|
||||
leader.follower = null
|
||||
leader = null
|
||||
if follower != null:
|
||||
follower.reset_leads()
|
||||
follower = null
|
||||
state = State.IDLE
|
||||
|
||||
func wander_state(delta: float) -> void:
|
||||
if leader != null:
|
||||
state = State.MOVE
|
||||
return
|
||||
move_neighbor(wander_direction, true)
|
||||
|
||||
|
||||
func move_neighbor(direction_vector: Vector2, is_wander: bool = false) -> void:
|
||||
sprite.play("run") if not is_wander else sprite.play("walk")
|
||||
var move_vector := Vector2(direction_vector).normalized()
|
||||
if move_vector.x < 0 and not sprite.flip_h:
|
||||
sprite.flip_h = true
|
||||
elif move_vector.x > 0 and sprite.flip_h:
|
||||
sprite.flip_h = false
|
||||
if move_vector != Vector2.ZERO:
|
||||
var velocity := move_vector * MAX_SPEED if not is_wander else move_vector * MAX_SPEED / 3
|
||||
neighbor_velocity = neighbor_velocity.move_toward(velocity, ACCELERATION * get_physics_process_delta_time())
|
||||
else:
|
||||
neighbor_velocity = neighbor_velocity.move_toward(Vector2.ZERO, FRICTION * get_physics_process_delta_time())
|
||||
|
||||
neighbor_velocity = move_and_slide(neighbor_velocity)
|
||||
|
||||
|
||||
func idle_state(delta: float) -> void:
|
||||
if wander_timer.is_stopped():
|
||||
wander_timer.start(rng.randf_range(0, 1.5))
|
||||
sprite.play("idle")
|
||||
for body in roger_area.get_overlapping_bodies():
|
||||
if body.is_class("KinematicBody2D") and not body is Trolley and leader == null and body.follower == null and body.leader != null:
|
||||
leader = body
|
||||
leader.follower = self
|
||||
if leader != null:
|
||||
state = State.MOVE
|
||||
|
||||
func _on_RogerArea2D_body_entered(body: Node) -> void:
|
||||
if body != self and leader == null:
|
||||
if body is Player and body.follower == null:
|
||||
body.follower = self
|
||||
leader = body
|
||||
elif body.is_class("KinematicBody2D") and not body is Trolley and body.follower == null:
|
||||
print('Got neighbor body')
|
||||
if body.leader != null:
|
||||
print('Following the leader')
|
||||
leader = body
|
||||
leader.follower = self
|
||||
|
||||
|
||||
func _on_WanderTimer_timeout() -> void:
|
||||
if state == State.IDLE:
|
||||
print('wander timer done')
|
||||
var rand_x = rng.randf_range(-1.0, 1.0)
|
||||
var rand_y = rng.randf_range(-1.0, 1.0)
|
||||
var wander_time = rng.randf_range(1.0, 1.5)
|
||||
state = State.WANDER
|
||||
wander_direction = Vector2(rand_x, rand_y)
|
||||
wander_timer.start(wander_time)
|
||||
elif state == State.WANDER:
|
||||
print('Done wandering')
|
||||
var wait_time = rng.randf_range(1.0, 5.5)
|
||||
state = State.IDLE
|
||||
wander_timer.start(wait_time)
|
||||
|
63
scripts/player.gd
Normal file
63
scripts/player.gd
Normal file
|
@ -0,0 +1,63 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
class_name Player
|
||||
|
||||
export var MAX_SPEED := 300
|
||||
export var ACCELERATION := 1000
|
||||
export var FRICTION := 2000
|
||||
|
||||
var player_velocity = Vector2.ZERO
|
||||
var state = State.IDLE
|
||||
var follower : KinematicBody2D
|
||||
|
||||
onready var sprite := $AnimatedSprite
|
||||
|
||||
enum State {
|
||||
MOVE,
|
||||
IDLE
|
||||
}
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
match state:
|
||||
State.MOVE:
|
||||
move_state(delta)
|
||||
State.IDLE:
|
||||
idle_state(delta)
|
||||
|
||||
func move_state(delta: float) -> void:
|
||||
var input_vector := Vector2.ZERO
|
||||
input_vector.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
|
||||
input_vector.y = Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
|
||||
input_vector.normalized()
|
||||
|
||||
if input_vector.x < 0 and not sprite.flip_h:
|
||||
sprite.flip_h = true
|
||||
elif input_vector.x > 0 and sprite.flip_h:
|
||||
sprite.flip_h = false
|
||||
|
||||
|
||||
if input_vector != Vector2.ZERO:
|
||||
player_velocity = player_velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION * delta)
|
||||
else:
|
||||
player_velocity = player_velocity.move_toward(Vector2.ZERO, FRICTION * delta)
|
||||
|
||||
player_velocity = move_and_slide(player_velocity)
|
||||
|
||||
if player_velocity == Vector2.ZERO:
|
||||
state = State.IDLE
|
||||
|
||||
func idle_state(delta: float) -> void:
|
||||
if Input.is_action_just_pressed("ui_up") or Input.is_action_just_pressed("ui_down") or Input.is_action_just_pressed("ui_left") or Input.is_action_just_pressed("ui_right"):
|
||||
sprite.set_animation("run")
|
||||
state = State.MOVE
|
||||
else:
|
||||
sprite.set_animation("idle")
|
||||
# if Input.is_action_pressed("ui_up"):
|
||||
# speed.y -= ACCELERATION
|
||||
# elif Input.is_action_pressed("ui_right"):
|
||||
# print("right")
|
||||
# elif Input.is_action_pressed("ui_left"):
|
||||
# print("left")
|
||||
# elif Input.is_action_pressed("ui_down"):
|
||||
# print("down")
|
2
scripts/stage.gd
Normal file
2
scripts/stage.gd
Normal file
|
@ -0,0 +1,2 @@
|
|||
extends Node2D
|
||||
|
33
scripts/trolley.gd
Normal file
33
scripts/trolley.gd
Normal file
|
@ -0,0 +1,33 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
class_name Trolley
|
||||
|
||||
export var TIME = 60
|
||||
onready var trolley_closed_shape = $TrolleyClosedShape
|
||||
export var MAX_VELOCITY = .3
|
||||
|
||||
var velocity := Vector2.ZERO
|
||||
var has_roger := false
|
||||
|
||||
func _ready() -> void:
|
||||
trolley_closed_shape.set_deferred("disabled", true)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
velocity.x = move_toward(velocity.x, MAX_VELOCITY, delta if not has_roger else delta * 10)
|
||||
var collision := move_and_collide(velocity)
|
||||
if collision:
|
||||
var collider = collision.get_collider()
|
||||
if collider.get_class() == "KinematicBody2D":
|
||||
if has_roger:
|
||||
MAX_VELOCITY = 10
|
||||
collider.move_and_collide(velocity * 3)
|
||||
|
||||
|
||||
|
||||
|
||||
func _on_TrolleySeatArea_body_entered(body: Node) -> void:
|
||||
if body is Player:
|
||||
has_roger = true
|
||||
print('closing trolley')
|
||||
trolley_closed_shape.set_deferred("disabled", false)
|
||||
|
Loading…
Reference in New Issue
Block a user