@ash15khng/

pygame drawing project

Pygame

i meant to make the thing move around NOT redraw itself everytime but ok

fork
loading
Files
  • main.py
  • nohup.out

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.9879365108654123","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"aW1wb3J0IHB5Z2FtZQpweWdhbWUuaW5pdCgpCnNpemUgPSAoODAwLCA2MDApCmJnY29sb3IgPSAoMjU1LCAyNTUsIDI1NSkKCnNjcmVlbiA9IHB5Z2FtZS5kaXNwbGF5LnNldF9tb2RlKHNpemUpCgpzY3JlZW4uZmlsbChiZ2NvbG9yKQoKeCwgeSA9IDAsIDAKCndoaWxlIFRydWU6CiAgICBweWdhbWUudGltZS5kZWxheSgxMDApCgogICAgZm9yIGV2ZW50IGluIHB5Z2FtZS5ldmVudC5nZXQoKToKICAgICAgICBpZiBldmVudC50eXBlID09IHB5Z2FtZS5RVUlUOgogICAgICAgICAgICBicmVhawoKICAgIGtleXMgPSBweWdhbWUua2V5LmdldF9wcmVzc2VkKCkKICAgIGlmIGtleXNbcHlnYW1lLktfTEVGVF06CiAgICAgICAgeCAtPSAxMAogICAgICAgIHByaW50KCJMRUZUIikKICAgIGlmIGtleXNbcHlnYW1lLktfUklHSFRdOgogICAgICAgIHggKz0gMTAKICAgICAgICBwcmludCgiUklHSFQiKQogICAgaWYga2V5c1tweWdhbWUuS19VUF06CiAgICAgICAgeSAtPSAxMAogICAgICAgIHByaW50KCJVUCIpCiAgICBpZiBrZXlzW3B5Z2FtZS5LX0RPV05dOgogICAgICAgIHkgKz0gMTAKICAgICAgICBwcmludCgiRE9XTiIpCiAgICBpZiB4IDwgMDoKICAgICAgICB4ID0gMAogICAgaWYgeSA8IDA6CiAgICAgICAgeSA9IDAKICAgIGlmIHggPiBzaXplWzBdOgogICAgICAgIHggPSBzaXplWzBdCiAgICBpZiB5ID4gc2l6ZVsxXToKICAgICAgICB5ID0gc2l6ZVsxXQoKICAgIGlmIGtleXNbcHlnYW1lLktfY106CiAgICAgICAgeCwgeSA9IDAsIDAKICAgICAgICBzY3JlZW4uZmlsbChiZ2NvbG9yKQogICAgICAgIHByaW50KCJDTEVBUiIpCgogICAgcHlnYW1lLmRyYXcucmVjdChzY3JlZW4sICgyNTUsIDAsIDApLCAoeCwgeSwgMTAsIDEwKSkKICAgIHB5Z2FtZS5kaXNwbGF5LmZsaXAoKQo="},"asBuffer":null},"loaded":true}}
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
import pygame
pygame.init()
size = (800, 600)
bgcolor = (255, 255, 255)

screen = pygame.display.set_mode(size)

screen.fill(bgcolor)

x, y = 0, 0

while True:
    pygame.time.delay(100)

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

    keys = pygame.key.get_pressed()
    if keys[pygame.K_LEFT]:
        x -= 10
        print("LEFT")
    if keys[pygame.K_RIGHT]:
        x += 10
        print("RIGHT")
    if keys[pygame.K_UP]:
        y -= 10
        print("UP")
    if keys[pygame.K_DOWN]:
        y += 10
        print("DOWN")
    if x < 0:
        x = 0
    if y < 0:
        y = 0
    if x > size[0]:
        x = size[0]
    if y > size[1]:
        y = size[1]

    if keys[pygame.K_c]:
        x, y = 0, 0
        screen.fill(bgcolor)
        print("CLEAR")

    pygame.draw.rect(screen, (255, 0, 0), (x, y, 10, 10))
    pygame.display.flip()