throw bottles at Tim and hurt him
This commit is contained in:
parent
4faa6ae915
commit
bc8f933e22
|
@ -6,18 +6,18 @@ extends Node2D
|
||||||
|
|
||||||
# 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.
|
pass # Replace with function body.
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
if Input.is_action_pressed("move_right"):
|
if Input.is_action_pressed("move_right"):
|
||||||
tim_sprite.flip_h = true
|
tim_sprite.flip_h = true
|
||||||
global_position += Vector2.RIGHT * delta * move_speed
|
global_position += Vector2.RIGHT * delta * move_speed
|
||||||
if global_position.x > boundary.get_most_right_position():
|
if global_position.x > boundary.get_most_right_position():
|
||||||
global_position = Vector2(boundary.get_most_right_position(), global_position.y)
|
global_position = Vector2(boundary.get_most_right_position(), global_position.y)
|
||||||
|
|
||||||
if Input.is_action_pressed("move_left"):
|
if Input.is_action_pressed("move_left"):
|
||||||
tim_sprite.flip_h = false
|
tim_sprite.flip_h = false
|
||||||
global_position += Vector2.LEFT * delta * move_speed
|
global_position += Vector2.LEFT * delta * move_speed
|
||||||
if global_position.x < boundary.get_most_left_position():
|
if global_position.x < boundary.get_most_left_position():
|
||||||
global_position = Vector2(boundary.get_most_left_position(), global_position.y)
|
global_position = Vector2(boundary.get_most_left_position(), global_position.y)
|
||||||
|
|
|
@ -4,11 +4,11 @@ extends Node2D
|
||||||
var max_persons = 16
|
var max_persons = 16
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
var counter = 0
|
var counter = 0
|
||||||
var person = preload("res://scenes/crowd/person.tscn")
|
var person = preload("res://scenes/crowd/person.tscn")
|
||||||
for seat in $Seats.get_children():
|
for seat in $Seats.get_children():
|
||||||
seat.add_child(person.instantiate())
|
seat.add_child(person.instantiate())
|
||||||
|
|
||||||
counter += 1
|
counter += 1
|
||||||
if counter == max_persons:
|
if counter == max_persons:
|
||||||
break
|
break
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
[node name="Crowd" type="Node2D"]
|
[node name="Crowd" type="Node2D"]
|
||||||
position = Vector2(240, 232)
|
position = Vector2(240, 232)
|
||||||
script = ExtResource("1_y7wyj")
|
script = ExtResource("1_y7wyj")
|
||||||
|
max_persons = 1
|
||||||
|
|
||||||
[node name="Tables" type="Node" parent="."]
|
[node name="Tables" type="Node" parent="."]
|
||||||
|
|
||||||
|
|
|
@ -2,25 +2,39 @@ extends Sprite2D
|
||||||
|
|
||||||
@export var head : Node2D
|
@export var head : Node2D
|
||||||
@export var face : Node2D
|
@export var face : Node2D
|
||||||
|
@export var mood : float = 0.0
|
||||||
|
|
||||||
var known_faces : Array[String] = [
|
var known_faces : Array[String] = [
|
||||||
"res://scenes/faces/face_curly.tscn",
|
"res://scenes/faces/face_curly.tscn",
|
||||||
"res://scenes/faces/face_moritz.tscn",
|
"res://scenes/faces/face_moritz.tscn",
|
||||||
"res://scenes/faces/face_ronald.tscn",
|
"res://scenes/faces/face_ronald.tscn",
|
||||||
# Add more scenes as needed
|
# Add more scenes as needed
|
||||||
]
|
]
|
||||||
|
|
||||||
# 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.
|
pass # Replace with function body.
|
||||||
if face == null:
|
if face == null:
|
||||||
set_random_face()
|
set_random_face()
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
pass
|
if mood < -9.9:
|
||||||
|
throw_bottle()
|
||||||
|
|
||||||
func set_random_face():
|
func set_random_face():
|
||||||
var face_res = load(known_faces[randi() % known_faces.size()])
|
var face_res = load(known_faces[randi() % known_faces.size()])
|
||||||
face = face_res.instantiate()
|
face = face_res.instantiate()
|
||||||
head.add_child(face)
|
head.add_child(face)
|
||||||
|
|
||||||
|
func throw_bottle():
|
||||||
|
mood += 2.0
|
||||||
|
|
||||||
|
var bottle_scene = preload("res://scenes/objects/bottle.tscn")
|
||||||
|
var bottle = bottle_scene.instantiate()
|
||||||
|
|
||||||
|
add_child(bottle);
|
||||||
|
|
||||||
|
|
||||||
|
func _on_debug_timer_timeout():
|
||||||
|
mood -= 1
|
||||||
|
|
|
@ -13,3 +13,8 @@ head = NodePath("Head")
|
||||||
[node name="Head" type="Node2D" parent="."]
|
[node name="Head" type="Node2D" parent="."]
|
||||||
position = Vector2(0, -16)
|
position = Vector2(0, -16)
|
||||||
scale = Vector2(0.3, 0.3)
|
scale = Vector2(0.3, 0.3)
|
||||||
|
|
||||||
|
[node name="DebugTimer" type="Timer" parent="."]
|
||||||
|
autostart = true
|
||||||
|
|
||||||
|
[connection signal="timeout" from="DebugTimer" to="." method="_on_debug_timer_timeout"]
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
extends Sprite2D
|
||||||
|
|
||||||
|
@export var bottle_speed: float = 120;
|
||||||
|
|
||||||
|
var tim_global_position: Vector2
|
||||||
|
var is_hidding: bool
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
tim_global_position = get_node("/root/IngameScene/Stage/Tim/ThrowPoint").global_position
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta):
|
||||||
|
var t = create_tween()
|
||||||
|
t.tween_property(self, "global_position", tim_global_position, 3.0)
|
||||||
|
t.tween_callback(remove_bottle)
|
||||||
|
|
||||||
|
func _on_bottle_area_entered(area):
|
||||||
|
is_hidding = true
|
||||||
|
|
||||||
|
func _on_bottle_area_exited(area):
|
||||||
|
is_hidding = false
|
||||||
|
|
||||||
|
func _on_growth_timer_timeout():
|
||||||
|
var t = create_tween()
|
||||||
|
t.tween_property(self, "scale", self.scale + Vector2(0.01, 0.01), 0.02)
|
||||||
|
|
||||||
|
func remove_bottle():
|
||||||
|
if is_hidding:
|
||||||
|
print("Ouch")
|
||||||
|
queue_free()
|
|
@ -0,0 +1,29 @@
|
||||||
|
[gd_scene load_steps=4 format=3 uid="uid://c5f5v1wtottyp"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scenes/objects/bottle.gd" id="1_87ktq"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://cow4dd0hlxrgr" path="res://sprites/room/bottle.svg" id="1_uea7l"]
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_p8qcj"]
|
||||||
|
radius = 22.4893
|
||||||
|
height = 44.9786
|
||||||
|
|
||||||
|
[node name="BottleSprite" type="Sprite2D"]
|
||||||
|
scale = Vector2(0.25, 0.25)
|
||||||
|
texture = ExtResource("1_uea7l")
|
||||||
|
script = ExtResource("1_87ktq")
|
||||||
|
|
||||||
|
[node name="GrowthTimer" type="Timer" parent="."]
|
||||||
|
wait_time = 0.1
|
||||||
|
autostart = true
|
||||||
|
|
||||||
|
[node name="Bottle" type="Area2D" parent="."]
|
||||||
|
collision_layer = 4096
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Bottle"]
|
||||||
|
rotation = 0.487459
|
||||||
|
scale = Vector2(1, 2.66666)
|
||||||
|
shape = SubResource("CapsuleShape2D_p8qcj")
|
||||||
|
|
||||||
|
[connection signal="timeout" from="GrowthTimer" to="." method="_on_growth_timer_timeout"]
|
||||||
|
[connection signal="area_entered" from="Bottle" to="." method="_on_bottle_area_entered"]
|
||||||
|
[connection signal="area_exited" from="Bottle" to="." method="_on_bottle_area_exited"]
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=5 format=3 uid="uid://cicyfp5xjvvu4"]
|
[gd_scene load_steps=6 format=3 uid="uid://cicyfp5xjvvu4"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scenes/Tim.gd" id="1_g3k2b"]
|
[ext_resource type="Script" path="res://scenes/Tim.gd" id="1_g3k2b"]
|
||||||
[ext_resource type="Texture2D" uid="uid://kq63ictuirhc" path="res://sprites/tim_side.png" id="1_saxit"]
|
[ext_resource type="Texture2D" uid="uid://kq63ictuirhc" path="res://sprites/tim_side.png" id="1_saxit"]
|
||||||
|
@ -7,6 +7,9 @@
|
||||||
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_3hx6l"]
|
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_3hx6l"]
|
||||||
size = Vector2(600, 200)
|
size = Vector2(600, 200)
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_vwfks"]
|
||||||
|
radius = 25.0
|
||||||
|
|
||||||
[node name="Stage" type="Node2D"]
|
[node name="Stage" type="Node2D"]
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
@ -25,5 +28,11 @@ scale = Vector2(0.4, 0.4)
|
||||||
texture = ExtResource("1_saxit")
|
texture = ExtResource("1_saxit")
|
||||||
offset = Vector2(0, 50)
|
offset = Vector2(0, 50)
|
||||||
|
|
||||||
|
[node name="ThrowPoint" type="Area2D" parent="Tim"]
|
||||||
|
position = Vector2(0, -148)
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Tim/ThrowPoint"]
|
||||||
|
shape = SubResource("CircleShape2D_vwfks")
|
||||||
|
|
||||||
[node name="Boundary" type="Node2D" parent="."]
|
[node name="Boundary" type="Node2D" parent="."]
|
||||||
script = ExtResource("2_8p6ir")
|
script = ExtResource("2_8p6ir")
|
||||||
|
|
Loading…
Reference in New Issue