diff options
-rw-r--r-- | MainScene.tscn | 13 | ||||
-rw-r--r-- | assets/hire.png | bin | 0 -> 616 bytes | |||
-rw-r--r-- | assets/hire.png.import | 34 | ||||
-rw-r--r-- | assets/intern.png | bin | 0 -> 611 bytes | |||
-rw-r--r-- | assets/intern.png.import | 34 | ||||
-rw-r--r-- | buildings/base_building.gd | 14 | ||||
-rw-r--r-- | buildings/base_building.tscn | 27 | ||||
-rw-r--r-- | buildings/building_clickable.gd | 10 | ||||
-rw-r--r-- | buildings/building_interface.gd | 32 | ||||
-rw-r--r-- | buildings/buildings.tscn | 30 | ||||
-rw-r--r-- | coffee_machine/coffee_machine.gd (renamed from coffee_maschine/coffee_maschine.gd) | 0 | ||||
-rw-r--r-- | coffee_machine/coffee_machine.tscn (renamed from coffee_maschine/coffee_maschine.tscn) | 2 | ||||
-rw-r--r-- | project.godot | 4 | ||||
-rw-r--r-- | save_state.gd | 5 |
14 files changed, 164 insertions, 41 deletions
diff --git a/MainScene.tscn b/MainScene.tscn index 0f05cc3..90b52b8 100644 --- a/MainScene.tscn +++ b/MainScene.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://assets/background.png" type="Texture" id=1] -[ext_resource path="res://coffee_maschine/coffee_maschine.tscn" type="PackedScene" id=2] +[ext_resource path="res://coffee_machine/coffee_machine.tscn" type="PackedScene" id=2] [ext_resource path="res://main_scene/Label.gd" type="Script" id=3] [ext_resource path="res://buildings/buildings.tscn" type="PackedScene" id=4] +[ext_resource path="res://assets/hire.png" type="Texture" id=5] [node name="Node2D" type="Node2D"] @@ -11,7 +12,7 @@ position = Vector2( 511.115, 299.606 ) texture = ExtResource( 1 ) -[node name="Node2D" parent="." instance=ExtResource( 2 )] +[node name="coffee_machine" parent="." instance=ExtResource( 2 )] position = Vector2( 256.585, 298.451 ) [node name="Label" type="Label" parent="."] @@ -23,3 +24,9 @@ __meta__ = { } [node name="buildings" parent="." instance=ExtResource( 4 )] + +[node name="hiring" type="Node2D" parent="."] + +[node name="hire" type="Sprite" parent="hiring"] +position = Vector2( 519.268, 89.2965 ) +texture = ExtResource( 5 ) diff --git a/assets/hire.png b/assets/hire.png Binary files differnew file mode 100644 index 0000000..a3cacdb --- /dev/null +++ b/assets/hire.png diff --git a/assets/hire.png.import b/assets/hire.png.import new file mode 100644 index 0000000..aa6cd9a --- /dev/null +++ b/assets/hire.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/hire.png-ed4aee0d6e78ff62cb5e1f2a123785bd.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/hire.png" +dest_files=[ "res://.import/hire.png-ed4aee0d6e78ff62cb5e1f2a123785bd.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 +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/assets/intern.png b/assets/intern.png Binary files differnew file mode 100644 index 0000000..e13a88b --- /dev/null +++ b/assets/intern.png diff --git a/assets/intern.png.import b/assets/intern.png.import new file mode 100644 index 0000000..21ccf5a --- /dev/null +++ b/assets/intern.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/intern.png-66f10bee0a108a5832146698be90c68d.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/intern.png" +dest_files=[ "res://.import/intern.png-66f10bee0a108a5832146698be90c68d.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 +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/buildings/base_building.gd b/buildings/base_building.gd deleted file mode 100644 index 00d4f94..0000000 --- a/buildings/base_building.gd +++ /dev/null @@ -1,14 +0,0 @@ -extends Button -class_name BaseBuilding - - -func _pressed(): - if SaveState.coffee >= get_cost(): - SaveState.coffee -= get_cost() - _bought() - -func get_cost(): - pass - -func _bought(): - pass diff --git a/buildings/base_building.tscn b/buildings/base_building.tscn new file mode 100644 index 0000000..036ad96 --- /dev/null +++ b/buildings/base_building.tscn @@ -0,0 +1,27 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://buildings/building_clickable.gd" type="Script" id=1] +[ext_resource path="res://buildings/building_interface.gd" type="Script" id=2] + +[sub_resource type="RectangleShape2D" id=1] +extents = Vector2( 32, 32 ) + +[node name="texture" type="Sprite"] +script = ExtResource( 2 ) + +[node name="Area2D" type="Area2D" parent="."] +script = ExtResource( 1 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] +shape = SubResource( 1 ) + +[node name="Label" type="Label" parent="."] +margin_left = -32.0 +margin_top = -32.0 +margin_right = 32.0 +margin_bottom = -16.0 +custom_colors/font_color = Color( 0, 0, 0, 1 ) +custom_colors/font_outline_modulate = Color( 0, 0, 0, 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/buildings/building_clickable.gd b/buildings/building_clickable.gd new file mode 100644 index 0000000..74c455b --- /dev/null +++ b/buildings/building_clickable.gd @@ -0,0 +1,10 @@ +extends Area2D +class_name BaseBuilding + + +func _input_event(viewport, event, shape_idx): + if event is InputEventMouseButton and event.button_index == BUTTON_LEFT and event.is_pressed(): + var parent = get_parent() + if SaveState.coffee >= parent.get_cost(): + SaveState.coffee -= parent.get_cost() + parent._bought() diff --git a/buildings/building_interface.gd b/buildings/building_interface.gd new file mode 100644 index 0000000..9d515cf --- /dev/null +++ b/buildings/building_interface.gd @@ -0,0 +1,32 @@ +extends Sprite + +export var base_cost := 1.0 +export var cost_multiplier := 1.0 +export var base_cps := 1.0 +export var building_identifier := "" +export var tick_rate := 1.0 + +var current_tick := 0.0 + +func _process(delta: float) -> void: + update_label() + current_tick += delta + while current_tick > tick_rate: + SaveState.coffee += get_amount() * base_cps + current_tick -= tick_rate + +func update_label(): + var label : Label = $Label + label.text = str(get_amount()) + +func get_cost() -> float: + return floor(base_cost * pow(cost_multiplier, get_amount())) + +func get_amount() -> int: + return SaveState.buildings[building_identifier] + +func set_amount(value : int) -> void: + SaveState.buildings[building_identifier] = value + +func _bought() -> void: + set_amount(get_amount() + 1) diff --git a/buildings/buildings.tscn b/buildings/buildings.tscn index 77f9e38..c64c18b 100644 --- a/buildings/buildings.tscn +++ b/buildings/buildings.tscn @@ -1,23 +1,13 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=3 format=2] -[ext_resource path="res://buildings/coffe_maker_button.gd" type="Script" id=1] +[ext_resource path="res://assets/intern.png" type="Texture" id=1] +[ext_resource path="res://buildings/base_building.tscn" type="PackedScene" id=2] -[node name="buildings" type="Control"] -margin_right = 40.0 -margin_bottom = 40.0 -__meta__ = { -"_edit_use_anchors_": false -} +[node name="buildings" type="Node2D"] -[node name="coffe_maker_button" type="Button" parent="."] -margin_left = 861.462 -margin_top = 77.3558 -margin_right = 873.462 -margin_bottom = 97.3558 -custom_colors/font_color = Color( 0.12549, 0.952941, 0.811765, 1 ) -custom_colors/font_color_hover = Color( 0, 0, 0, 1 ) -text = "Coffee Maker" -script = ExtResource( 1 ) -__meta__ = { -"_edit_use_anchors_": false -} +[node name="intern" parent="." instance=ExtResource( 2 )] +position = Vector2( 931.798, 83.8618 ) +texture = ExtResource( 1 ) +base_cost = 10.0 +cost_multiplier = 1.1 +building_identifier = "intern" diff --git a/coffee_maschine/coffee_maschine.gd b/coffee_machine/coffee_machine.gd index 99e3bea..99e3bea 100644 --- a/coffee_maschine/coffee_maschine.gd +++ b/coffee_machine/coffee_machine.gd diff --git a/coffee_maschine/coffee_maschine.tscn b/coffee_machine/coffee_machine.tscn index d5ddec4..a726f66 100644 --- a/coffee_maschine/coffee_maschine.tscn +++ b/coffee_machine/coffee_machine.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=4 format=2] [ext_resource path="res://assets/coffee_machine.png" type="Texture" id=1] -[ext_resource path="res://coffee_maschine/coffee_maschine.gd" type="Script" id=2] +[ext_resource path="res://coffee_machine/coffee_machine.gd" type="Script" id=2] [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 64, 64 ) diff --git a/project.godot b/project.godot index a72749c..fb4ad35 100644 --- a/project.godot +++ b/project.godot @@ -9,10 +9,10 @@ config_version=4 _global_script_classes=[ { -"base": "Button", +"base": "Area2D", "class": "BaseBuilding", "language": "GDScript", -"path": "res://buildings/base_building.gd" +"path": "res://buildings/building_clickable.gd" } ] _global_script_class_icons={ "BaseBuilding": "" diff --git a/save_state.gd b/save_state.gd index e4564a9..1cff02a 100644 --- a/save_state.gd +++ b/save_state.gd @@ -1,7 +1,10 @@ extends Node +var buildings = { + "intern": 0 +} var coffee = 0 -var coffee_machine = 0 +var programmers = 0 |