mirror of
https://github.com/Yadciel1/2048-Shooter.git
synced 2025-06-16 11:15:23 +02:00
Big_update
This commit is contained in:
152
Main Scenes/Game.gd
Normal file
152
Main Scenes/Game.gd
Normal file
@ -0,0 +1,152 @@
|
||||
extends Node2D
|
||||
|
||||
|
||||
const SlotClass = preload("res:///Objects/Slot.gd")
|
||||
var Panzer_Temp = preload("res://Objects/Panzer.tscn")
|
||||
onready var game_slots = $VBoxContainer/PanzerSlots
|
||||
onready var overlay_node = find_node("Overlay")
|
||||
var holding_item = null
|
||||
var buy_panzer_left = 0
|
||||
var life = 100
|
||||
var hover = null
|
||||
onready var start_panzer = 1
|
||||
var rng = RandomNumberGenerator.new()
|
||||
|
||||
signal speed_shoot
|
||||
|
||||
func _ready():
|
||||
#Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
|
||||
var node = String("Slot ")
|
||||
node += rng.randi_range(1, 8) as String
|
||||
node = find_node(node)
|
||||
node.start_panzer += 1;
|
||||
$Panel/Area2D/LifeBar.value = life
|
||||
overlay_node.connect("score", self, "update_life_bar")
|
||||
for gam_slot in game_slots.get_children():
|
||||
gam_slot.connect("gui_input", self, "slot_gui_input", [gam_slot])
|
||||
var pBars = get_tree().get_nodes_in_group("XP")
|
||||
for pBar in pBars:
|
||||
pBar.connect("full_bar", self, "_enable_Panzer")
|
||||
|
||||
func _process(delta):
|
||||
if $Panel/Area2D/LifeBar.value == 0:
|
||||
get_tree().change_scene("res://Main Scenes/GameOver.tscn")
|
||||
|
||||
func slot_gui_input(event: InputEvent, slot: SlotClass):
|
||||
# if OS.get_name() != "Android":
|
||||
# if event is InputEventMouseButton:
|
||||
# if event.button_index == BUTTON_LEFT && event.pressed:
|
||||
# _Panzer_Slot_handler(event, slot)
|
||||
# else:
|
||||
if event is InputEventScreenTouch:
|
||||
if event.pressed:
|
||||
_Panzer_Slot_handler_touch(event, slot)
|
||||
else:
|
||||
if holding_item != null and hover == null and holding_item.old_slot != null:
|
||||
holding_item.old_slot.putIntoSlot(holding_item)
|
||||
holding_item = null
|
||||
elif holding_item != null and hover != null:
|
||||
drag_drop_handle(hover)
|
||||
else:
|
||||
pass
|
||||
pass
|
||||
|
||||
|
||||
func _input(event):
|
||||
if event is InputEventScreenDrag:
|
||||
if holding_item:
|
||||
holding_item.global_position = get_global_mouse_position()
|
||||
pass
|
||||
|
||||
|
||||
func _on_Panzer_pressed():
|
||||
if holding_item == null:
|
||||
buy_panzer_left -= 1
|
||||
if buy_panzer_left == 0:
|
||||
$VBoxContainer/ButtonGrid/Panzer.disabled = true
|
||||
var Panzer = null
|
||||
Panzer = Panzer_Temp.instance()
|
||||
add_child(Panzer)
|
||||
holding_item = Panzer
|
||||
holding_item.global_position = get_global_mouse_position()
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
func _on_Speed_pressed():
|
||||
var value = 0.5
|
||||
emit_signal("speed_shoot", value)
|
||||
$VBoxContainer/ButtonGrid/Speed.disabled = true
|
||||
pass # Replace with function body.
|
||||
|
||||
func _enable_Panzer(value):
|
||||
buy_panzer_left += 1
|
||||
$VBoxContainer/ButtonGrid/Panzer.disabled = false
|
||||
|
||||
func update_life_bar():
|
||||
var lifebar = find_node("LifeBar")
|
||||
lifebar.value = lifebar.max_value
|
||||
pass
|
||||
|
||||
|
||||
func _on_Bullet_Grave_area_entered(area):
|
||||
if area.is_in_group("Bullet"):
|
||||
var Bullet = area.get_parent()
|
||||
Bullet.queue_free()
|
||||
pass # Replace with function body.
|
||||
|
||||
func _Panzer_Slot_handler(event: InputEvent, slot: SlotClass):
|
||||
if holding_item != null:
|
||||
if!slot.Panzer:
|
||||
slot.putIntoSlot(holding_item)
|
||||
holding_item = null
|
||||
elif slot.Panzer and holding_item.PanzerType == slot.Panzer.PanzerType:
|
||||
slot.upgradePanzerInSlot()
|
||||
holding_item.queue_free()
|
||||
holding_item = null
|
||||
else:
|
||||
print("yes")
|
||||
# var temp_item = slot.Panzer
|
||||
# slot.pickFromSlot()
|
||||
# temp_item.global_position = event.global_position
|
||||
# slot.putIntoSlot(holding_item)
|
||||
# holding_item = temp_item
|
||||
holding_item.old_slot.putIntoSlot(slot.Panzer)
|
||||
slot.Panzer.old_slot.putIntoSlot(holding_item)
|
||||
elif slot.Panzer:
|
||||
holding_item = slot.Panzer
|
||||
slot.pickFromSlot()
|
||||
holding_item.global_position = get_global_mouse_position()
|
||||
|
||||
func _Panzer_Slot_handler_touch(event: InputEvent, slot: SlotClass):
|
||||
if holding_item != null and holding_item.old_slot != slot:
|
||||
if!slot.Panzer:
|
||||
slot.putIntoSlot(holding_item)
|
||||
holding_item = null
|
||||
elif slot.Panzer and holding_item.PanzerType == slot.Panzer.PanzerType:
|
||||
slot.upgradePanzerInSlot()
|
||||
holding_item.queue_free()
|
||||
holding_item = null
|
||||
elif holding_item.old_slot != slot:
|
||||
pass
|
||||
elif slot.Panzer and holding_item == null:
|
||||
holding_item = slot.Panzer
|
||||
slot.pickFromSlot()
|
||||
holding_item.global_position = get_global_mouse_position()
|
||||
|
||||
func drag_drop_handle(hover):
|
||||
if!hover.Panzer:
|
||||
hover.putIntoSlot(holding_item)
|
||||
holding_item = null
|
||||
elif hover.Panzer and holding_item.PanzerType == hover.Panzer.PanzerType:
|
||||
hover.upgradePanzerInSlot()
|
||||
holding_item.queue_free()
|
||||
holding_item = null
|
||||
elif holding_item.old_slot != null:
|
||||
var temp = hover.Panzer
|
||||
var temp2 = holding_item
|
||||
hover.pickFromSlot()
|
||||
hover.putIntoSlot(holding_item)
|
||||
print(holding_item.old_slot)
|
||||
temp2.old_slot.putIntoSlot(temp)
|
||||
holding_item = null
|
||||
|
173
Main Scenes/Game.tscn
Normal file
173
Main Scenes/Game.tscn
Normal file
@ -0,0 +1,173 @@
|
||||
[gd_scene load_steps=14 format=2]
|
||||
|
||||
[ext_resource path="res://retrowave.png" type="Texture" id=1]
|
||||
[ext_resource path="res://Objects/Overlay.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://Main Scenes/Game.gd" type="Script" id=3]
|
||||
[ext_resource path="res://Objects/Slot.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://Objects/Spawner.gd" type="Script" id=5]
|
||||
[ext_resource path="res://Font/super-legend-boy-font/SuperLegendBoy-4w8Y.ttf" type="DynamicFontData" id=6]
|
||||
[ext_resource path="res://box.png" type="Texture" id=7]
|
||||
[ext_resource path="res://Objects/PanzerButton.tscn" type="PackedScene" id=8]
|
||||
|
||||
[sub_resource type="TileSet" id=1]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=4]
|
||||
extents = Vector2( 288, 20 )
|
||||
|
||||
[sub_resource type="StyleBoxTexture" id=3]
|
||||
texture = ExtResource( 7 )
|
||||
region_rect = Rect2( 0, 0, 8, 8 )
|
||||
|
||||
[sub_resource type="DynamicFont" id=5]
|
||||
font_data = ExtResource( 6 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=6]
|
||||
extents = Vector2( 288, 40 )
|
||||
|
||||
[node name="Game" type="Node2D"]
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Background" type="Sprite" parent="."]
|
||||
position = Vector2( 288, 592 )
|
||||
scale = Vector2( 0.463768, 0.5 )
|
||||
texture = ExtResource( 1 )
|
||||
|
||||
[node name="TileMap" type="TileMap" parent="."]
|
||||
tile_set = SubResource( 1 )
|
||||
format = 1
|
||||
|
||||
[node name="Panel" type="Panel" parent="."]
|
||||
margin_top = 760.0
|
||||
margin_right = 576.0
|
||||
margin_bottom = 800.0
|
||||
rect_min_size = Vector2( 575, 32 )
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="Panel" groups=["Border"]]
|
||||
|
||||
[node name="LifeBar" type="ProgressBar" parent="Panel/Area2D"]
|
||||
margin_right = 576.0
|
||||
margin_bottom = 40.0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Panel/Area2D"]
|
||||
position = Vector2( 288, 20 )
|
||||
shape = SubResource( 4 )
|
||||
|
||||
[node name="Spawner" type="GridContainer" parent="."]
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_top = -128.0
|
||||
margin_right = 575.0
|
||||
custom_constants/hseparation = 21
|
||||
columns = 4
|
||||
|
||||
[node name="Spawner 1" type="Panel" parent="Spawner" groups=["Spawner"]]
|
||||
margin_right = 128.0
|
||||
margin_bottom = 128.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 3 )
|
||||
script = ExtResource( 5 )
|
||||
|
||||
[node name="Spawner 2" type="Panel" parent="Spawner" groups=["Spawner"]]
|
||||
margin_left = 149.0
|
||||
margin_right = 277.0
|
||||
margin_bottom = 128.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 3 )
|
||||
script = ExtResource( 5 )
|
||||
|
||||
[node name="Spawner 3" type="Panel" parent="Spawner" groups=["Spawner"]]
|
||||
margin_left = 298.0
|
||||
margin_right = 426.0
|
||||
margin_bottom = 128.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 3 )
|
||||
script = ExtResource( 5 )
|
||||
|
||||
[node name="Spawner 4" type="Panel" parent="Spawner" groups=["Spawner"]]
|
||||
margin_left = 447.0
|
||||
margin_right = 575.0
|
||||
margin_bottom = 128.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 3 )
|
||||
script = ExtResource( 5 )
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
margin_top = 800.0
|
||||
margin_right = 575.0
|
||||
margin_bottom = 1200.0
|
||||
|
||||
[node name="PanzerSlots" type="GridContainer" parent="VBoxContainer"]
|
||||
margin_right = 575.0
|
||||
margin_bottom = 266.0
|
||||
custom_constants/vseparation = 10
|
||||
custom_constants/hseparation = 21
|
||||
columns = 4
|
||||
|
||||
[node name="Slot 1" parent="VBoxContainer/PanzerSlots" instance=ExtResource( 4 )]
|
||||
|
||||
[node name="Slot 2" parent="VBoxContainer/PanzerSlots" instance=ExtResource( 4 )]
|
||||
margin_left = 149.0
|
||||
margin_right = 277.0
|
||||
|
||||
[node name="Slot 3" parent="VBoxContainer/PanzerSlots" instance=ExtResource( 4 )]
|
||||
margin_left = 298.0
|
||||
margin_right = 426.0
|
||||
|
||||
[node name="Slot 4" parent="VBoxContainer/PanzerSlots" instance=ExtResource( 4 )]
|
||||
margin_left = 447.0
|
||||
margin_right = 575.0
|
||||
|
||||
[node name="Slot 5" parent="VBoxContainer/PanzerSlots" instance=ExtResource( 4 )]
|
||||
margin_top = 138.0
|
||||
margin_bottom = 266.0
|
||||
|
||||
[node name="Slot 6" parent="VBoxContainer/PanzerSlots" instance=ExtResource( 4 )]
|
||||
margin_left = 149.0
|
||||
margin_top = 138.0
|
||||
margin_right = 277.0
|
||||
margin_bottom = 266.0
|
||||
|
||||
[node name="Slot 7" parent="VBoxContainer/PanzerSlots" instance=ExtResource( 4 )]
|
||||
margin_left = 298.0
|
||||
margin_top = 138.0
|
||||
margin_right = 426.0
|
||||
margin_bottom = 266.0
|
||||
|
||||
[node name="Slot 8" parent="VBoxContainer/PanzerSlots" instance=ExtResource( 4 )]
|
||||
margin_left = 447.0
|
||||
margin_top = 138.0
|
||||
margin_right = 575.0
|
||||
margin_bottom = 266.0
|
||||
|
||||
[node name="ButtonGrid" type="GridContainer" parent="VBoxContainer"]
|
||||
margin_top = 270.0
|
||||
margin_right = 575.0
|
||||
margin_bottom = 398.0
|
||||
columns = 4
|
||||
|
||||
[node name="Speed" type="Button" parent="VBoxContainer/ButtonGrid"]
|
||||
margin_right = 128.0
|
||||
margin_bottom = 128.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_fonts/font = SubResource( 5 )
|
||||
disabled = true
|
||||
text = "Speed"
|
||||
|
||||
[node name="Panzer" parent="VBoxContainer/ButtonGrid" instance=ExtResource( 8 )]
|
||||
disabled = true
|
||||
|
||||
[node name="Overlay" parent="." instance=ExtResource( 2 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 575.0
|
||||
margin_bottom = 0.0
|
||||
|
||||
[node name="Bullet_Grave" type="Area2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Bullet_Grave"]
|
||||
position = Vector2( 288, -40 )
|
||||
shape = SubResource( 6 )
|
||||
|
||||
[connection signal="pressed" from="VBoxContainer/ButtonGrid/Speed" to="." method="_on_Speed_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/ButtonGrid/Panzer" to="." method="_on_Panzer_pressed"]
|
||||
[connection signal="area_entered" from="Bullet_Grave" to="." method="_on_Bullet_Grave_area_entered"]
|
48
Main Scenes/GameOver.tscn
Normal file
48
Main Scenes/GameOver.tscn
Normal file
@ -0,0 +1,48 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="GDScript" id=1]
|
||||
script/source = "extends Control
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = \"text\"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
||||
|
||||
|
||||
func _on_Button_pressed():
|
||||
get_tree().change_scene(\"res://Main Scenes/Game.tscn\")
|
||||
pass # Replace with function body.
|
||||
"
|
||||
|
||||
[node name="Control" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = SubResource( 1 )
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -20.0
|
||||
margin_top = -20.0
|
||||
margin_right = 20.0
|
||||
margin_bottom = 20.0
|
||||
|
||||
[node name="Button" type="Button" parent="VBoxContainer"]
|
||||
margin_right = 57.0
|
||||
margin_bottom = 20.0
|
||||
text = "Restart"
|
||||
icon_align = 1
|
||||
|
||||
[connection signal="pressed" from="VBoxContainer/Button" to="." method="_on_Button_pressed"]
|
68
Main Scenes/MainMenu.tscn
Normal file
68
Main Scenes/MainMenu.tscn
Normal file
@ -0,0 +1,68 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[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]
|
||||
|
||||
[sub_resource type="GDScript" id=2]
|
||||
script/source = "extends Node2D
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = \"text\"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
||||
|
||||
|
||||
func _on_Start_pressed():
|
||||
get_tree().change_scene(\"res://Main Scenes/Game.tscn\")
|
||||
pass # Replace with function body.
|
||||
"
|
||||
|
||||
[sub_resource type="DynamicFont" id=1]
|
||||
font_data = ExtResource( 1 )
|
||||
|
||||
[node name="Node2D" type="Node2D"]
|
||||
script = SubResource( 2 )
|
||||
|
||||
[node name="Background" type="Sprite" parent="."]
|
||||
position = Vector2( 288, 592 )
|
||||
scale = Vector2( 0.463768, 0.5 )
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="Control" type="Control" parent="."]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = 288.0
|
||||
margin_top = 504.0
|
||||
margin_right = 328.0
|
||||
margin_bottom = 544.0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Control"]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -180.0
|
||||
margin_top = -12.0
|
||||
margin_right = 140.0
|
||||
margin_bottom = 140.0
|
||||
|
||||
[node name="Button" type="Button" parent="Control/VBoxContainer"]
|
||||
margin_right = 320.0
|
||||
margin_bottom = 70.0
|
||||
rect_min_size = Vector2( 0, 70 )
|
||||
custom_fonts/font = SubResource( 1 )
|
||||
text = "Start"
|
||||
|
||||
[connection signal="pressed" from="Control/VBoxContainer/Button" to="." method="_on_Start_pressed"]
|
Reference in New Issue
Block a user