Skip to content

Commit 61121b9

Browse files
authored
Merge pull request #2 from Halfwhit/development
Ball, water and yellow physics added
2 parents 97faef1 + 87ae493 commit 61121b9

26 files changed

+375
-28
lines changed

Resources/ball.png Fonts/ball.png

File renamed without changes.

Resources/ball.png.import Fonts/ball.png.import

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
importer="texture"
44
type="StreamTexture"
5-
path="res://.import/ball.png-0c3280ad08e14f6566aaeef4d0612e1c.stex"
5+
path="res://.import/ball.png-4dfe03bdd509009df8ec8eba45e2593f.stex"
66
metadata={
77
"vram_texture": false
88
}
99

1010
[deps]
1111

12-
source_file="res://Resources/ball.png"
13-
dest_files=[ "res://.import/ball.png-0c3280ad08e14f6566aaeef4d0612e1c.stex" ]
12+
source_file="res://Fonts/ball.png"
13+
dest_files=[ "res://.import/ball.png-4dfe03bdd509009df8ec8eba45e2593f.stex" ]
1414

1515
[params]
1616

Resources/grass.png

-55 Bytes
Loading

Resources/hole.png

157 Bytes
Loading

Resources/slant.png

5.8 KB
Loading

Resources/slant.png.import

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="StreamTexture"
5+
path="res://.import/slant.png-11885bf6a7d04d1b062268be1ec518ff.stex"
6+
metadata={
7+
"vram_texture": false
8+
}
9+
10+
[deps]
11+
12+
source_file="res://Resources/slant.png"
13+
dest_files=[ "res://.import/slant.png-11885bf6a7d04d1b062268be1ec518ff.stex" ]
14+
15+
[params]
16+
17+
compress/mode=0
18+
compress/lossy_quality=0.7
19+
compress/hdr_mode=0
20+
compress/bptc_ldr=0
21+
compress/normal_map=0
22+
flags/repeat=0
23+
flags/filter=true
24+
flags/mipmaps=false
25+
flags/anisotropic=false
26+
flags/srgb=2
27+
process/fix_alpha_border=true
28+
process/premult_alpha=false
29+
process/HDR_as_SRGB=false
30+
process/invert_color=false
31+
stream=false
32+
size_limit=0
33+
detect_3d=true
34+
svg/scale=1.0

Resources/start.png

5.51 KB
Loading

Resources/start.png.import

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="StreamTexture"
5+
path="res://.import/start.png-0528a7d09d053d53a519b1fbc7701b39.stex"
6+
metadata={
7+
"vram_texture": false
8+
}
9+
10+
[deps]
11+
12+
source_file="res://Resources/start.png"
13+
dest_files=[ "res://.import/start.png-0528a7d09d053d53a519b1fbc7701b39.stex" ]
14+
15+
[params]
16+
17+
compress/mode=0
18+
compress/lossy_quality=0.7
19+
compress/hdr_mode=0
20+
compress/bptc_ldr=0
21+
compress/normal_map=0
22+
flags/repeat=0
23+
flags/filter=true
24+
flags/mipmaps=false
25+
flags/anisotropic=false
26+
flags/srgb=2
27+
process/fix_alpha_border=true
28+
process/premult_alpha=false
29+
process/HDR_as_SRGB=false
30+
process/invert_color=false
31+
stream=false
32+
size_limit=0
33+
detect_3d=true
34+
svg/scale=1.0

Resources/tileset.tres

+54-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
[gd_resource type="TileSet" load_steps=5 format=2]
1+
[gd_resource type="TileSet" load_steps=10 format=2]
22

33
[ext_resource path="res://Resources/grass.png" type="Texture" id=1]
44
[ext_resource path="res://Resources/wall.png" type="Texture" id=2]
55
[ext_resource path="res://Resources/hole.png" type="Texture" id=3]
6+
[ext_resource path="res://Resources/slant.png" type="Texture" id=4]
7+
[ext_resource path="res://Resources/start.png" type="Texture" id=5]
8+
[ext_resource path="res://Resources/water.png" type="Texture" id=6]
9+
[ext_resource path="res://Resources/yellow.png" type="Texture" id=7]
610

711
[sub_resource type="ConvexPolygonShape2D" id=1]
812
points = PoolVector2Array( 0, 0, 50, 0, 50, 50, 0, 50 )
913

14+
[sub_resource type="ConvexPolygonShape2D" id=2]
15+
points = PoolVector2Array( 0, 50, 0, 0, 50, 0, 0, 50 )
16+
1017
[resource]
1118
0/name = "Grass"
1219
0/texture = ExtResource( 1 )
@@ -44,4 +51,50 @@ points = PoolVector2Array( 0, 0, 50, 0, 50, 50, 0, 50 )
4451
2/navigation_offset = Vector2( 0, 0 )
4552
2/shapes = [ ]
4653
2/z_index = 0
54+
3/name = "Slant"
55+
3/texture = ExtResource( 4 )
56+
3/tex_offset = Vector2( 0, 0 )
57+
3/modulate = Color( 1, 1, 1, 1 )
58+
3/region = Rect2( 0, 0, 50, 50 )
59+
3/tile_mode = 0
60+
3/occluder_offset = Vector2( 0, 0 )
61+
3/navigation_offset = Vector2( 0, 0 )
62+
3/shapes = [ {
63+
"autotile_coord": Vector2( 0, 0 ),
64+
"one_way": false,
65+
"one_way_margin": 1.0,
66+
"shape": SubResource( 2 ),
67+
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
68+
} ]
69+
3/z_index = 0
70+
4/name = "Start"
71+
4/texture = ExtResource( 5 )
72+
4/tex_offset = Vector2( 0, 0 )
73+
4/modulate = Color( 1, 1, 1, 1 )
74+
4/region = Rect2( 0, 0, 50, 50 )
75+
4/tile_mode = 0
76+
4/occluder_offset = Vector2( 0, 0 )
77+
4/navigation_offset = Vector2( 0, 0 )
78+
4/shapes = [ ]
79+
4/z_index = 0
80+
5/name = "Water"
81+
5/texture = ExtResource( 6 )
82+
5/tex_offset = Vector2( 0, 0 )
83+
5/modulate = Color( 1, 1, 1, 1 )
84+
5/region = Rect2( 0, 0, 50, 50 )
85+
5/tile_mode = 0
86+
5/occluder_offset = Vector2( 0, 0 )
87+
5/navigation_offset = Vector2( 0, 0 )
88+
5/shapes = [ ]
89+
5/z_index = 0
90+
6/name = "Yellow"
91+
6/texture = ExtResource( 7 )
92+
6/tex_offset = Vector2( 0, 0 )
93+
6/modulate = Color( 1, 1, 1, 1 )
94+
6/region = Rect2( 0, 0, 50, 50 )
95+
6/tile_mode = 0
96+
6/occluder_offset = Vector2( 0, 0 )
97+
6/navigation_offset = Vector2( 0, 0 )
98+
6/shapes = [ ]
99+
6/z_index = 0
47100

Resources/tileset_edit.tscn

+32-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
[gd_scene load_steps=4 format=2]
1+
[gd_scene load_steps=8 format=2]
22

33
[ext_resource path="res://Resources/grass.png" type="Texture" id=1]
44
[ext_resource path="res://Resources/wall.png" type="Texture" id=2]
55
[ext_resource path="res://Resources/hole.png" type="Texture" id=3]
6+
[ext_resource path="res://Resources/slant.png" type="Texture" id=4]
7+
[ext_resource path="res://Resources/start.png" type="Texture" id=5]
8+
[ext_resource path="res://Resources/water.png" type="Texture" id=6]
9+
[ext_resource path="res://Resources/yellow.png" type="Texture" id=7]
610

711
[node name="Node2D" type="Node2D"]
812

@@ -16,6 +20,7 @@ texture = ExtResource( 2 )
1620
centered = false
1721

1822
[node name="StaticBody2D" type="StaticBody2D" parent="Wall"]
23+
collision_layer = 2
1924

2025
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Wall/StaticBody2D"]
2126
polygon = PoolVector2Array( 0, 0, 50, 0, 50, 50, 0, 50 )
@@ -25,3 +30,29 @@ position = Vector2( 100, 0 )
2530
texture = ExtResource( 3 )
2631
centered = false
2732

33+
[node name="Slant" type="Sprite" parent="."]
34+
position = Vector2( 150, 0 )
35+
texture = ExtResource( 4 )
36+
centered = false
37+
38+
[node name="StaticBody2D" type="StaticBody2D" parent="Slant"]
39+
collision_layer = 2
40+
41+
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Slant/StaticBody2D"]
42+
polygon = PoolVector2Array( 0, 50, 50, 0, 0, 0, 0, 50 )
43+
44+
[node name="Start" type="Sprite" parent="."]
45+
position = Vector2( 200, 0 )
46+
texture = ExtResource( 5 )
47+
centered = false
48+
49+
[node name="Water" type="Sprite" parent="."]
50+
position = Vector2( 0, 50 )
51+
texture = ExtResource( 6 )
52+
centered = false
53+
54+
[node name="Yellow" type="Sprite" parent="."]
55+
position = Vector2( 50, 50 )
56+
texture = ExtResource( 7 )
57+
centered = false
58+

Resources/wall.png

4.65 KB
Loading

Resources/water.png

196 Bytes
Loading

Resources/water.png.import

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="StreamTexture"
5+
path="res://.import/water.png-9089d9ada5e24425e8ca1d4f887dd9dc.stex"
6+
metadata={
7+
"vram_texture": false
8+
}
9+
10+
[deps]
11+
12+
source_file="res://Resources/water.png"
13+
dest_files=[ "res://.import/water.png-9089d9ada5e24425e8ca1d4f887dd9dc.stex" ]
14+
15+
[params]
16+
17+
compress/mode=0
18+
compress/lossy_quality=0.7
19+
compress/hdr_mode=0
20+
compress/bptc_ldr=0
21+
compress/normal_map=0
22+
flags/repeat=0
23+
flags/filter=true
24+
flags/mipmaps=false
25+
flags/anisotropic=false
26+
flags/srgb=2
27+
process/fix_alpha_border=true
28+
process/premult_alpha=false
29+
process/HDR_as_SRGB=false
30+
process/invert_color=false
31+
stream=false
32+
size_limit=0
33+
detect_3d=true
34+
svg/scale=1.0

Resources/yellow.png

194 Bytes
Loading

Resources/yellow.png.import

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="StreamTexture"
5+
path="res://.import/yellow.png-71818132e79f9d3d5fcb28f9725f4c4e.stex"
6+
metadata={
7+
"vram_texture": false
8+
}
9+
10+
[deps]
11+
12+
source_file="res://Resources/yellow.png"
13+
dest_files=[ "res://.import/yellow.png-71818132e79f9d3d5fcb28f9725f4c4e.stex" ]
14+
15+
[params]
16+
17+
compress/mode=0
18+
compress/lossy_quality=0.7
19+
compress/hdr_mode=0
20+
compress/bptc_ldr=0
21+
compress/normal_map=0
22+
flags/repeat=0
23+
flags/filter=true
24+
flags/mipmaps=false
25+
flags/anisotropic=false
26+
flags/srgb=2
27+
process/fix_alpha_border=true
28+
process/premult_alpha=false
29+
process/HDR_as_SRGB=false
30+
process/invert_color=false
31+
stream=false
32+
size_limit=0
33+
detect_3d=true
34+
svg/scale=1.0

Scenes/Assets/Hole.gd

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
extends Node2D
2+
3+
func _on_HoleArea2D_body_entered(body):
4+
if body.get_name() == "Player":
5+
print("GOAAAAAAAAAAAAAAAAL!")
6+
#get_node("Player").hide().

Scenes/Assets/Hole.tscn

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
[gd_scene load_steps=2 format=2]
1+
[gd_scene load_steps=3 format=2]
2+
3+
[ext_resource path="res://Scenes/Assets/Hole.gd" type="Script" id=1]
24

35
[sub_resource type="CircleShape2D" id=1]
46
radius = 7.07107
57

6-
[node name="Hole" type="Area2D"]
8+
[node name="Hole" type="Node2D"]
9+
script = ExtResource( 1 )
10+
11+
[node name="HoleArea2D" type="Area2D" parent="."]
712

8-
[node name="Area" type="CollisionShape2D" parent="."]
9-
position = Vector2( 25, 25 )
13+
[node name="AreaCollisionShape" type="CollisionShape2D" parent="HoleArea2D"]
1014
shape = SubResource( 1 )
1115

16+
[connection signal="body_entered" from="HoleArea2D" to="." method="_on_HoleArea2D_body_entered"]

Scenes/Assets/Player.gd

+33-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@ var max_force = 500
44
var ball_vector = Vector2()
55
var collision
66
var in_motion
7+
var in_water
8+
var in_yellow
79
var friction = 0.98
10+
var start_point
11+
var reset_point
12+
13+
func _ready():
14+
start_point = get("position")
815

916
func _draw():
1017
if in_motion == false:
@@ -26,17 +33,41 @@ func _physics_process(delta):
2633
ball_vector = ball_vector.linear_interpolate(Vector2(0,0), friction * delta)
2734

2835
func get_new_vector():
36+
reset_point = get("position")
2937
ball_vector = -get_local_mouse_position().clamped(max_force)
3038

39+
func set_new_vector(vector):
40+
ball_vector = vector
41+
3142
func check_motion():
32-
if ball_vector.length() < 1:
43+
if ball_vector.length() <= 1:
3344
ball_vector = Vector2()
3445
in_motion = false
46+
if in_water:
47+
position = reset_point
48+
in_water = false
49+
if in_yellow:
50+
position = start_point
51+
in_yellow = false
3552
else:
3653
in_motion = true
3754

3855
func hit_ball(delta):
3956
collision = move_and_collide(ball_vector * delta)
4057
if collision:
4158
ball_vector = ball_vector.bounce(collision.normal)
42-
move_and_collide(ball_vector * delta)
59+
move_and_collide(ball_vector * delta)
60+
61+
func in_water():
62+
in_water = true
63+
ball_vector /= 4
64+
65+
func in_yellow():
66+
in_yellow = true
67+
ball_vector /= 4
68+
69+
func _on_Area2D_area_entered(area):
70+
if area.get_name() == "WaterArea2D":
71+
in_water()
72+
if area.get_name() == "YellowArea2D":
73+
in_yellow()

Scenes/Assets/Player.tscn

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
[gd_scene load_steps=4 format=2]
22

33
[ext_resource path="res://Scenes/Assets/Player.gd" type="Script" id=1]
4-
[ext_resource path="res://Resources/ball.png" type="Texture" id=2]
4+
[ext_resource path="res://Fonts/ball.png" type="Texture" id=2]
55

66
[sub_resource type="CircleShape2D" id=1]
77
custom_solver_bias = 1.0
88
radius = 25.0
99

1010
[node name="Player" type="KinematicBody2D"]
11-
scale = Vector2( 0.5, 0.5 )
11+
scale = Vector2( 0.25, 0.25 )
12+
collision_mask = 7
1213
script = ExtResource( 1 )
1314

1415
[node name="Sprite" type="Sprite" parent="."]
@@ -17,3 +18,9 @@ texture = ExtResource( 2 )
1718
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
1819
shape = SubResource( 1 )
1920

21+
[node name="Area2D" type="Area2D" parent="."]
22+
23+
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
24+
shape = SubResource( 1 )
25+
26+
[connection signal="area_entered" from="Area2D" to="." method="_on_Area2D_area_entered"]

0 commit comments

Comments
 (0)