0

I tried to make a clone of a game but the rectangle (which is the basic shape that I will need) does not appear. What did I do wrong or is it just pygame going crazy?

code:

# importing modules
import pygame
import sys
import random

# starting pygame
pygame.init()
# making a screen
(width, height) = (500, 500)
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption('Mincraft')
running = True
# fps counter
clock = pygame.time.Clock()
print(clock)
# geting the x button to work
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
            pygame.display.update()
pygame.display.quit()
pygame.quit()
exit()
# colors
white = (255, 255, 255)
blue = (0, 0, 255)
red = (255, 0, 0)
green = (4, 255, 0)

# cube
if running == True:
    pygame.draw.rect(screen, blue, (395, 0, 10, 10)),
    pygame.draw.rect(screen, blue, (395, 10, 10, 10)),
    pygame.draw.rect(screen, blue, (395, 20, 10, 10)),
clock.tick(60)

and also how am I going to make it empty and 3d? I know I am asking for a lot but I believe someone can explain

Wilson
  • 399
  • 2
  • 10

1 Answers1

1

You have to draw the scene in the application loop:

# importing modules
import pygame
import sys
import random

# colors
white = (255, 255, 255)
blue = (0, 0, 255)
red = (255, 0, 0)
green = (4, 255, 0)

# starting pygame
pygame.init()
# making a screen
(width, height) = (500, 500)
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption('Mincraft')
running = True
# fps counter
clock = pygame.time.Clock()
print(clock)
# geting the x button to work
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
            
    pygame.draw.rect(screen, blue, (395, 0, 10, 10))
    pygame.draw.rect(screen, blue, (395, 10, 10, 10))
    pygame.draw.rect(screen, blue, (395, 20, 10, 10))
    pygame.display.update()
    clock.tick(60)

pygame.display.quit()
pygame.quit()
exit()

The typical PyGame application loop has to:

Rabbid76
  • 202,892
  • 27
  • 131
  • 174