Skip to content

Commit ce8f62a

Browse files
committed
Roleta Tá Funcionando
Imagem da roleta, arquivo dela e mudança nos scripts da main para funcionar com ela
1 parent e7d94e5 commit ce8f62a

File tree

7 files changed

+155
-11
lines changed

7 files changed

+155
-11
lines changed

godot/Roleta.gd

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
extends StaticBody2D
2+
var sprite
3+
# class member variables go here, for example:
4+
# var a = 2
5+
# var b = "textvar"
6+
7+
func _ready():
8+
randomize()
9+
sprite = get_node("Sprite/AnimationPlayer")
10+
pass
11+
12+
func roleta():
13+
sprite.play("roleta")
14+
sprite.advance(randi()%8)
15+
16+
func parada():
17+
sprite.play("Parada")
18+
19+
func getframe():
20+
return sprite.get_pos()
21+
22+
func stop():
23+
sprite.stop()

godot/Roleta.tscn

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
[gd_scene load_steps=5 format=1]
2+
3+
[ext_resource path="res://Roleta.gd" type="Script" id=1]
4+
[ext_resource path="res://roleta.tex" type="Texture" id=2]
5+
6+
[sub_resource type="Animation" id=2]
7+
8+
resource/name = "Parada"
9+
length = 7.0
10+
loop = true
11+
step = 0.1
12+
tracks/0/type = "value"
13+
tracks/0/path = NodePath(".:visibility/visible")
14+
tracks/0/interp = 1
15+
tracks/0/imported = false
16+
tracks/0/keys = {
17+
"times": FloatArray( 0, 6, 6.1, 6.2, 6.5 ),
18+
"transitions": FloatArray( 1, 1, 1, 1, 1 ),
19+
"update": 1,
20+
"values": [ true, false, true, false, true ]
21+
}
22+
tracks/1/type = "value"
23+
tracks/1/path = NodePath(".:frame")
24+
tracks/1/interp = 1
25+
tracks/1/imported = false
26+
tracks/1/keys = {
27+
"times": FloatArray( 0 ),
28+
"transitions": FloatArray( 1 ),
29+
"update": 1,
30+
"values": [ 0 ]
31+
}
32+
33+
[sub_resource type="Animation" id=1]
34+
35+
resource/name = "roleta"
36+
length = 0.8
37+
loop = true
38+
step = 0.1
39+
tracks/0/type = "value"
40+
tracks/0/path = NodePath(".:frame")
41+
tracks/0/interp = 1
42+
tracks/0/imported = false
43+
tracks/0/keys = {
44+
"times": FloatArray( 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7 ),
45+
"transitions": FloatArray( 1, 1, 1, 1, 1, 1, 1, 1 ),
46+
"update": 1,
47+
"values": [ 1, 2, 3, 4, 5, 6, 7, 8 ]
48+
}
49+
tracks/1/type = "value"
50+
tracks/1/path = NodePath(".:visibility/visible")
51+
tracks/1/interp = 1
52+
tracks/1/imported = false
53+
tracks/1/keys = {
54+
"times": FloatArray( 0 ),
55+
"transitions": FloatArray( 1 ),
56+
"update": 1,
57+
"values": [ true ]
58+
}
59+
60+
[node name="Roleta" type="StaticBody2D"]
61+
62+
input/pickable = false
63+
collision/layers = 1
64+
collision/mask = 1
65+
constant_linear_velocity = Vector2( 0, 0 )
66+
constant_angular_velocity = 0.0
67+
friction = 1.0
68+
bounce = 0.0
69+
script/script = ExtResource( 1 )
70+
71+
[node name="Sprite" type="Sprite" parent="."]
72+
73+
texture = ExtResource( 2 )
74+
hframes = 9
75+
frame = 4
76+
77+
[node name="AnimationPlayer" type="AnimationPlayer" parent="Sprite"]
78+
79+
playback/process_mode = 1
80+
playback/default_blend_time = 0.0
81+
root/root = NodePath("..")
82+
anims/Parada = SubResource( 2 )
83+
anims/roleta = SubResource( 1 )
84+
playback/active = true
85+
playback/speed = 2.5
86+
blend_times = [ ]
87+
autoplay = "Parada"
88+
89+

godot/main.gd

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,50 @@ var vetorx = Vector2(-10,0)
44
var vetory = Vector2(0,3)
55
var set = 0 #usado para determinar o tempo da bola parada
66
var rightcor = 0 #usado para ver se a bola foi lançada com a cor correta
7+
var parada = 0 #usado para parar a roleta
78
var ball #a bola
9+
var roleta #a roleta
810

911

1012
func setball(): #coloca a bola no meio
1113
ball.set_global_pos(Vector2(512.5,300))
12-
if(randi()%10 > 5 ):
13-
vetorx = Vector2(10,0)
14-
ball.sprite(0)
15-
else:
16-
vetorx = Vector2(-10,0)
17-
ball.sprite(1)
18-
vetory = Vector2(0, (randi()%8-4)*3)
1914
set = 0
2015
rightcor = 0
16+
parada = 0
17+
roleta.roleta()
2118

19+
func throw(): #prepara a direçao da bola baseada na roleta
20+
var pos = roleta.getframe()
21+
roleta.stop()
22+
if(pos<0.4):
23+
vetorx = Vector2(-10,0)
24+
if(pos<0.1):
25+
vetory = Vector2(0,-14)
26+
elif(pos<0.2):
27+
vetory = Vector2(0,-4)
28+
elif(pos<0.3):
29+
vetory = Vector2(0,4)
30+
else:
31+
vetory = Vector2(0,14)
32+
else:
33+
vetorx = Vector2(10,0)
34+
if(pos<0.5):
35+
vetory = Vector2(0,14)
36+
elif(pos<0.6):
37+
vetory = Vector2(0,4)
38+
elif(pos<0.7):
39+
vetory = Vector2(0,-4)
40+
else:
41+
vetory = Vector2(0,-14)
2242

2343
func ballcollisions(): #verifica as colisoes da bola
2444
if(ball.get_collider() == get_node("BarraVermelha") or ball.get_collider() == get_node("BarraAzul")):
2545
vetorx = -vetorx
2646

2747
if(ball.get_collider_velocity() > Vector2(0,0)):
28-
vetory = vetory+Vector2(0,randi()%5+1)
48+
vetory = vetory+Vector2(0,randi()%5+3)
2949
if(ball.get_collider_velocity() < Vector2(0,0)):
30-
vetory = vetory+Vector2(0,-randi()%5+1)
50+
vetory = vetory+Vector2(0,-randi()%5+3)
3151

3252
if(vetory > Vector2(0,20)):
3353
vetory = Vector2(0,20)
@@ -54,18 +74,23 @@ func blink(): #troca a cor da bola
5474

5575
func _ready():
5676
ball = get_node("Ball")
77+
roleta = get_node("Roleta")
5778
randomize()
5879
setball()
5980
set_fixed_process(true)
6081
pass
6182

6283

6384
func _fixed_process(delta):
64-
if(set < 0.75):
85+
if(set < 1.35):
6586
set = set + 1*delta
6687
blink();
88+
if(set > 0.75 and parada == 0):
89+
parada = 1
90+
throw()
6791
else:
6892
if(rightcor == 0):
93+
roleta.parada()
6994
if(vetorx < Vector2(0,0)):
7095
ball.sprite(1)
7196
else:

godot/main.tscn

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[gd_scene load_steps=10 format=1]
1+
[gd_scene load_steps=11 format=1]
22

33
[ext_resource path="res://main.gd" type="Script" id=1]
44
[ext_resource path="res://barraAzul.tscn" type="PackedScene" id=2]
@@ -7,6 +7,7 @@
77
[ext_resource path="res://soundtrack_repeat.ogg" type="AudioStream" id=5]
88
[ext_resource path="res://SoundtrackRepeat.gd" type="Script" id=6]
99
[ext_resource path="res://soundtrack_intro.ogg" type="AudioStream" id=7]
10+
[ext_resource path="res://Roleta.tscn" type="PackedScene" id=8]
1011

1112
[sub_resource type="RectangleShape2D" id=1]
1213

@@ -96,6 +97,12 @@ stream/paused = false
9697
stream/loop_restart_time = 0.0
9798
stream/buffering_ms = 500
9899

100+
[node name="Roleta" parent="." instance=ExtResource( 8 )]
101+
102+
transform/pos = Vector2( 512.372, 299.098 )
103+
transform/scale = Vector2( 0.32, 0.32 )
104+
z/z = -2
105+
99106
[connection signal="finished" from="Intro" to="Repeat" method="_on_Intro_finished"]
100107

101108

godot/roleta.tex

7.08 KB
Binary file not shown.

roleta.png

14.4 KB
Loading

roleta.psd

116 KB
Binary file not shown.

0 commit comments

Comments
 (0)