added drill
This commit is contained in:
parent
afd8500d4e
commit
18a2279cc3
|
@ -11,7 +11,6 @@ config_version=5
|
||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="Courier"
|
config/name="Courier"
|
||||||
run/main_scene="res://scenes/world.tscn"
|
|
||||||
config/features=PackedStringArray("4.3", "GL Compatibility")
|
config/features=PackedStringArray("4.3", "GL Compatibility")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
|
|
16
scenes/drill.tscn
Normal file
16
scenes/drill.tscn
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://cl86qyf4rls0y"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/drill.gd" id="1_7g7rb"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://c8sctajtkp1qs" path="res://sprites/drill.png" id="2_21l7t"]
|
||||||
|
|
||||||
|
[node name="Drill" type="Node2D"]
|
||||||
|
script = ExtResource("1_7g7rb")
|
||||||
|
|
||||||
|
[node name="RayCast2D" type="RayCast2D" parent="."]
|
||||||
|
target_position = Vector2(70, 0)
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
position = Vector2(46, -1.42109e-13)
|
||||||
|
rotation = -1.5708
|
||||||
|
scale = Vector2(0.1, 0.1)
|
||||||
|
texture = ExtResource("2_21l7t")
|
|
@ -10,6 +10,7 @@ height = 100.0
|
||||||
|
|
||||||
[node name="Player" type="CharacterBody2D" groups=["player"]]
|
[node name="Player" type="CharacterBody2D" groups=["player"]]
|
||||||
z_index = 1
|
z_index = 1
|
||||||
|
motion_mode = 1
|
||||||
script = ExtResource("1_a7huw")
|
script = ExtResource("1_a7huw")
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
|
File diff suppressed because one or more lines are too long
25
scripts/drill.gd
Normal file
25
scripts/drill.gd
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
@onready var RayCast : RayCast2D = $RayCast2D
|
||||||
|
|
||||||
|
var uses = 5
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
if RayCast.is_colliding():
|
||||||
|
var collisionObject = RayCast.get_collider()
|
||||||
|
if collisionObject is TileMapLayer:
|
||||||
|
var cell : Vector2i = collisionObject.local_to_map(RayCast.get_collision_point() + Vector2(5,0).rotated(global_rotation))
|
||||||
|
|
||||||
|
if collisionObject.get_cell_source_id(cell) == 0:
|
||||||
|
collisionObject.set_cell(cell,1,Vector2i(0, 0))
|
||||||
|
uses -= 1
|
||||||
|
get_parent().GUI.remove_item("Drill")
|
||||||
|
|
||||||
|
if uses == 0:
|
||||||
|
queue_free()
|
|
@ -6,7 +6,7 @@ extends CanvasLayer
|
||||||
|
|
||||||
@onready var CurrentAddress = $List/CurrentAddress
|
@onready var CurrentAddress = $List/CurrentAddress
|
||||||
|
|
||||||
@onready var ItemTextures = {"Shoes" : preload("res://sprites/runningshoes.png")}
|
@onready var ItemTextures = {"Shoes" : preload("res://sprites/runningshoes.png"), "Drill" : preload("res://sprites/drill.png")}
|
||||||
|
|
||||||
@onready var ItemGrid = $Items
|
@onready var ItemGrid = $Items
|
||||||
|
|
||||||
|
@ -26,14 +26,23 @@ func _process(delta: float) -> void:
|
||||||
else:
|
else:
|
||||||
CurrentAddress.text = "No Active Contract"
|
CurrentAddress.text = "No Active Contract"
|
||||||
|
|
||||||
func add_item(name: String):
|
func add_item(name: String, number : int = 1):
|
||||||
if not ItemGrid.has_node(name):
|
if not ItemGrid.has_node(name):
|
||||||
var newItem = ItemCounter.instantiate()
|
var newItem = ItemCounter.instantiate()
|
||||||
newItem.name = name
|
newItem.name = name
|
||||||
newItem.Count = 1
|
newItem.Count = number
|
||||||
|
|
||||||
ItemGrid.add_child(newItem)
|
ItemGrid.add_child(newItem)
|
||||||
ItemGrid.get_node(name).ItemTexture.texture = ItemTextures[name]
|
ItemGrid.get_node(name).ItemTexture.texture = ItemTextures[name]
|
||||||
else:
|
else:
|
||||||
ItemGrid.get_node(name).Count += 1
|
ItemGrid.get_node(name).Count += number
|
||||||
|
|
||||||
|
func remove_item(name: String, number : int = 1):
|
||||||
|
if ItemGrid.has_node(name):
|
||||||
|
|
||||||
|
var item = ItemGrid.get_node(name)
|
||||||
|
item.Count -= number
|
||||||
|
|
||||||
|
if item.Count <= 0:
|
||||||
|
item.queue_free()
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,17 @@ extends Area2D
|
||||||
|
|
||||||
@onready var InteractibleManager = $InteractibleManager
|
@onready var InteractibleManager = $InteractibleManager
|
||||||
|
|
||||||
|
@onready var Sprite = $Sprite2D
|
||||||
|
|
||||||
var Player : Node2D
|
var Player : Node2D
|
||||||
|
|
||||||
@export var Cost : int = 100
|
@export var Cost : int = 100
|
||||||
|
|
||||||
var items = ["Shoes"]
|
var playerItem : Dictionary = {"Drill" : preload("res://scenes/drill.tscn")}
|
||||||
|
|
||||||
|
var Textures : Dictionary = {"Shoes" : preload("res://sprites/runningshoes.png"), "Drill" : preload("res://sprites/drill.png")}
|
||||||
|
|
||||||
|
var items = ["Shoes", "Drill"]
|
||||||
|
|
||||||
@onready var item = items.pick_random()
|
@onready var item = items.pick_random()
|
||||||
|
|
||||||
|
@ -20,6 +26,12 @@ func _ready() -> void:
|
||||||
match item:
|
match item:
|
||||||
"Shoes":
|
"Shoes":
|
||||||
Cost = 200
|
Cost = 200
|
||||||
|
Dialogue.DialogueLabel.text = "Running Shoes"
|
||||||
|
"Drill":
|
||||||
|
Cost = 400
|
||||||
|
Dialogue.DialogueLabel.text = "Dirt Drill"
|
||||||
|
|
||||||
|
Sprite.texture = Textures[item]
|
||||||
|
|
||||||
Dialogue.DialogueLabel.text += " - $" + str(Cost)
|
Dialogue.DialogueLabel.text += " - $" + str(Cost)
|
||||||
|
|
||||||
|
@ -32,4 +44,8 @@ func _process(delta: float) -> void:
|
||||||
if item == "Shoes":
|
if item == "Shoes":
|
||||||
Player.Speed += 300
|
Player.Speed += 300
|
||||||
Player.GUI.add_item("Shoes")
|
Player.GUI.add_item("Shoes")
|
||||||
|
if item == "Drill":
|
||||||
|
var newDrill = playerItem["Drill"].instantiate()
|
||||||
|
Player.add_child(newDrill)
|
||||||
|
Player.GUI.add_item("Drill", 5)
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
|
@ -46,7 +46,7 @@ func _physics_process(delta: float) -> void:
|
||||||
velocity = velocity.move_toward(Vector2(0,0), delta * clamp(velocity.length() * FrictionMult, 1000, 100000))
|
velocity = velocity.move_toward(Vector2(0,0), delta * clamp(velocity.length() * FrictionMult, 1000, 100000))
|
||||||
|
|
||||||
if velocity.length() > 0.1:
|
if velocity.length() > 0.1:
|
||||||
Sprite.rotation = rotate_toward(Sprite.rotation,velocity.angle(),delta*SpriteTurningSpeed)
|
rotation = rotate_toward(rotation,velocity.angle(),delta*SpriteTurningSpeed)
|
||||||
|
|
||||||
if ActiveContract:
|
if ActiveContract:
|
||||||
PackageSprite.show()
|
PackageSprite.show()
|
||||||
|
|
BIN
sprites/drill.png
Normal file
BIN
sprites/drill.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
34
sprites/drill.png.import
Normal file
34
sprites/drill.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://c8sctajtkp1qs"
|
||||||
|
path="res://.godot/imported/drill.png-f7e26017a80df26609ac6d9e8e1e114a.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://sprites/drill.png"
|
||||||
|
dest_files=["res://.godot/imported/drill.png-f7e26017a80df26609ac6d9e8e1e114a.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
Loading…
Reference in a new issue