Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame, random
- #button state variable, order: axes, A(z) B(x) START(enter) SELECT(shift)
- #SELECT and START cannot be held
- global buttons
- buttons = [[0, 0], 0, 0, 0, 0]
- pygame.init()
- pygame.font.init()
- text = pygame.font.Font('PressStart2p.ttf', 8)
- debugmode = 1
- #read config file
- config = open("config.ini")
- cfg_resx = int(config.readline())
- cfg_resy = int(config.readline())
- cfg_res = [cfg_resx, cfg_resy]
- cfg_fscreen = config.readline()
- if cfg_fscreen == 1:
- cfg_fscreen = pygame.FULLSCREEN
- global screen
- screen = pygame.display.set_mode(cfg_res)
- config.close()
- logo = pygame.image.load('titletext.bmp')
- pygame.event.get()
- global output
- output = pygame.Surface([255, 240])
- def update():
- pygame.transform.scale(output, cfg_res, screen)
- pygame.display.flip()
- screen.fill([0, 0, 0])
- for event in pygame.event.get():
- print event
- if event.type == pygame.QUIT:
- state = 0
- elif event.type == pygame.MOUSEMOTION:
- continue
- elif event.type == pygame.KEYDOWN:
- if event.key == pygame.K_UP:
- buttons[0][1] += 1
- elif event.key == pygame.K_DOWN:
- buttons[0][1] -= 1
- elif event.key == pygame.K_RIGHT:
- buttons[0][0] += 1
- elif event.key == pygame.K_LEFT:
- buttons[0][0] -= 1
- elif event.key == pygame.K_z:
- buttons[1] = 1
- elif event.key == pygame.K_x:
- buttons[2] = 1
- elif event.key == pygame.K_RETURN:
- buttons[3] = 1
- elif event.key == pygame.K_RSHIFT:
- buttons[4] = 1
- elif event.type -- pygame.KEYUP:
- if event.key == pygame.K_UP:
- buttons[0][1] -= 1
- elif event.key == pygame.K_DOWN:
- buttons[0][1] += 1
- elif event.key == pygame.K_RIGHT:
- buttons[0][0] -= 1
- elif event.key == pygame.K_LEFT:
- buttons[0][0] += 1
- elif event.key == pygame.K_z:
- buttons[1] = 0
- elif event.key == pygame.K_x:
- buttons[2] = 0
- global state
- state = 1
- while state != 0:
- if state == 1:
- option = 2
- while state == 1: #main menu
- #display logo
- output.blit(logo, [25, 20])
- #display menu text options in correct color
- if option == 2:
- output.blit(text.render('Start', 0, [250, 250, 250]), [100, 100])
- else:
- output.blit(text.render('Start', 0, [200, 200, 200]), [100, 100])
- if option == 3:
- output.blit(text.render('Highscores', 0, [250, 250, 250]), [100, 115])
- else:
- output.blit(text.render('Highscores', 0, [200, 200, 200]), [100, 115])
- if option == 4:
- output.blit(text.render('Quit', 0, [250, 250, 250]), [100, 130])
- else:
- output.blit(text.render('Quit', 0, [200, 200, 200]), [100, 130])
- if buttons[4] == 1:
- option += 1
- buttons[4] = 0
- if option >= 5:
- option = 2
- #change state when "start" is pressed
- if buttons[3] == 1:
- if option == 4:
- state = 0
- else:
- state = option
- update()
- pygame.quit()
- Traceback (most recent call last):
- File "H:GUNFORCEmain.py", line 113, in <module>
- update()
- File "H:GUNFORCEmain.py", line 65, in update
- if event.key == pygame.K_UP:
- AttributeError: event member not defined
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement