user3393830
user3393830

Reputation:

Pygame program code issue

I´ve written a programm code in python using pygame and i dont know why it doesn´t work. I want the program to show the menu and i can switch through the Buttons using "w" and "s". But it doesn´t work. Can anyone help me please? I already tried everything.

import pygame
pygame.init()


WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
BLUE = (0, 26, 219)

w = 1280
h = 800
screen = pygame.display.set_mode((w,h),pygame.FULLSCREEN)
clock = pygame.time.Clock()
done = False
marked = 1
while not done:
    start = pygame.font.Font(None, 100)
    option = pygame.font.Font(None, 100)
    help = pygame.font.Font(None, 100)
    end = pygame.font.Font(None, 100)
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_ESCAPE:
                done = True
            if event.key == pygame.K_w:
                marked -= 1
            elif event.key == pygame.K_a:
                marked += 1
    if(marked == 0):
        marked = 1
        start = pygame.font.Font(None, 125)
    if(marked == 1):
        start = pygame.font.Font(None, 125)
    if(marked == 2):
        option = pygame.font.Font(None, 125)
    if(marked == 3):
        help = pygame.font.Font(None, 125)
    if(marked == 4):
        end = pygame.font.Font(None, 125)
    if(marked == 5):
        marked = 4
        end = pygame.font.Font(None, 125)

    starttext = start.render("Start the Game",True,BLACK)
    optiontext = option.render("Options",True,BLACK)
    helptext = help.render("Help",True,BLACK)
    endtext = end.render("End the Game",True,BLACK)

    screen.fill(WHITE)
    screen.blit(starttext, [400,200])
    screen.blit(optiontext, [400,300])
    screen.blit(helptext, [400,400])
    screen.blit(endtext, [400,500])
    pygame.display.flip()
    clock.tick(30)

Thanks for answer!

Upvotes: 0

Views: 74

Answers (1)

Harvey
Harvey

Reputation: 384

Since you haven't really given a great description of what the errors are I'll just try my best to help. I think the reason your code doesn't do what you intend is because you are looking for K_a as opposed to K_s. Change that up and it should be fine :)

Upvotes: 1

Related Questions