Forklift image #2
73
main.py
73
main.py
@ -3,36 +3,55 @@ import sys
|
|||||||
|
|
||||||
pygame.init()
|
pygame.init()
|
||||||
screen = pygame.display.set_mode((1280, 720))
|
screen = pygame.display.set_mode((1280, 720))
|
||||||
wozek = pygame.Rect(55,55,50,50)
|
|
||||||
c = (0, 150, 0)
|
c = (0, 150, 0)
|
||||||
|
|
||||||
while True:
|
class Wozek:
|
||||||
for event in pygame.event.get():
|
def __init__(self):
|
||||||
if event.type == pygame.QUIT:
|
self.x = 55
|
||||||
sys.exit(0)
|
self.y = 55
|
||||||
elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
|
self.height = 64
|
||||||
sys.exit(0)
|
self.width = 64
|
||||||
elif event.type == pygame.KEYDOWN and event.key == pygame.K_DOWN:
|
self.image = pygame.image.load("wozek.png")
|
||||||
if wozek.y <= 600:
|
# Credit: Forklift icons created by Smashicons - Flaticon
|
||||||
wozek.y += 80
|
# https://www.flaticon.com/free-icons/forklift
|
||||||
elif event.type == pygame.KEYDOWN and event.key == pygame.K_UP:
|
|
||||||
if wozek.y >= 100:
|
def draw(self):
|
||||||
wozek.y -= 80
|
screen.blit(self.image, (self.x, self.y))
|
||||||
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):
|
def main():
|
||||||
pygame.draw.line(screen, c, (1, x), (1280, x), 2)
|
wozek = Wozek()
|
||||||
pygame.draw.line(screen, c, (x, 1), (x, 720), 2)
|
while True:
|
||||||
pygame.display.update()
|
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
|
||||||
|
|
||||||
|
|
||||||
#Drawing
|
for x in range(0, 1280, 80):
|
||||||
screen.fill((0,0,0)) #removes object trail
|
pygame.draw.line(screen, c, (1, x), (1280, x), 2)
|
||||||
pygame.draw.rect(screen, (0,150,255), wozek) #resolution, color, object
|
pygame.draw.line(screen, c, (x, 1), (x, 720), 2)
|
||||||
pygame.display.flip() #updating frames
|
pygame.display.update()
|
||||||
|
|
||||||
|
|
||||||
|
#Drawing
|
||||||
|
screen.fill((0,0,0)) #removes object trail
|
||||||
|
pygame.display.flip() #updating frames
|
||||||
|
wozek.draw()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user