we have learnt to code with python
This is the python code using pygame zero:
# alien is a sprite,that is, a moving images in a game
# Actor is the name of a Class sprite (Nayara is an example of the class Homo sapiens), this means create an object from a class
# oscarcasas is a name of a image in the folder images
alien = Actor ('oscarcasas')
# topright means to locate the image in the top right corner
alien.topright = 0, 10
# screen sice in pixels
WIDTH = 500
HEIGHT = alien.height + 20
def draw():
screen.clear()
alien.draw()
def update():
alien.left += 2
if alien.left > WIDTH:
alien.right = 0
This is a videotutorial showing how to create a basic game named Alien Fall:
import pgzrun
import random
TITLE = 'Flappy Bird'
WIDTH = 400
HEIGHT = 708
# These constant control the difficulty of the game
GAP = 130
GRAVITY = 0.3
FLAP_STRENGTH = 6.5
SPEED = 3
bird = Actor('bird1', (75, 200))
bird.dead = False
bird.score = 0
bird.vy = 0
#storage.setdefault('highscore', 0)
def reset_pipes():
pipe_gap_y = random.randint(200, HEIGHT -200)
pipe_top.pos = (WIDTH, pipe_gap_y - GAP // 2)
pipe_bottom.pos = (WIDTH, pipe_gap_y + GAP // 2)
pipe_top = Actor('top', anchor=('left', 'bottom'))
pipe_bottom = Actor('bottom', anchor=('left', 'top'))
reset_pipes() # Set initial pipe positions.
def update_pipes():
pipe_top.left -= SPEED
pipe_bottom.left -= SPEED
if pipe_top.right < 0:
reset_pipes()
if not bird.dead:
bird.score += 1
def update_bird():
uy = bird.vy
bird.vy += GRAVITY
bird.y += (uy + bird.vy) / 2
bird.x = 75
if not bird.dead:
if bird.vy < -3:
bird.image = 'bird2'
else:
bird.image = 'bird1'
if bird.colliderect(pipe_top) or bird.colliderect(pipe_bottom):
bird.dead = True
bird.image = 'birddead'
if not 0 < bird.y < 720:
bird.y = 200
bird.dead = False
bird.score = 0
bird.vy = 0
reset_pipes()
def update():
update_pipes()
update_bird()
def on_key_down():
if not bird.dead:
bird.vy = -FLAP_STRENGTH
def draw():
screen.blit('background', (0, 0))
pipe_top.draw()
pipe_bottom.draw()
bird.draw()
pgzrun.go()
This is a videotutorial showing how to create a basic game named Flappy bird:
I am Nayara, in this website you will find my work a school project where our school is participating during the school year 2020-2021. Our Erasmus+ partner schools are from Greece, Italy, Czech Republic and Spain Visit school website here Pompeu Fabra de Martorell.
Some of the project objectives are: