Browse Source

Add main menu

Added a main menu which is where the game starts and goes too once the
rocket hits an asteroid. Very basic for now.
master
Abheek Dhawan 4 years ago
parent
commit
0ad371163d
  1. 1
      Game Scenes/Game.tscn
  2. 58
      Game Scenes/MainMenu.tscn
  3. 8
      Scripts/Rocket.gd
  4. 9
      Scripts/Text Container.gd
  5. 7
      project.godot

1
Game Scenes/Game.tscn

@ -79,6 +79,7 @@ __meta__ = {
position = Vector2( -8.0022, -34.2137 )
scale = Vector2( 0.401688, 0.401688 )
frames = SubResource( 6 )
frame = 2
playing = true
[node name="ParallaxBackground" type="ParallaxBackground" parent="."]

58
Game Scenes/MainMenu.tscn

@ -0,0 +1,58 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://Scripts/Text Container.gd" type="Script" id=1]
[ext_resource path="res://Objects/Rocket.tscn" type="PackedScene" id=2]
[ext_resource path="res://Images and Anims/In Game/background.png" type="Texture" id=3]
[node name="MarginContainer" type="MarginContainer"]
anchor_right = 1.0
anchor_bottom = 1.0
custom_constants/margin_right = 120
custom_constants/margin_top = 80
custom_constants/margin_left = 120
custom_constants/margin_bottom = 80
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Rocket" parent="." instance=ExtResource( 2 )]
position = Vector2( 416, 760 )
scale = Vector2( 15, 15 )
[node name="Text Container" type="Node2D" parent="."]
position = Vector2( 414, 896 )
script = ExtResource( 1 )
[node name="AsteroidDodge" type="Label" parent="Text Container"]
margin_left = -321.63
margin_top = -826.827
margin_right = -257.63
margin_bottom = -778.827
rect_scale = Vector2( 10, 10 )
text = "ASTEROID
DODGE
"
align = 1
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Tap" type="Label" parent="Text Container"]
margin_left = -264.901
margin_top = 682.457
margin_right = -191.901
margin_bottom = 696.457
rect_scale = Vector2( 7, 7 )
text = "Tap to play!"
align = 1
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Sprite" type="Sprite" parent="."]
position = Vector2( 344.221, 738.579 )
scale = Vector2( 4.19527, 4.19527 )
z_index = -1
texture = ExtResource( 3 )

8
Scripts/Rocket.gd

@ -5,12 +5,18 @@ var difficulty
var deltaDifficulty = 0
var explosionObj = load("res://Objects/Explosion.tscn")
var collided = false
onready var gameNode = get_node("/root/Game")
func _process(delta):
difficulty = 600 + deltaDifficulty
difficulty += 0.0005
var score = -position.y/10
var collision = move_and_collide(Vector2(difficulty * sin(angle) * delta, -difficulty * cos(angle) * delta))
if collision:
var lastscore = score
if score > gameNode.hiscore:
gameNode.hiscore = score
score = 0
collided = true
hide()
var explosion = explosionObj.instance()
@ -19,7 +25,7 @@ func _process(delta):
get_node("Collider").queue_free()
yield(get_tree().create_timer(1.5), "timeout")
queue_free()
get_tree().reload_current_scene()
get_tree().change_scene("res://Game Scenes/MainMenu.tscn")
if Input.is_mouse_button_pressed(BUTTON_LEFT):
if (get_viewport().get_mouse_position().x <= get_viewport_rect().size.x/2):
if angle > -1.5:

9
Scripts/Text Container.gd

@ -0,0 +1,9 @@
extends Node2D
var time = 0
func _process(delta):
time += delta
rotation = sin(time)/10
if Input.is_mouse_button_pressed(BUTTON_LEFT):
get_tree().change_scene("res://Game Scenes/Game.tscn")

7
project.godot

@ -17,10 +17,15 @@ _global_script_class_icons={
config/name="SpacEscape"
config/description="Simple game based on avoiding asteroids while controlling a rocket."
run/main_scene="res://Game Scenes/Game.tscn"
run/main_scene="res://Game Scenes/MainMenu.tscn"
boot_splash/image="res://Images and Anims/Other/logo.png"
config/icon="res://Images and Anims/Other/icon.png"
[display]
window/size/width=828
window/size/height=1792
[input]
turn_left={

Loading…
Cancel
Save