Skip to content

Commit

Permalink
Score
Browse files Browse the repository at this point in the history
  • Loading branch information
neuberpe committed Feb 2, 2018
1 parent 8cd2df3 commit c8de01d
Show file tree
Hide file tree
Showing 15 changed files with 173 additions and 4 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
41 changes: 41 additions & 0 deletions scenes/bonus.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[gd_scene load_steps=4 format=2]

[ext_resource path="res://scripts/bonus.gd" type="Script" id=1]
[ext_resource path="res://sprite/bonus.png" type="Texture" id=2]

[sub_resource type="CircleShape2D" id=1]

custom_solver_bias = 0.0
radius = 15.0

[node name="bonus" type="RigidBody2D"]

input_pickable = false
collision_layer = 1
collision_mask = 1
mode = 0
mass = 1.0
friction = 1.0
bounce = 0.0
gravity_scale = 1.0
custom_integrator = false
continuous_cd = 0
contacts_reported = 0
contact_monitor = false
sleeping = false
can_sleep = true
linear_velocity = Vector2( 0, 0 )
linear_damp = -1.0
angular_velocity = 0.0
angular_damp = -1.0
script = ExtResource( 1 )

[node name="sprite" type="Sprite" parent="." index="0"]

texture = ExtResource( 2 )

[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="1"]

shape = SubResource( 1 )


27 changes: 27 additions & 0 deletions scenes/score.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[gd_scene load_steps=2 format=2]

[ext_resource path="res://scripts/score.gd" type="Script" id=1]

[node name="score" type="Label"]

anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 40.0
margin_bottom = 14.0
rect_pivot_offset = Vector2( 0, 0 )
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
custom_colors/font_color = Color( 0, 0, 0, 0.817686 )
custom_colors/font_color_shadow = Color( 0, 0, 0, 0.364627 )
text = "0"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
script = ExtResource( 1 )
_sections_unfolded = [ "custom_colors" ]


1 change: 1 addition & 0 deletions scripts/ball.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
extends RigidBody2D

func _ready():
add_to_group("player")
set_contact_monitor(true)
set_max_contacts_reported(3)
connect("body_entered", self, "_on_body_enter")
Expand Down
15 changes: 15 additions & 0 deletions scripts/bonus.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
extends RigidBody2D



func _ready():
add_to_group("bonus")
set_contact_monitor(true)
set_max_contacts_reported(2)
connect("body_entered", self, "_on_body_enter")
set_process(true)

func _on_body_enter(other):
if other.is_in_group("player"):
get_parent().points += 10
queue_free()
27 changes: 27 additions & 0 deletions scripts/bonus_spawner.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
extends Node

const boon = preload("res://scenes/bonus.tscn")
var counter = 0
export var cooldown = 3.0
var points = 0

func _ready():
spawn()
set_process(true)
pass

func _process(delta):
counter += delta
if counter > cooldown:
spawn()
counter = 0

func spawn():
randomize()
var bonus = boon.instance()
var pos = Vector2()
pos.x = rand_range(0+14,164)
pos.y = 0-8
bonus.position=pos
self.add_child(bonus)
pass
11 changes: 11 additions & 0 deletions scripts/score.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
extends Label

var score = 0

func _ready():
set_process(true)
pass

func _process(delta):
score = get_node("../bonus_spawner").points
set_text(str(score))
Binary file added sprite/bonus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions sprite/bonus.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/bonus.png-1175ca28e2725613d92f04eaac1e4c79.stex"

[deps]

source_file="res://sprite/bonus.png"
source_md5="1c19da82992634eda0f8bc60e5f3f1ed"

dest_files=[ "res://.import/bonus.png-1175ca28e2725613d92f04eaac1e4c79.stex" ]
dest_md5="3b1369e551a26858544763d65bea8785"

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
23 changes: 19 additions & 4 deletions stage/world.tscn
Original file line number Diff line number Diff line change
@@ -1,25 +1,40 @@
[gd_scene load_steps=5 format=2]
[gd_scene load_steps=7 format=2]

[ext_resource path="res://scenes/ball.tscn" type="PackedScene" id=1]
[ext_resource path="res://scenes/bar.tscn" type="PackedScene" id=2]
[ext_resource path="res://scenes/ice_spawner.tscn" type="PackedScene" id=3]
[ext_resource path="res://sprite/background.png" type="Texture" id=4]
[ext_resource path="res://scripts/bonus_spawner.gd" type="Script" id=4]
[ext_resource path="res://sprite/background.png" type="Texture" id=5]
[ext_resource path="res://scenes/score.tscn" type="PackedScene" id=6]

[node name="world" type="Node" index="0"]

[node name="ball" parent="." index="0" instance=ExtResource( 1 )]

z_index = 10
_sections_unfolded = [ "Transform", "Z Index" ]

[node name="bar" parent="." index="1" instance=ExtResource( 2 )]

z_index = 10
_sections_unfolded = [ "Transform", "Z Index" ]

[node name="ice_spawner" parent="." index="2" instance=ExtResource( 3 )]

cooldown = 2.0

[node name="background" type="Sprite" parent="." index="3"]
[node name="bonus_spawner" type="Node" parent="." index="3"]

script = ExtResource( 4 )
cooldown = 10.0

[node name="background" type="Sprite" parent="." index="4"]

z_index = -5
texture = ExtResource( 4 )
texture = ExtResource( 5 )
centered = false
_sections_unfolded = [ "Offset", "Z Index" ]

[node name="score" parent="." index="5" instance=ExtResource( 6 )]


0 comments on commit c8de01d

Please sign in to comment.