From fc494403a2b7ae091b6bbb65df259532e0f73685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zuzanna=20W=C3=B3jcik?= Date: Sat, 11 Mar 2023 00:44:46 +0100 Subject: [PATCH] forklift image --- main.py | 73 ++++++++++++++++++++++++++++++++++-------------------- wozek.png | Bin 0 -> 3077 bytes 2 files changed, 46 insertions(+), 27 deletions(-) create mode 100644 wozek.png diff --git a/main.py b/main.py index 10f1cd9..80b1b49 100644 --- a/main.py +++ b/main.py @@ -3,36 +3,55 @@ import sys pygame.init() screen = pygame.display.set_mode((1280, 720)) -wozek = pygame.Rect(55,55,50,50) c = (0, 150, 0) -while True: - for event in pygame.event.get(): - if event.type == pygame.QUIT: - sys.exit(0) - elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE: - sys.exit(0) - elif event.type == pygame.KEYDOWN and event.key == pygame.K_DOWN: - if wozek.y <= 600: - wozek.y += 80 - elif event.type == pygame.KEYDOWN and event.key == pygame.K_UP: - if wozek.y >= 100: - wozek.y -= 80 - elif event.type == pygame.KEYDOWN and event.key == pygame.K_RIGHT: - if wozek.x <= 1170: - wozek.x += 80 - elif event.type == pygame.KEYDOWN and event.key == pygame.K_LEFT: - if wozek.x >= 100: - wozek.x -= 80 +class Wozek: + def __init__(self): + self.x = 55 + self.y = 55 + self.height = 64 + self.width = 64 + self.image = pygame.image.load("wozek.png") + # Credit: Forklift icons created by Smashicons - Flaticon + # https://www.flaticon.com/free-icons/forklift + + def draw(self): + screen.blit(self.image, (self.x, self.y)) - for x in range(0, 1280, 80): - pygame.draw.line(screen, c, (1, x), (1280, x), 2) - pygame.draw.line(screen, c, (x, 1), (x, 720), 2) - pygame.display.update() +def main(): + wozek = Wozek() + while True: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + sys.exit(0) + elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE: + sys.exit(0) + elif event.type == pygame.KEYDOWN and event.key == pygame.K_DOWN: + if wozek.y <= 600: + wozek.y += 80 + elif event.type == pygame.KEYDOWN and event.key == pygame.K_UP: + if wozek.y >= 100: + wozek.y -= 80 + elif event.type == pygame.KEYDOWN and event.key == pygame.K_RIGHT: + if wozek.x <= 1170: + wozek.x += 80 + elif event.type == pygame.KEYDOWN and event.key == pygame.K_LEFT: + if wozek.x >= 100: + wozek.x -= 80 + + + for x in range(0, 1280, 80): + pygame.draw.line(screen, c, (1, x), (1280, x), 2) + pygame.draw.line(screen, c, (x, 1), (x, 720), 2) + pygame.display.update() - #Drawing - screen.fill((0,0,0)) #removes object trail - pygame.draw.rect(screen, (0,150,255), wozek) #resolution, color, object - pygame.display.flip() #updating frames + #Drawing + screen.fill((0,0,0)) #removes object trail + pygame.display.flip() #updating frames + wozek.draw() + + +if __name__ == "__main__": + main() diff --git a/wozek.png b/wozek.png new file mode 100644 index 0000000000000000000000000000000000000000..8310c9ec46e66edc75cee97aa8795145d10c45d6 GIT binary patch literal 3077 zcmV+g4EpnlP)3<&dT|)`}cnS_}%yKzVGdx*>>Ny zr*>VR>)P-4J$*i}`+NF)zn>qHC`^E^zzINpkl%o>fk%J}m(s(ZLJis9&!(+Org&%KQoB-E%WXLV`UYTvaXs4C>!O_H2AFSzO%vA=yo8SrEPl!pj|i zdUe9ptRboq<|*}Sqr2M`U;c3$di@EsH^qdodn%h6U2Q>F2iVFBfMNa|`;{u9Z$Cu# zOb+M1$EonDR$6>{0T2wt19JgIL_{bq?w==m-DxUXp#lalxCAl;SPLjD1Z`P>^j}in z>SqDi4g{7t05=eC0qWJOmyEN!)@@y2Dq81iPL#M|2m&$zMO}-|XL93DK#$`n({=8gEdRE@(mz@LDozle-gte!o{0ed!R8(B zS^&-gA!P~xs2Ldwy@9Ip=L8u&~R_y*APk04_yX_FqZ+DI((A+Tb_irJ@6pO#K#rk`Dh0s@fD zhT%&u4j2HaZcSug!%zFCn(a8e(Mn}K2P8|94oywlk!=1lq1E`qr;0!|;0&PkpI|77 zW6^c3UT|+&4uO>R?c1M{B>mhk>#J#|Qn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