PYTHON
Welcome to my website!
This is coin collector game, consist in
This is the modified code:
import pgzrun
import pygame
from random import randint
WIDTH = 1350
HEIGHT = 700
score = 0
game_over = False
background = Actor("bandera")
fox1 = Actor("fox1")
fox1.pos = 100, 100
coin2 =Actor("coin2")
coin2.pos = 1, 1
def draw():
screen.surface = pygame.display.set_mode((WIDTH, HEIGHT), pygame.FULLSCREEN)
screen.blit("bandera", (0, 0))
fox1.draw()
coin2.draw()
screen.draw.text("Score: " + str(score), color="white", topleft=(10, 10))
if game_over:
screen.fill("OrangeRed4")
screen.draw.text("Final Score: "+ str(score), topleft=(10, 10), fontsize=60)
def place_coin():
coin2.x = randint(100, (WIDTH - 100))
coin2.y = randint(100, (HEIGHT - 100))
def time_up():
global game_over
game_over = True
def update():
global score
if keyboard.left:
fox1.x = fox1.x - 12
elif keyboard.right:
fox1.x = fox1.x + 12
elif keyboard.up:
fox1.y = fox1.y - 12
elif keyboard.down:
fox1.y = fox1.y + 12
coin_collected = fox1.colliderect(coin2)
if coin_collected :
score = score +5
place_coin()
clock.schedule(time_up, 30)
place_coin()
pgzrun.go()