Skip to content
Snippets Groups Projects
Commit 5bb0a8fa authored by florian.hassler's avatar florian.hassler
Browse files

functionnal game with godot

parent ba4a6e01
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ extends Spatial ...@@ -3,7 +3,7 @@ extends Spatial
# Declare member variables here. Examples: # Declare member variables here. Examples:
# var a = 2 # var a = 2
# var b = "text" # var b = "text"
var score = 0
# 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():
var VR = ARVRServer.find_interface("Oculus") var VR = ARVRServer.find_interface("Oculus")
...@@ -20,3 +20,9 @@ func _ready(): ...@@ -20,3 +20,9 @@ func _ready():
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta): #func _process(delta):
# pass # pass
func increase_score():
score=score+1
func get_score():
return score
\ No newline at end of file
[gd_scene load_steps=15 format=2] [gd_scene load_steps=19 format=2]
[ext_resource path="res://Game.gd" type="Script" id=1] [ext_resource path="res://Game.gd" type="Script" id=1]
[ext_resource path="res://Player.gd" type="Script" id=2] [ext_resource path="res://Player.gd" type="Script" id=2]
[ext_resource path="res://pickup.gd" type="Script" id=3]
[sub_resource type="SphereShape" id=1] [sub_resource type="SphereShape" id=1]
...@@ -37,6 +38,13 @@ bounce = 0.5 ...@@ -37,6 +38,13 @@ bounce = 0.5
[sub_resource type="PhysicsMaterial" id=12] [sub_resource type="PhysicsMaterial" id=12]
bounce = 0.5 bounce = 0.5
[sub_resource type="CubeMesh" id=13]
[sub_resource type="SpatialMaterial" id=14]
albedo_color = Color( 0.992157, 0.905882, 0, 1 )
[sub_resource type="BoxShape" id=15]
[node name="Game" type="Spatial"] [node name="Game" type="Spatial"]
script = ExtResource( 1 ) script = ExtResource( 1 )
...@@ -52,7 +60,6 @@ script = ExtResource( 2 ) ...@@ -52,7 +60,6 @@ script = ExtResource( 2 )
[node name="Camera" type="Camera" parent="Player"] [node name="Camera" type="Camera" parent="Player"]
transform = Transform( 1, 0, 0, 0, 0.707107, 0.707107, 0, -0.707107, 0.707107, 0, 10.7425, 10.738 ) transform = Transform( 1, 0, 0, 0, 0.707107, 0.707107, 0, -0.707107, 0.707107, 0, 10.7425, 10.738 )
visible = false
[node name="CollisionShape" type="CollisionShape" parent="Player"] [node name="CollisionShape" type="CollisionShape" parent="Player"]
shape = SubResource( 1 ) shape = SubResource( 1 )
...@@ -67,23 +74,21 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 7.4796, 11 ) ...@@ -67,23 +74,21 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 7.4796, 11 )
[node name="ARVRCamera" type="ARVRCamera" parent="Player/ARVROrigin"] [node name="ARVRCamera" type="ARVRCamera" parent="Player/ARVROrigin"]
[node name="StaticBody" type="StaticBody" parent="."] [node name="floor" type="StaticBody" parent="."]
editor/display_folded = true editor/display_folded = true
transform = Transform( 10, 0, 0, 0, 0.01, 0, 0, 0, 10, 0, 0, 0 ) transform = Transform( 10, 0, 0, 0, 0.01, 0, 0, 0, 10, 0, 0, 0 )
[node name="MeshInstance" type="MeshInstance" parent="StaticBody"] [node name="MeshInstance" type="MeshInstance" parent="floor"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.07057, 0 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.000484419, 2.2213, 0.000886536 )
mesh = SubResource( 4 ) mesh = SubResource( 4 )
material/0 = SubResource( 5 ) material/0 = SubResource( 5 )
[node name="CollisionShape" type="CollisionShape" parent="StaticBody"] [node name="CollisionShape" type="CollisionShape" parent="floor"]
shape = SubResource( 6 ) shape = SubResource( 6 )
[node name="walls" type="Node" parent="."] [node name="walls" type="Node" parent="."]
editor/display_folded = true
[node name="northWall" type="StaticBody" parent="walls"] [node name="northWall" type="StaticBody" parent="walls"]
editor/display_folded = true
transform = Transform( 10, 0, 0, 0, 1, 0, 0, 0, 0.3, 0, 1, -10 ) transform = Transform( 10, 0, 0, 0, 1, 0, 0, 0, 0.3, 0, 1, -10 )
physics_material_override = SubResource( 7 ) physics_material_override = SubResource( 7 )
...@@ -130,8 +135,145 @@ shape = SubResource( 8 ) ...@@ -130,8 +135,145 @@ shape = SubResource( 8 )
mesh = SubResource( 9 ) mesh = SubResource( 9 )
material/0 = null material/0 = null
[node name="Score" type="Label" parent="."]
margin_left = 21.259
margin_top = 39.1908
margin_right = 61.259
margin_bottom = 53.1908
text = "Score"
[node name="Win" type="Label" parent="."]
margin_left = 447.0
margin_top = 184.0
margin_right = 591.0
margin_bottom = 258.0
size_flags_stretch_ratio = 2.38
text = "win"
align = 1
valign = 1
[node name="Pickups" type="Node" parent="."] [node name="Pickups" type="Node" parent="."]
[node name="pickup" type="Area" parent="Pickups"]
transform = Transform( 0.4, 0, 0, 0, 0.4, 0, 0, 0, 0.4, -5.94239, 1.35348, -5.10558 )
script = ExtResource( 3 )
[node name="MeshInstance" type="MeshInstance" parent="Pickups/pickup"]
mesh = SubResource( 13 )
material/0 = SubResource( 14 )
[node name="CollisionShape" type="CollisionShape" parent="Pickups/pickup"]
shape = SubResource( 15 )
[node name="pickup2" type="Area" parent="Pickups"]
editor/display_folded = true
transform = Transform( 0.4, 0, 0, 0, 0.4, 0, 0, 0, 0.4, -5.95064, 1.03515, 0.217007 )
script = ExtResource( 3 )
[node name="MeshInstance" type="MeshInstance" parent="Pickups/pickup2"]
mesh = SubResource( 13 )
material/0 = SubResource( 14 )
[node name="CollisionShape" type="CollisionShape" parent="Pickups/pickup2"]
transform = Transform( 0.341421, -0.0585786, 0.2, 0.2, 0.2, -0.282843, -0.0585786, 0.341421, 0.2, 0, 0, 0 )
shape = SubResource( 15 )
[node name="pickup3" type="Area" parent="Pickups"]
editor/display_folded = true
transform = Transform( 0.4, 0, 0, 0, 0.4, 0, 0, 0, 0.4, -5.95064, 1.03515, 3.71801 )
script = ExtResource( 3 )
[node name="MeshInstance" type="MeshInstance" parent="Pickups/pickup3"]
mesh = SubResource( 13 )
material/0 = SubResource( 14 )
[node name="CollisionShape" type="CollisionShape" parent="Pickups/pickup3"]
transform = Transform( 0.341421, -0.0585786, 0.2, 0.2, 0.2, -0.282843, -0.0585786, 0.341421, 0.2, 0, 0, 0 )
shape = SubResource( 15 )
[node name="pickup4" type="Area" parent="Pickups"]
editor/display_folded = true
transform = Transform( 0.4, 0, 0, 0, 0.4, 0, 0, 0, 0.4, -1.81294, 1.03515, 5.51762 )
script = ExtResource( 3 )
[node name="MeshInstance" type="MeshInstance" parent="Pickups/pickup4"]
mesh = SubResource( 13 )
material/0 = SubResource( 14 )
[node name="CollisionShape" type="CollisionShape" parent="Pickups/pickup4"]
transform = Transform( 0.341421, -0.0585786, 0.2, 0.2, 0.2, -0.282843, -0.0585786, 0.341421, 0.2, 0, 0, 0 )
shape = SubResource( 15 )
[node name="pickup5" type="Area" parent="Pickups"]
editor/display_folded = true
transform = Transform( 0.4, 0, 0, 0, 0.4, 0, 0, 0, 0.4, 1.64553, 1.03515, 5.51762 )
script = ExtResource( 3 )
[node name="MeshInstance" type="MeshInstance" parent="Pickups/pickup5"]
mesh = SubResource( 13 )
material/0 = SubResource( 14 )
[node name="CollisionShape" type="CollisionShape" parent="Pickups/pickup5"]
transform = Transform( 0.341421, -0.0585786, 0.2, 0.2, 0.2, -0.282843, -0.0585786, 0.341421, 0.2, 0, 0, 0 )
shape = SubResource( 15 )
[node name="pickup6" type="Area" parent="Pickups"]
editor/display_folded = true
transform = Transform( 0.4, 0, 0, 0, 0.4, 0, 0, 0, 0.4, 4.28147, 1.03515, 2.90757 )
script = ExtResource( 3 )
[node name="MeshInstance" type="MeshInstance" parent="Pickups/pickup6"]
mesh = SubResource( 13 )
material/0 = SubResource( 14 )
[node name="CollisionShape" type="CollisionShape" parent="Pickups/pickup6"]
transform = Transform( 0.341421, -0.0585786, 0.2, 0.2, 0.2, -0.282843, -0.0585786, 0.341421, 0.2, 0, 0, 0 )
shape = SubResource( 15 )
[node name="pickup7" type="Area" parent="Pickups"]
editor/display_folded = true editor/display_folded = true
transform = Transform( 0.4, 0, 0, 0, 0.4, 0, 0, 0, 0.4, 4.28147, 1.03515, -1.57881 )
script = ExtResource( 3 )
[node name="RigidBody" type="RigidBody" parent="Pickups"] [node name="MeshInstance" type="MeshInstance" parent="Pickups/pickup7"]
mesh = SubResource( 13 )
material/0 = SubResource( 14 )
[node name="CollisionShape" type="CollisionShape" parent="Pickups/pickup7"]
transform = Transform( 0.341421, -0.0585786, 0.2, 0.2, 0.2, -0.282843, -0.0585786, 0.341421, 0.2, 0, 0, 0 )
shape = SubResource( 15 )
[node name="pickup8" type="Area" parent="Pickups"]
editor/display_folded = true
transform = Transform( 0.4, 0, 0, 0, 0.4, 0, 0, 0, 0.4, 4.28147, 1.03515, -6.06925 )
script = ExtResource( 3 )
[node name="MeshInstance" type="MeshInstance" parent="Pickups/pickup8"]
mesh = SubResource( 13 )
material/0 = SubResource( 14 )
[node name="CollisionShape" type="CollisionShape" parent="Pickups/pickup8"]
transform = Transform( 0.341421, -0.0585786, 0.2, 0.2, 0.2, -0.282843, -0.0585786, 0.341421, 0.2, 0, 0, 0 )
shape = SubResource( 15 )
[node name="pickup9" type="Area" parent="Pickups"]
transform = Transform( 0.4, 0, 0, 0, 0.4, 0, 0, 0, 0.4, 0.208534, 1.03515, -6.06925 )
script = ExtResource( 3 )
[node name="MeshInstance" type="MeshInstance" parent="Pickups/pickup9"]
mesh = SubResource( 13 )
material/0 = SubResource( 14 )
[node name="CollisionShape" type="CollisionShape" parent="Pickups/pickup9"]
transform = Transform( 0.341421, -0.0585786, 0.2, 0.2, 0.2, -0.282843, -0.0585786, 0.341421, 0.2, 0, 0, 0 )
shape = SubResource( 15 )
[connection signal="body_entered" from="Pickups/pickup" to="Pickups/pickup" method="_on_pickup_body_entered"]
[connection signal="body_entered" from="Pickups/pickup2" to="Pickups/pickup2" method="_on_pickup_body_entered"]
[connection signal="body_entered" from="Pickups/pickup3" to="Pickups/pickup3" method="_on_pickup_body_entered"]
[connection signal="body_entered" from="Pickups/pickup4" to="Pickups/pickup4" method="_on_pickup_body_entered"]
[connection signal="body_entered" from="Pickups/pickup5" to="Pickups/pickup5" method="_on_pickup_body_entered"]
[connection signal="body_entered" from="Pickups/pickup6" to="Pickups/pickup6" method="_on_pickup_body_entered"]
[connection signal="body_entered" from="Pickups/pickup7" to="Pickups/pickup7" method="_on_pickup_body_entered"]
[connection signal="body_entered" from="Pickups/pickup8" to="Pickups/pickup8" method="_on_pickup_body_entered"]
[connection signal="body_entered" from="Pickups/pickup9" to="Pickups/pickup9" method="_on_pickup_body_entered"]
extends RigidBody extends RigidBody
var speed = 10 var speed = 20
# Declare member variables here. Examples: # Declare member variables here. Examples:
# var a = 2 # var a = 2
# var b = "text" # var b = "text"
...@@ -23,3 +23,4 @@ func _process(delta): ...@@ -23,3 +23,4 @@ func _process(delta):
if Input.is_action_pressed("ui_up"): if Input.is_action_pressed("ui_up"):
velocity.z -= 1 velocity.z -= 1
add_force(velocity*speed,Vector3(0,0,0)) add_force(velocity*speed,Vector3(0,0,0))
extends Area
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
var score_lbl
var lbl_win
var game_control
# Called when the node enters the scene tree for the first time.
func _ready():
score_lbl = get_node("/root/Game/Score")
lbl_win = get_node("/root/Game/Win")
game_control=get_node("/root/Game")
lbl_win.set_text("")
display_score()
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func _process(delta):
rotate_x(deg2rad(15*delta))
rotate_y(deg2rad(30*delta))
rotate_z(deg2rad(45*delta))
func _on_pickup_body_entered(body):
if body is RigidBody:
game_control.increase_score()
display_score()
queue_free()
func display_score():
var score =game_control.get_score()
score_lbl.set_text("score: "+str(score))
if score>=9:
lbl_win.set_text("YOU WIN!")
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment