Notes
![]() ![]() Notes - notes.io |
import random
WIDTH = 600
HEIGHT = 450
TITLE = "Viaggio spaziale"
FPS = 30
# Oggetti e variabili
ship = Actor("ship", (300, 400))
space = Actor("space")
enemies = []
planets = [Actor("plan1", (random.randint(0, 600), -100)), Actor("plan2", (random.randint(0, 600), -100)), Actor("plan3", (random.randint(0, 600), -100))]
meteors = []
mode = 'menu'
type1 = Actor("ship1", (100, 200))
type2 = Actor("ship2", (300, 200))
type3 = Actor("ship3", (500, 200))
# Crea la lista di nemici
for i in range(5):
x = random.randint(0, 600)
y = random.randint(-450, -50)
enemy = Actor("enemy", (x, y))
enemy.speed = random.randint(2, 8)
enemies.append(enemy)
# Crea la lista di meteore
for i in range(5):
x = random.randint(0, 600)
y = random.randint(-450, -50)
meteor = Actor("meteor", (x, y))
meteor.speed = random.randint(2, 10)
meteors.append(meteor)
# Disegni
def draw():
# Avvio schermata di menu
if mode == 'menu':
space.draw()
screen.draw.text('Scegli la nave', center = (300, 100), color = "white", fontsize = 36)
type1.draw()
type2.draw()
type3.draw()
# Modalità di gioco
if mode == 'game':
space.draw()
planets[0].draw()
# Disegni meteore
for i in range(len(meteors)):
meteors[i].draw()
ship.draw()
# Disegni nemici
for i in range(len(enemies)):
enemies[i].draw()
# Finestra di game over
elif mode == 'end':
space.draw()
screen.draw.text("GAME OVER!", center = (300, 200), color = "white", fontsize = 36)
# Controlli
def on_mouse_move(pos):
ship.pos = pos
# Aggiungi nuovi nemici alla lista
def new_enemy():
x = random.randint(0, 400)
y = -50
enemy = Actor("enemy", (x, y))
enemy.speed = random.randint(2, 8)
enemies.append(enemy)
# Movimento dei nemici
def enemy_ship():
for i in range(len(enemies)):
if enemies[i].y < 650:
enemies[i].y = enemies[i].y + enemies[i].speed
else:
enemies.pop(i)
new_enemy()
# Movimento dei pianeti
def planet():
if planets[0].y < 550:
planets[0].y = planets[0].y + 1
else:
planets[0].y = -100
planets[0].x = random.randint(0, 600)
first = planets.pop(0)
planets.append(first)
# Movimento delle meteore
def meteorites():
for i in range(len(meteors)):
if meteors[i].y < 450:
meteors[i].y = meteors[i].y + meteors[i].speed
else:
meteors[i].x = random.randint(0, 600)
meteors[i].y = -20
meteors[i].speed = random.randint(2, 10)
# Collisioni
def collisions():
global mode
for i in range(len(enemies)):
if ship.colliderect(enemies[i]):
mode = 'end'
def update(dt):
if mode == 'game':
enemy_ship()
collisions()
planet()
meteorites()
def on_mouse_down(button, pos):
global mode, ship
if mode == 'menu' and type1.collidepoint(pos):
ship.image = "ship1"
mode = 'game'
elif mode == 'menu' and type2.collidepoint(pos):
ship.image = "ship2"
mode = 'game'
elif mode == 'menu' and type3.collidepoint(pos):
ship.image = "ship3"
mode = 'game'
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team