@Zeune/

Lets learn Pygame

Pygame

Lets learn Pygame

fork
loading
Files
  • main.py
  • nohup.out
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Adding libraries we're going to use
import pygame
from random import randint

pygame
# Initializing variables to account for the number of balls caught, and total dropped
score = 0
total = 0

# Creates a font to write the score in
#myFont = pygame.font.SysFont('monospace', 50)

# Making dictionaries with settings for everything

display = {
  "width": 800,
  "height": 600
}

paddle = {
  "width": 200,
  "height": 20,
  "x": 300,
  "y": 580,
  "velocity": 10
}

ball = {
  "radius": 15,
  "y": 30,
  "x": randint(0, display["width"]),
  "velocity": 20
}

# Creating a wwindow, and launching our game
win = pygame.display.set_mode((display["width"], display["height"])) #800 x 600

while True:
  pygame.time.delay(100)
  win.fill((255, 255, 255))

  for event in pygame.event.get():
    if event.type == pygame.QUIT:
      break

  keys = pygame.key.get_pressed()

  if keys[pygame.K_LEFT]:
    paddle["x"] -= paddle["velocity"]

  if keys[pygame.K_RIGHT]:
    paddle["x"] += paddle["velocity"]

  pygame.draw.rect(win, (255, 0, 0), (paddle["x"], paddle["y"], paddle["width"], paddle["height"]))
  pygame.display.update()

  pygame.quit()