mirror of
https://github.com/Yadciel1/2048-Shooter.git
synced 2024-11-08 23:21:22 +01:00
Score
This commit is contained in:
parent
13394479bd
commit
015c1ad0ae
BIN
Export/Game.apk
BIN
Export/Game.apk
Binary file not shown.
Binary file not shown.
@ -5,6 +5,7 @@ const SlotClass = preload("res:///Objects/Slot.gd")
|
|||||||
var Panzer_Temp = preload("res://Objects/Panzer.tscn")
|
var Panzer_Temp = preload("res://Objects/Panzer.tscn")
|
||||||
onready var game_slots = $VBoxContainer/PanzerSlots
|
onready var game_slots = $VBoxContainer/PanzerSlots
|
||||||
onready var overlay_node = find_node("Overlay")
|
onready var overlay_node = find_node("Overlay")
|
||||||
|
var score_file = "user://highscore_2048Shooter.save"
|
||||||
var holding_item = null
|
var holding_item = null
|
||||||
var buy_panzer_left = 0
|
var buy_panzer_left = 0
|
||||||
var life = 100
|
var life = 100
|
||||||
@ -30,6 +31,7 @@ func _ready():
|
|||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
if $Panel/Area2D/LifeBar.value == 0:
|
if $Panel/Area2D/LifeBar.value == 0:
|
||||||
|
save_score()
|
||||||
get_tree().change_scene("res://Main Scenes/GameOver.tscn")
|
get_tree().change_scene("res://Main Scenes/GameOver.tscn")
|
||||||
|
|
||||||
func slot_gui_input(event: InputEvent, slot: SlotClass):
|
func slot_gui_input(event: InputEvent, slot: SlotClass):
|
||||||
@ -146,7 +148,24 @@ func drag_drop_handle(hover):
|
|||||||
var temp2 = holding_item
|
var temp2 = holding_item
|
||||||
hover.pickFromSlot()
|
hover.pickFromSlot()
|
||||||
hover.putIntoSlot(holding_item)
|
hover.putIntoSlot(holding_item)
|
||||||
print(holding_item.old_slot)
|
|
||||||
temp2.old_slot.putIntoSlot(temp)
|
temp2.old_slot.putIntoSlot(temp)
|
||||||
holding_item = null
|
holding_item = null
|
||||||
|
elif holding_item.old_slot == null:
|
||||||
|
var temp = hover.Panzer
|
||||||
|
var temp2 = holding_item
|
||||||
|
hover.pickFromSlot()
|
||||||
|
hover.putIntoSlot(holding_item)
|
||||||
|
holding_item = temp
|
||||||
|
holding_item.global_position = get_global_mouse_position()
|
||||||
|
holding_item.old_slot = null
|
||||||
|
|
||||||
|
func save_score():
|
||||||
|
var highscoreNode = find_node("Score")
|
||||||
|
var f = File.new()
|
||||||
|
if f.file_exists(score_file):
|
||||||
|
f.open(score_file, File.READ)
|
||||||
|
if (f.get_var() as int) > 0:
|
||||||
|
f.close()
|
||||||
|
f.open(score_file,File.WRITE)
|
||||||
|
f.store_var(highscoreNode.text)
|
||||||
|
f.close()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=5 format=2]
|
[gd_scene load_steps=6 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://Font/super-legend-boy-font/SuperLegendBoy-4w8Y.ttf" type="DynamicFontData" id=1]
|
[ext_resource path="res://Font/super-legend-boy-font/SuperLegendBoy-4w8Y.ttf" type="DynamicFontData" id=1]
|
||||||
[ext_resource path="res://retrowave.png" type="Texture" id=2]
|
[ext_resource path="res://retrowave.png" type="Texture" id=2]
|
||||||
@ -6,7 +6,7 @@
|
|||||||
[sub_resource type="GDScript" id=2]
|
[sub_resource type="GDScript" id=2]
|
||||||
script/source = "extends Node2D
|
script/source = "extends Node2D
|
||||||
|
|
||||||
|
var score_file = \"user://highscore_2048Shooter.save\"
|
||||||
# Declare member variables here. Examples:
|
# Declare member variables here. Examples:
|
||||||
# var a = 2
|
# var a = 2
|
||||||
# var b = \"text\"
|
# var b = \"text\"
|
||||||
@ -14,6 +14,7 @@ script/source = "extends Node2D
|
|||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
|
load_score()
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
@ -25,12 +26,27 @@ func _ready():
|
|||||||
func _on_Start_pressed():
|
func _on_Start_pressed():
|
||||||
get_tree().change_scene(\"res://Main Scenes/Game.tscn\")
|
get_tree().change_scene(\"res://Main Scenes/Game.tscn\")
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
|
func load_score():
|
||||||
|
var f = File.new()
|
||||||
|
if f.file_exists(score_file):
|
||||||
|
$Control/Score.visible = true
|
||||||
|
f.open(score_file, File.READ)
|
||||||
|
$Control/Score.text = \"Score: \" + f.get_var() as String
|
||||||
|
f.close()
|
||||||
|
else:
|
||||||
|
$Control/Score.text = '0'
|
||||||
"
|
"
|
||||||
|
|
||||||
[sub_resource type="DynamicFont" id=1]
|
[sub_resource type="DynamicFont" id=1]
|
||||||
font_data = ExtResource( 1 )
|
font_data = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="Node2D" type="Node2D"]
|
[sub_resource type="DynamicFont" id=3]
|
||||||
|
size = 40
|
||||||
|
font_data = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="MainMenu" type="Node2D"]
|
||||||
script = SubResource( 2 )
|
script = SubResource( 2 )
|
||||||
|
|
||||||
[node name="Background" type="Sprite" parent="."]
|
[node name="Background" type="Sprite" parent="."]
|
||||||
@ -54,9 +70,9 @@ anchor_top = 0.5
|
|||||||
anchor_right = 0.5
|
anchor_right = 0.5
|
||||||
anchor_bottom = 0.5
|
anchor_bottom = 0.5
|
||||||
margin_left = -180.0
|
margin_left = -180.0
|
||||||
margin_top = -12.0
|
margin_top = 244.0
|
||||||
margin_right = 140.0
|
margin_right = 140.0
|
||||||
margin_bottom = 140.0
|
margin_bottom = 396.0
|
||||||
|
|
||||||
[node name="Button" type="Button" parent="Control/VBoxContainer"]
|
[node name="Button" type="Button" parent="Control/VBoxContainer"]
|
||||||
margin_right = 320.0
|
margin_right = 320.0
|
||||||
@ -65,4 +81,12 @@ rect_min_size = Vector2( 0, 70 )
|
|||||||
custom_fonts/font = SubResource( 1 )
|
custom_fonts/font = SubResource( 1 )
|
||||||
text = "Start"
|
text = "Start"
|
||||||
|
|
||||||
|
[node name="Score" type="Label" parent="Control"]
|
||||||
|
margin_left = -264.0
|
||||||
|
margin_top = -424.0
|
||||||
|
margin_right = -69.0
|
||||||
|
margin_bottom = -368.0
|
||||||
|
custom_fonts/font = SubResource( 3 )
|
||||||
|
text = "Score: "
|
||||||
|
|
||||||
[connection signal="pressed" from="Control/VBoxContainer/Button" to="." method="_on_Start_pressed"]
|
[connection signal="pressed" from="Control/VBoxContainer/Button" to="." method="_on_Start_pressed"]
|
||||||
|
@ -103,14 +103,14 @@ __meta__ = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[node name="Banner" type="HBoxContainer" parent="Background/TabContainer/AdFormats/VBoxContainer"]
|
[node name="Banner" type="HBoxContainer" parent="Background/TabContainer/AdFormats/VBoxContainer"]
|
||||||
margin_top = 46.0
|
margin_top = 65.0
|
||||||
margin_right = 426.0
|
margin_right = 408.0
|
||||||
margin_bottom = 66.0
|
margin_bottom = 85.0
|
||||||
size_flags_vertical = 0
|
size_flags_vertical = 0
|
||||||
alignment = 1
|
alignment = 1
|
||||||
|
|
||||||
[node name="EnableBanner" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer/Banner"]
|
[node name="EnableBanner" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer/Banner"]
|
||||||
margin_right = 211.0
|
margin_right = 202.0
|
||||||
margin_bottom = 20.0
|
margin_bottom = 20.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
disabled = true
|
disabled = true
|
||||||
@ -120,22 +120,22 @@ __meta__ = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[node name="DisableBanner" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer/Banner"]
|
[node name="DisableBanner" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer/Banner"]
|
||||||
margin_left = 215.0
|
margin_left = 206.0
|
||||||
margin_right = 426.0
|
margin_right = 408.0
|
||||||
margin_bottom = 20.0
|
margin_bottom = 20.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
disabled = true
|
disabled = true
|
||||||
text = "DISABLE BANNER"
|
text = "DISABLE BANNER"
|
||||||
|
|
||||||
[node name="Banner2" type="HBoxContainer" parent="Background/TabContainer/AdFormats/VBoxContainer"]
|
[node name="Banner2" type="HBoxContainer" parent="Background/TabContainer/AdFormats/VBoxContainer"]
|
||||||
margin_top = 70.0
|
margin_top = 89.0
|
||||||
margin_right = 426.0
|
margin_right = 408.0
|
||||||
margin_bottom = 90.0
|
margin_bottom = 109.0
|
||||||
size_flags_vertical = 0
|
size_flags_vertical = 0
|
||||||
alignment = 1
|
alignment = 1
|
||||||
|
|
||||||
[node name="ShowBanner" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer/Banner2"]
|
[node name="ShowBanner" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer/Banner2"]
|
||||||
margin_right = 211.0
|
margin_right = 202.0
|
||||||
margin_bottom = 20.0
|
margin_bottom = 20.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
disabled = true
|
disabled = true
|
||||||
@ -145,31 +145,31 @@ __meta__ = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[node name="HideBanner" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer/Banner2"]
|
[node name="HideBanner" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer/Banner2"]
|
||||||
margin_left = 215.0
|
margin_left = 206.0
|
||||||
margin_right = 426.0
|
margin_right = 408.0
|
||||||
margin_bottom = 20.0
|
margin_bottom = 20.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
disabled = true
|
disabled = true
|
||||||
text = "HIDE BANNER"
|
text = "HIDE BANNER"
|
||||||
|
|
||||||
[node name="Interstitial" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer"]
|
[node name="Interstitial" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer"]
|
||||||
margin_top = 94.0
|
margin_top = 113.0
|
||||||
margin_right = 426.0
|
margin_right = 408.0
|
||||||
margin_bottom = 114.0
|
margin_bottom = 133.0
|
||||||
disabled = true
|
disabled = true
|
||||||
text = "INTERSTITIAL"
|
text = "INTERSTITIAL"
|
||||||
|
|
||||||
[node name="Rewarded" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer"]
|
[node name="Rewarded" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer"]
|
||||||
margin_top = 118.0
|
margin_top = 137.0
|
||||||
margin_right = 426.0
|
margin_right = 408.0
|
||||||
margin_bottom = 138.0
|
margin_bottom = 157.0
|
||||||
disabled = true
|
disabled = true
|
||||||
text = "REWARDED"
|
text = "REWARDED"
|
||||||
|
|
||||||
[node name="RewardedInterstitial" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer"]
|
[node name="RewardedInterstitial" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer"]
|
||||||
margin_top = 142.0
|
margin_top = 161.0
|
||||||
margin_right = 426.0
|
margin_right = 408.0
|
||||||
margin_bottom = 162.0
|
margin_bottom = 181.0
|
||||||
disabled = true
|
disabled = true
|
||||||
text = "REWARDED INTERSTITIAL"
|
text = "REWARDED INTERSTITIAL"
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ config={
|
|||||||
"size": "BANNER",
|
"size": "BANNER",
|
||||||
"unit_ids": {
|
"unit_ids": {
|
||||||
"Android": {
|
"Android": {
|
||||||
"standard": "ca-app-pub-3940256099942544/6300978111"
|
"standard": "ca-app-pub-8587655649812919~8719438638"
|
||||||
},
|
},
|
||||||
"iOS": {
|
"iOS": {
|
||||||
"standard": "ca-app-pub-3940256099942544/2934735716"
|
"standard": "ca-app-pub-3940256099942544/2934735716"
|
||||||
@ -33,12 +33,12 @@ config={
|
|||||||
"general": {
|
"general": {
|
||||||
"is_enabled": true,
|
"is_enabled": true,
|
||||||
"is_for_child_directed_treatment": false,
|
"is_for_child_directed_treatment": false,
|
||||||
"max_ad_content_rating": "PG"
|
"max_ad_content_rating": "G"
|
||||||
},
|
},
|
||||||
"interstitial": {
|
"interstitial": {
|
||||||
"unit_ids": {
|
"unit_ids": {
|
||||||
"Android": {
|
"Android": {
|
||||||
"standard": "ca-app-pub-3940256099942544/1033173712"
|
"standard": "ca-app-pub-8587655649812919~8719438638"
|
||||||
},
|
},
|
||||||
"iOS": {
|
"iOS": {
|
||||||
"standard": "ca-app-pub-3940256099942544/4411468910"
|
"standard": "ca-app-pub-3940256099942544/4411468910"
|
||||||
@ -48,7 +48,7 @@ config={
|
|||||||
"rewarded": {
|
"rewarded": {
|
||||||
"unit_ids": {
|
"unit_ids": {
|
||||||
"Android": {
|
"Android": {
|
||||||
"standard": "ca-app-pub-3940256099942544/5224354917"
|
"standard": "ca-app-pub-8587655649812919~8719438638"
|
||||||
},
|
},
|
||||||
"iOS": {
|
"iOS": {
|
||||||
"standard": "ca-app-pub-3940256099942544/1712485313"
|
"standard": "ca-app-pub-3940256099942544/1712485313"
|
||||||
@ -58,7 +58,7 @@ config={
|
|||||||
"rewarded_interstitial": {
|
"rewarded_interstitial": {
|
||||||
"unit_ids": {
|
"unit_ids": {
|
||||||
"Android": {
|
"Android": {
|
||||||
"standard": "ca-app-pub-3940256099942544/5354046379"
|
"standard": "ca-app-pub-8587655649812919~8719438638"
|
||||||
},
|
},
|
||||||
"iOS": {
|
"iOS": {
|
||||||
"standard": "ca-app-pub-3940256099942544/6978759866"
|
"standard": "ca-app-pub-3940256099942544/6978759866"
|
||||||
|
Loading…
Reference in New Issue
Block a user