Add files via upload

master
AiTechEye 2019-09-24 20:47:13 +02:00 committed by GitHub
parent 7e7579c473
commit 41bdece2cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 85 additions and 0 deletions

34
Node2D.gd Normal file
View File

@ -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()

20
Node2D.tscn Normal file
View File

@ -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"]

7
default_env.tres Normal file
View File

@ -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 )

24
project.godot Normal file
View File

@ -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"