Skip to content

Commit b296359

Browse files
committed
tonygame concluso
1 parent 55da7eb commit b296359

File tree

7 files changed

+65
-4
lines changed

7 files changed

+65
-4
lines changed

game02/ape.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import pgzrun
2+
from random import randint
3+
4+
TITLE = "Ape golosa"
5+
WIDTH = 600
6+
HEIGHT = 500
7+
8+
punteggio = 0
9+
game_over = False
10+
11+
ape = Actor("ape")
12+
ape.pos = 100,100
13+
14+
fiore = Actor("fiore")
15+
16+
def draw():
17+
screen.blit("sfondo", (0,0))
18+
fiore.draw()
19+
ape.draw()
20+
screen.draw.text("Punteggio: " + str(punteggio), color="black", topleft=(10,10))
21+
22+
if game_over:
23+
screen.fill("pink")
24+
screen.draw.text("Tempo scaduto! Punteggio finale: " + str(punteggio), midtop=(WIDTH/2,10),
25+
fontsize=40, color="red")
26+
27+
def piazza_fiore():
28+
fiore.x = randint(70, (WIDTH-70))
29+
fiore.y = randint(70, (HEIGHT-70))
30+
31+
def tempo_scaduto():
32+
global game_over
33+
game_over = True
34+
35+
def update():
36+
'''
37+
Funzione speciale PGZ
38+
'''
39+
global punteggio
40+
41+
if keyboard.left:
42+
ape.x = ape.x - 2
43+
if keyboard.right:
44+
ape.x = ape.x + 2
45+
if keyboard.up:
46+
ape.y = ape.y - 2
47+
if keyboard.down:
48+
ape.y = ape.y + 2
49+
50+
fiore_raccolto = ape.colliderect(fiore)
51+
52+
if fiore_raccolto:
53+
punteggio = punteggio + 10
54+
piazza_fiore()
55+
56+
57+
piazza_fiore()
58+
clock.schedule(tempo_scaduto, 10.0)
59+
pgzrun.go()

game02_1/images/sfondo.png

93.5 KB
Loading
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pgzrun
55
from random import randint
66

7-
TITLE = "tony golosa"
7+
TITLE = "tony alla ricerca della musica"
88
WIDTH = 600
99
HEIGHT = 500
1010

@@ -22,7 +22,9 @@ def draw():
2222
screen.blit("sfondo", (0, 0))
2323
nota.draw()
2424
tony.draw()
25-
screen.draw.text("Note imparate: " + str(punteggio), color="black", topleft=(10, 10))
25+
screen.draw.text(
26+
"Note imparate: " + str(punteggio), color="black", topleft=(10, 10)
27+
)
2628

2729
if game_over:
2830
screen.fill("pink")
@@ -63,13 +65,13 @@ def update():
6365
nota_presa = tony.colliderect(nota)
6466

6567
if nota_presa:
66-
punteggio += 10
68+
punteggio += 1
6769
tony.image = "tony2"
6870
sounds.tonyaudio2.play()
6971
piazza_nota()
7072
clock.schedule(torna_concentrato, 1.0)
7173

7274

7375
piazza_nota()
74-
clock.schedule(tempo_scaduto, 10.0)
76+
clock.schedule(tempo_scaduto, 60.0)
7577
pgzrun.go()

0 commit comments

Comments
 (0)