import pygame
import sys
import random
from pygame.locals import *
pygame.init()
width = 300
height = 600
win = pygame.display.set_mode((width, height))
pygame.display.set_caption('Caption')
clock = pygame.time.Clock()
fps = 60
player_x = 50
fallSpeed = 4
scroll = 0
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
win.fill((255, 255, 255))
keys = pygame.key.get_pressed()
if keys[K_LEFT]:
player_x -= 5
if player_x < -32:
player_x = 299
if keys[K_RIGHT]:
player_x += 5
if player_x > 300:
player_x = 0
playerRect = pygame.draw.rect(win, (255, 0,0), (player_x, 200, 32, 32))
scroll -= fallSpeed
clock.tick(fps)
pygame.display.update()
0 comments