-
Notifications
You must be signed in to change notification settings - Fork 0
/
input_name_scene.py
39 lines (33 loc) · 1.22 KB
/
input_name_scene.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import pygame
import input_box
import draw_text
import button
import sys
import game_scene
def input_name_scene(screen,font,font_text,mainClock):
running = True
input_name_box = input_box.InputBox(100, 100, 140, 32)
name = "Anonymous"
while running:
screen.fill((255, 255, 255))
draw_text.draw_text('Game by player', font, (0, 0, 0), screen, 70, 20)
draw_text.draw_text('Please enter your name', font_text, (0, 0, 0), screen, 90, 80)
button_start_game = button.Button(100, 300, 200, 50, 70, text='Start !')
button_start_game.draw(screen)
input_name_box.update()
input_name_box.draw(screen)
name = input_name_box.text
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
running = False
input_name_box.handle_event(event)
button_start_game.handle_event(event)
if button_start_game.click:
game_scene.game_start(name, False)
pygame.display.update()
mainClock.tick(25)
return input_name_box.text