audio.beep
Plays notes from text. Put it where something happens in update(), once, not in draw(). Try "duration 100 C E G" or "saw C2".
audio.beep("C E G")Games with microStudio · In any playground, open Reference to copy these.
Plays notes from text. Put it where something happens in update(), once, not in draw(). Try "duration 100 C E G" or "saw C2".
audio.beep("C E G")In update(), tell every object to move; in draw(), tell every object to draw. The loop stays short however many there are.
for star in stars:
star.move()A whole number picked at random from the first to the second, both included. import random goes at the top of the game.
import random
random.randint(-90, 90)True when this object is close to (x, y) in both directions: abs() is the distance, whichever side it is on.
def touches(self, x, y):
return abs(self.x - x) < 12 and abs(self.y - y) < 8Each object keeps its own x and y in self, moves itself and draws itself.
class Star:
def __init__(self, x):
self.x = x
self.y = 100
def move(self):
self.y -= 1
def draw(self):
screen.fillRound(self.x, self.y, 8, 8, "yellow")class Star:
def __init__(self, x):
self.x = x
self.y = 60
def draw(self):
screen.fillRound(self.x, self.y, 10, 10, "rgb(255,210,0)")
stars = []
for i in range(4):
stars.append(Star(-60 + i * 40))
def draw():
screen.clear("rgb(10,10,40)")
for star in stars:
star.draw()