From 41bdece2cd0f2e9e1cc3ad688f52215c66a4c520 Mon Sep 17 00:00:00 2001 From: AiTechEye <40591179+AiTechEye@users.noreply.github.com> Date: Tue, 24 Sep 2019 20:47:13 +0200 Subject: [PATCH] Add files via upload --- Node2D.gd | 34 ++++++++++++++++++++++++++++++++++ Node2D.tscn | 20 ++++++++++++++++++++ default_env.tres | 7 +++++++ project.godot | 24 ++++++++++++++++++++++++ 4 files changed, 85 insertions(+) create mode 100644 Node2D.gd create mode 100644 Node2D.tscn create mode 100644 default_env.tres create mode 100644 project.godot diff --git a/Node2D.gd b/Node2D.gd new file mode 100644 index 0000000..ac95c15 --- /dev/null +++ b/Node2D.gd @@ -0,0 +1,34 @@ +extends Node2D + +var save = { + "clicks":0, + "level":1, + "lols":100, +} +# do not try to save in _ready, it doesn't work +func _ready(): + if load_data(): + get_node("CenterContainer/Button").set_text(str("You clicked: ",save.clicks, " times")) + + +# saves everyhing in the "save" variable +func save_data(): + var file = File.new() + file.open("user://save",file.WRITE_READ) + file.store_var(save) + file.close() + +# and load +func load_data(): + var file = File.new() + if not file.file_exists("user://save"): + return false + file.open("user://save",file.READ) + save = file.get_var() + file.close() + return true + +func _on_Button_pressed(): + save.clicks += 1 + get_node("CenterContainer/Button").set_text(str("You clicked: ",save.clicks, " times")) + save_data() \ No newline at end of file diff --git a/Node2D.tscn b/Node2D.tscn new file mode 100644 index 0000000..9e6040a --- /dev/null +++ b/Node2D.tscn @@ -0,0 +1,20 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://Node2D.gd" type="Script" id=1] + +[node name="Node2D" type="Node2D"] +script = ExtResource( 1 ) + +[node name="Camera2D" type="Camera2D" parent="."] + +[node name="CenterContainer" type="CenterContainer" parent="."] +margin_right = 1030.0 +margin_bottom = 610.0 + +[node name="Button" type="Button" parent="CenterContainer"] +margin_left = 444.0 +margin_top = 295.0 +margin_right = 585.0 +margin_bottom = 315.0 +text = "You clicked: 0 times" +[connection signal="pressed" from="CenterContainer/Button" to="." method="_on_Button_pressed"] diff --git a/default_env.tres b/default_env.tres new file mode 100644 index 0000000..20207a4 --- /dev/null +++ b/default_env.tres @@ -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 ) diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..fd3740e --- /dev/null +++ b/project.godot @@ -0,0 +1,24 @@ +; 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=[ ] +_global_script_class_icons={ + +} + +[application] + +config/name="clicking game" +run/main_scene="res://Node2D.tscn" +config/icon="res://icon.png" + +[rendering] + +environment/default_environment="res://default_env.tres"