mirror of
https://github.com/Alee14/frivolous-run.git
synced 2025-01-22 10:41:56 -05:00
Death implemented, added money spent, pause screen
This commit is contained in:
parent
dbb42c99e0
commit
a4f737b2be
10 changed files with 140 additions and 77 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -1,5 +1,7 @@
|
|||
# Godot-specific ignores
|
||||
# Godot 4+ specific ignores
|
||||
.godot/
|
||||
|
||||
# Godot-specific ignores
|
||||
.import/
|
||||
export.cfg
|
||||
export_presets.cfg
|
||||
|
@ -10,3 +12,4 @@ export_presets.cfg
|
|||
# Mono-specific ignores
|
||||
.mono/
|
||||
data_*/
|
||||
mono_crash.*.json
|
8
game/Game.gd
Normal file
8
game/Game.gd
Normal file
|
@ -0,0 +1,8 @@
|
|||
extends Node2D
|
||||
|
||||
func _input(event):
|
||||
if event.is_action_pressed("pause"):
|
||||
var new_pause_state = not get_tree().paused
|
||||
get_tree().paused = new_pause_state
|
||||
visible = new_pause_state
|
||||
$Pause.show()
|
103
game/Game.tscn
103
game/Game.tscn
File diff suppressed because one or more lines are too long
|
@ -1,8 +1,6 @@
|
|||
extends CharacterBody2D
|
||||
|
||||
|
||||
@export var SPEED = 300.0
|
||||
var JUMP_VELOCITY = -400.0
|
||||
const JUMP_VELOCITY = -500.0
|
||||
|
||||
# Get the gravity from the project settings to be synced with RigidBody nodes.
|
||||
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
|
||||
|
@ -14,15 +12,15 @@ func _physics_process(delta):
|
|||
velocity.y += gravity * delta
|
||||
|
||||
# Handle Jump.
|
||||
if Input.is_action_just_pressed("jump") and is_on_floor():
|
||||
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
|
||||
velocity.y = JUMP_VELOCITY
|
||||
|
||||
# Get the input direction and handle the movement/deceleration.
|
||||
# As good practice, you should replace UI actions with custom gameplay actions.
|
||||
var direction = Input.get_axis("left", "right")
|
||||
if direction:
|
||||
velocity.x = direction * SPEED
|
||||
else:
|
||||
velocity.x = move_toward(velocity.x, 0, SPEED)
|
||||
|
||||
velocity.x = 1 * Stats.playerspeed
|
||||
move_and_slide()
|
||||
|
||||
if Stats.playerdead == true:
|
||||
queue_free()
|
||||
get_tree().paused = true
|
||||
$"../Game Over".show()
|
||||
|
|
|
@ -1,40 +1,14 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://l0lnby3rm6fj"]
|
||||
|
||||
[ext_resource type="Script" path="res://game/characters/player/Player.gd" id="1_a5mv4"]
|
||||
[ext_resource type="Texture2D" uid="uid://d1gf8ked7ik4l" path="res://assets/images/white.png" id="2"]
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_mix1s"]
|
||||
script/source = "extends CharacterBody2D
|
||||
|
||||
const JUMP_VELOCITY = -500.0
|
||||
|
||||
# Get the gravity from the project settings to be synced with RigidBody nodes.
|
||||
var gravity = ProjectSettings.get_setting(\"physics/2d/default_gravity\")
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
# Add the gravity.
|
||||
if not is_on_floor():
|
||||
velocity.y += gravity * delta
|
||||
|
||||
# Handle Jump.
|
||||
if Input.is_action_just_pressed(\"ui_accept\") and is_on_floor():
|
||||
velocity.y = JUMP_VELOCITY
|
||||
|
||||
# Get the input direction and handle the movement/deceleration.
|
||||
# As good practice, you should replace UI actions with custom gameplay actions.
|
||||
velocity.x = 1 * Stats.initspeed
|
||||
move_and_slide()
|
||||
|
||||
if Stats.playerdead == true:
|
||||
queue_free()
|
||||
"
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="1"]
|
||||
size = Vector2(16, 16)
|
||||
|
||||
[node name="Player" type="CharacterBody2D"]
|
||||
position = Vector2(50, 600)
|
||||
script = SubResource("GDScript_mix1s")
|
||||
position = Vector2(8, 8)
|
||||
script = ExtResource("1_a5mv4")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("2")
|
||||
|
|
|
@ -1,18 +1,24 @@
|
|||
extends CharacterBody2D
|
||||
|
||||
var SPEED = 100
|
||||
const JUMP_VELOCITY = -500.0
|
||||
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
|
||||
var player
|
||||
var chase = true
|
||||
|
||||
func _physics_process(delta):
|
||||
velocity.y += gravity * delta
|
||||
player = get_node("../Player")
|
||||
var direction = (player.position - self.position).normalized()
|
||||
velocity.x = direction.x * SPEED
|
||||
move_and_slide()
|
||||
if chase == true:
|
||||
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
|
||||
velocity.y = JUMP_VELOCITY
|
||||
player = get_node("../Player")
|
||||
var direction = (player.position - self.position).normalized()
|
||||
velocity.x = direction.x * SPEED
|
||||
move_and_slide()
|
||||
|
||||
|
||||
func _on_player_collision_body_entered(body):
|
||||
if body.name == "Player":
|
||||
print("Killed player")
|
||||
Stats.playerdead == true
|
||||
chase = false
|
||||
Stats.playerdead = true
|
||||
|
|
21
game/objects/Shop.gd
Normal file
21
game/objects/Shop.gd
Normal file
|
@ -0,0 +1,21 @@
|
|||
extends Node2D
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
|
||||
|
||||
func _on_area_2d_body_entered(body):
|
||||
if body.name == "Player":
|
||||
Stats.money += 5
|
||||
var popuptween = create_tween()
|
||||
popuptween.tween_property($"../MoneySpent", "position", position - Vector2(888,0), 0.2)
|
||||
print("Oh no! Victor spent some money!")
|
||||
Stats.victorannoyed += 1
|
||||
self.queue_free()
|
|
@ -1,11 +1,13 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://dhb4sjfe6w3uh"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://dhb4sjfe6w3uh"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bac68xxoapn2c" path="res://assets/images/green.png" id="1"]
|
||||
[ext_resource type="Script" path="res://game/objects/Shop.gd" id="1_qgosu"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="1"]
|
||||
size = Vector2(16, 16)
|
||||
size = Vector2(12, 12)
|
||||
|
||||
[node name="Shop" type="Node2D"]
|
||||
script = ExtResource("1_qgosu")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("1")
|
||||
|
@ -14,3 +16,6 @@ texture = ExtResource("1")
|
|||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
shape = SubResource("1")
|
||||
|
||||
[connection signal="area_entered" from="Area2D" to="." method="_on_area_2d_area_entered"]
|
||||
[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"]
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
extends Node
|
||||
|
||||
var money = 0
|
||||
var initspeed = 10
|
||||
var playerspeed = 110
|
||||
var playerdead = false
|
||||
var victorannoyed = 0
|
||||
var cutscene = false
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
[sub_resource type="GDScript" id="GDScript_kjhan"]
|
||||
script/source = "extends Control
|
||||
|
||||
|
||||
func _on_Play_button_up():
|
||||
if get_tree().change_scene_to_file(\"res://game/Game.tscn\") != OK:
|
||||
print(\"There was an error trying to load the scene...\")
|
||||
|
|
Loading…
Reference in a new issue