Esempio n. 1
0
 def __init__(self):
     self.surface = screen
     self.ball = Ball(self, ball_speed)
     self.player_paddle = Paddle(self)
     self.enemy_paddle = ComputerPaddle(self)
     self.player_score = 0
     self.computer_score = 0
     self.player_scoreboard = eztext.Input(maxlength=3, color=(255, 255, 255), prompt=str(self.player_score))
     self.computer_scoreboard = eztext.Input(maxlength=3, color=(255, 255, 255), prompt=str(self.computer_score))
     self.player_scoreboard.x = screen_width/2 - 100
     self.computer_scoreboard.x = screen_width/2 + 100
Esempio n. 2
0
    def setup_text_boxes(self):
        self.block_textbox = eztext.Input(maxlength=15,
                                          color=(255, 0, 0),
                                          prompt='w, h, c: ',
                                          x=WIDTH - WIDTH // 4 + 10,
                                          y=0,
                                          font=pygame.font.Font(None, 30))
        self.sawblock_textbox = eztext.Input(maxlength=5,
                                             color=(255, 0, 0),
                                             prompt='l: ',
                                             x=WIDTH - WIDTH // 4 + 10,
                                             y=70,
                                             font=pygame.font.Font(None, 30))

        self.textboxes = [self.block_textbox, self.sawblock_textbox]
Esempio n. 3
0
def LoopIntro():
    #Almacena el nombre de usuario
    NombreUsuario = eztext.Input(maxlength=13,
                                 color=white,
                                 prompt='Nombre de usuario: ')
    NombreUsuario.set_pos(150, 350)
    Inicio = True
    while Inicio:

        #Refresca los eventos a esta variable
        eventos = pygame.event.get()
        #Variable que verifica si una tecla esta presionada
        presionada = pygame.key.get_pressed()
        #Animacion del background
        AnimacionBackground()
        #Evento para salir del juego o del loop inicial
        for event in eventos:
            if event.type == QUIT:
                pygame.quit()
                sys.exit()
            if presionada[pygame.K_RETURN] and Usuario != "":
                Inicio = False
                return Usuario
    #Dibuja el input, lo actualiza y asigna a la variable 'Usuario'
        gameDisplay.blit(CajaPNG, (125, 330))
        NombreUsuario.draw(gameDisplay)
        NombreUsuario.update(eventos)
        Usuario = NombreUsuario.value
        #Actualiza los dibujos de la pantalla a un determinado FPS
        pygame.display.flip()
        fpsClock.tick(FPS)
Esempio n. 4
0
 def __init__(self, mainMenu, bg, lastInput=""):
     self.score = 0
     self.paused = False
     self.gameOver = False
     self.levelChange = True
     self.asteroids = 1
     self.level = 1
     # create a few sprites / groups
     self.allSprites = pygame.sprite.Group()
     self.lazers = pygame.sprite.Group()
     self.enemies = pygame.sprite.Group()
     self.player = player.Player()
     self.allSprites.add(self.player)
     self.background = bg
     # some overlays
     self.lives = LivesDisplay(self.player.lives)
     self.pauseScreen = TextOverlay("paused", GREY)
     self.gameOverScreen = TextOverlay("game over", RED)
     self.levelChangeOverlay = LevelChangeOverlay(self.level, self)
     self.scoreDisplay = ScoreDisplay(self.score)
     self.input = eztext.Input(x=330,
                               y=320,
                               font=self.scoreDisplay.font,
                               color=WHITE,
                               prompt="name: ")
     self.input.value = lastInput  # save the player's name
     self.mainMenu = mainMenu
     self.audio = audio.Sounds()
Esempio n. 5
0
def input_box(x, y, maxlength, prompt):
    # make text box "surface thing"
    txtbx = eztext.Input(x=x,
                         y=y,
                         maxlength=maxlength,
                         color=(0, 0, 0),
                         prompt=prompt)
    # for the remainder of the time..
    while state == 'EVENT1':
        #clear and redraw screen.
        screen.fill((0, 0, 0))
        redraw_scene()
        #check for keyboard events
        events = pygame.event.get()
        # exit if necessary
        for event in events:
            if event.type == KEYDOWN:
                if pygame.key.get_pressed()[K_ESCAPE]:
                    pygame.quit()
                    sys.exit()

                elif pygame.key.get_pressed()[K_RETURN]:
                    return txtbx.value
        # update text box
        txtbx.update(events)
        txtbx.draw(screen)
        pygame.display.update()
Esempio n. 6
0
 def __init__(self, screen, x, y):
     self.screen = screen
     self.x_logo = x
     self.y_logo = y
     self.x_btn = x-30
     self.y_btn = y+70
     self.font = constants.load_font("LithosPro", 20)
     self.y_t = self.y_btn+10
     d = shelve.open('info')
     try :
         self.user, self.token = d['user'] 
     except:
         self.user, self.token = ('','')
     d.close()
     self.api = gjapi.GameJoltTrophy(self.user, self.token, constants.GAME_ID, constants.PRIVATE_KEY)
     #if self.api.authenticateUser():
         #self.logged = True
         #self.api.openSession()
         #self.btn =  Gj.btnh
         #self.text = self.font.render(self.user, 1, constants.BLACK) 
         #pygame.time.set_timer(27, 35000)            
     #else:
     self.logged = False
     self.btn = Gj.btn
     self.text = self.font.render("Offline", 1, constants.BLACK)
     _thread.start_new_thread(self.login, (self.user, self.token))
     self.opened = False
     options = {'x':150, 'y':200, 'font':self.font, 'color':constants.DLIGHT_BLUE,
                'maxlength':25, 'prompt1':"Username:  "******"Token:  "}
     self.txtbx = eztext.Input(**options)
     self.tip1 = self.font.render("- Tab to switch between text boxes", 1, constants.OFF_WHITE)
     self.tip2 = self.font.render("- Enter to login", 1, constants.OFF_WHITE)
     self.tip3 = self.font.render("- Esc to go back", 1, constants.OFF_WHITE)
Esempio n. 7
0
def net_jn(screen):
    screen.fill((255, 255, 255))
    text = eztext.Input(prompt='connect to: ', x=160, y=230)
    clock = pygame.time.Clock()

    while 1:
        clock.tick(30)

        events = pygame.event.get()
        text.update(events)

        for event in events:
            if event.type == QUIT: return None
            elif event.type == KEYDOWN:
                if event.key == K_ESCAPE: return None
                elif event.key == K_RETURN:
                    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                    talk = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                    listen = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                    sock.connect((text.value, 55594))
                    listen.connect((text.value, 55595))
                    talk.connect((text.value, 55596))
                    return (sock, talk, listen, text.value, 'client')

        screen.fill((255, 255, 255))
        text.draw(screen)
        pygame.display.flip()
 def nameinput(self, x, y):  #Naam input tekenen
     self.txtbx = eztext.Input(x=x,
                               y=y,
                               maxlength=45,
                               color=(255, 0, 0),
                               prompt='Name: ')
     self.txtbx.value = self.name
Esempio n. 9
0
def main():
    # initialize pygame
    pygame.init()
    # create the screen
    screen = pygame.display.set_mode((640, 240))
    # fill the screen w/ white
    screen.fill((255, 255, 255))
    # here is the magic: making the text input
    # create an input with a max length of 45,
    # and a red color and a prompt saying 'type here: '
    txtbx = eztext.Input(maxlength=45, color=(255, 255, 255), prompt='')
    # create the pygame clock
    clock = pygame.time.Clock()
    # main loop!

    while 1:
        # make sure the program is running at 30 fps
        clock.tick(30)

        # events for txtbx
        events = pygame.event.get()
        # process other events
        for event in events:
            # close it x button si pressed
            if event.type == QUIT: return

        # clear the screen
        screen.fill((255, 255, 255))
        # update txtbx
        txtbx.update(events)
        # blit txtbx on the sceen
        txtbx.draw(screen)
        # refresh the display
        pygame.display.flip()
Esempio n. 10
0
def bx(nickname):
    fgh = True
    txtbx = eztext.Input(x=50,
                         y=50,
                         maxlength=10,
                         color=(PAL),
                         prompt='Enter your Nickname: ')
    while fgh:
        # make sure the program is running at 30 fps
        # events for txtbx
        events = pygame.event.get()
        # process other events

        for event in events:

            # close it x button si pressed
            if event.type == QUIT:
                quit()
            if event.type == KEYDOWN and event.key == K_RETURN:
                nickname = txtbx.value
                return nickname
                fgh = False

        # clear the screen
        screen.fill(NAVY_BLUE)
        # update txtbx
        txtbx.update(events)
        # blit txtbx on the sceen
        txtbx.draw(screen)
        # refresh the display
        pygame.display.flip()
Esempio n. 11
0
def load():
    #global line_list, fill_list, triangle_list, circle_list, write_list
    #global symbol_list
    global objects

    textbox = eztext.Input(maxlength=45,
                           color=(255, 0, 0),
                           prompt="Load name: ")
    looping = True
    while looping:
        pygame.draw.rect(screen, WHITE, ((0, 0), (600, 20)))
        events = pygame.event.get()
        for event in events:
            if event.type == pygame.QUIT:
                return
            elif event.type == pygame.KEYDOWN:
                if event.key == pygame.K_ESCAPE:
                    return
                if event.key == pygame.K_RETURN:
                    looping = False
        val = textbox.update(events)
        textbox.draw(screen)
        pygame.display.flip()
    try:
        file = shelve.open(val, 'r')
        objects = file['objects']
        file.close()
    except:
        print "File not found."
Esempio n. 12
0
 def __init__(self, x, y, prompt):
     self.focus = False
     self.x = x
     self.y = y
     self.textbox = eztext.Input(maxlength=5, color=RED, prompt=prompt)
     self.textbox.set_pos(x, y)
     self.outline = pygame.Rect(x, y - 10, 200, 40)
     self.width = 1
Esempio n. 13
0
def passChk(password):
    # initialize pygame
    pygame.init()

    # create the screen
    screen = pygame.display.set_mode((width, height), FULLSCREEN)
    # screen = pygame.display.set_mode((1280,1024))

    # fill the screen black
    screen.fill((255, 255, 255))

    txtbx = eztext.Input(maxlength=40,
                         color=(255, 255, 255),
                         prompt='PASSWORD:',
                         font=pygame.font.Font(None, 62))
    # create the pygame clock

    clock = pygame.time.Clock()
    # main loop!

    while 1:
        # make sure the program is running at 30 fps
        clock.tick(15)
        txtbx.set_pos(width / 2.0, height / 2.0)

        # events for txtbx
        events = pygame.event.get()

        # process other events
        for event in events:
            # close it x button si pressed
            if event.type == QUIT: return
            if event.type == KEYDOWN:
                if event.key == K_F10:
                    pygame.display.set_mode((width, height), FULLSCREEN)
                elif event.key == K_F11:
                    pygame.display.set_mode((width, height))

        # clear the screen
        screen.fill((0, 0, 0))

        # update txtbx
        txtbx.update(events)

        # check password input
        if txtbx.chk_value(password):
            print "correct"
            return True
        else:
            print "something wrong"

        # blit txtbx on the sceen
        txtbx.draw(screen)

        # refresh the display
        pygame.display.flip()
Esempio n. 14
0
def gameOver():  # game over screen
    global screen, score
    for i, highscore in enumerate(
            highscores
    ):  # checking if there is a new highscore and adding to highscores
        if score > int(highscore[1]):
            txtbx = eztext.Input(x=150,
                                 y=240,
                                 maxlength=45,
                                 color=(255, 255, 255),
                                 prompt='Your name: ')
            input_done = False
            name = ''
            while not input_done:
                events = pygame.event.get()
                for event in events:
                    if event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN:
                        name = txtbx.value
                        input_done = True
                        print(name)
                txtbx.update(events)
                screen.fill(black)
                blit_text(
                    screen,
                    'NEW HIGHSCORE!',
                    (320, 180),
                    font_name='sans serif',
                    size=50,
                    color=gold,
                )
                txtbx.draw(screen)
                pygame.display.flip()
            highscores.insert(i, tuple([name, str(score)]))
            highscores.pop()
            clock.tick(60)
            break
    # now blitting and drawing everything after getting input
    screen.fill(black)
    blit_text(screen,
              'GAME OVER', (320, 200),
              font_name='sans serif',
              size=72,
              color=white)
    showScore(1)
    pygame.display.flip()
    write_highscores(highscore_file)
    sleep(2)  # wait for 2 secs
    pygame.quit()  #pygame exit
    sys.exit()  #console exit
Esempio n. 15
0
def textInput(screen, maxLength, prompt):
    # fill the screen w/ black
    screen.fill(black)
    ypos = 0
    deltay = 25
    txtbx = []
    # For getting the return values
    a = ['']
    # here is the magic: making the text input
    # create an input with a max length of 45,
    # and a red color and a prompt saying 'type here $i: '
    txtbx.append(eztext.Input(maxlength=maxLength,
                              color=blue, y=ypos,
                              prompt=prompt))
    ypos += deltay

    # create the pygame clock
    clock = pygame.time.Clock()
    # main loop!

    while True:
        # make sure the program is running at 30 fps
        clock.tick(30)

        # events for txtbx
        events = pygame.event.get()
        # process other events
        for event in events:
            # close it x button si pressed
            if event.type == QUIT:
                return "None"

        # clear the screen
        screen.fill(white)  # I like black better :)
        # update txtbx and get return val
        a[0] = txtbx[0].update(events)
        txtbx[0].focus = True
        txtbx[0].color = black

        # blit txtbx[i] on the screen
        txtbx[0].draw(screen)

        # Changing the focus to the next element
        # every time enter is pressed
        if a[0] != None:
            return a[0]

        # refresh the display
        pygame.display.flip()
Esempio n. 16
0
def main():
    # initialize pygame
    pygame.init()
    # create the screen
    screen = pygame.display.set_mode((930, 580))
    # fill the screen w/ white
    screen.fill(BLACK)
    # here is the magic: making the text input
    # create an input with a max length of 45,
    # and a red color and a prompt saying 'type here: '
    txtbx = eztext.Input(maxlength=45,
                         color=(255, 0, 0),
                         prompt='Naam speler één:   ',
                         x=100,
                         y=260)
    # create the pygame clock
    clock = pygame.time.Clock()
    # main loop!

    players = []

    while 1:
        # make sure the program is running at 30 fps
        clock.tick(30)
        # events for txtbx
        events = pygame.event.get()
        # process other events
        if len(players) == 2:
            players.append("Game")
            return players
        for event in events:
            # close it x button is pressed
            if event.type == QUIT: return
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_RETURN:
                    players.append(txtbx.value)
                    txtbx.color = (0, 0, 255)
                    txtbx.prompt = 'Naam speler twee:   '
                    txtbx.value = ''

        # clear the screen
        screen.fill((0, 0, 0))
        # update txtbx
        txtbx.update(events)
        # blit txtbx on the sceen
        txtbx.draw(screen)
        # refresh the display
        pygame.display.flip()
def askForValue(text):
	finished = 0
	txtbx = eztext.Input(maxlength=50, color=(0, 255, 0), prompt=text)
	while not finished:
		# update txtbx
		clock.tick(60)
		events = pygame.event.get()
		val = txtbx.update(events)
		if val != None:
			finished = 1
		# blit txtbx on the sceen
		txtbx.draw(gameDisplay)
		pygame.display.flip()
		render()
	
	return val
Esempio n. 18
0
    def game_over_screen(self, screen):
        self.planet_scroll = -300
        planet_size = loader.PLANET_IMAGE.get_size()
        screen.blit(loader.PLANET_IMAGE,
                    (SCREEN_CENTER[0] - planet_size[0] // 2,
                     SCREEN_CENTER[1] - planet_size[1] // 2))

        #check lowest high score against current score
        if self.score > int(loader.highscore[len(loader.highscore) -
                                             1][1]) and not self.score_changed:
            loader.highscore[len(loader.highscore) - 1][0] = "NEWSCORE"
            loader.highscore[len(loader.highscore) - 1][1] = str(self.score)

            #sort the new scores(in place)
            loader.highscore.sort(key=lambda x: int(x[1]), reverse=True)
            for counter, score in enumerate(loader.highscore):
                if score[0] == "NEWSCORE":
                    self.score_changed = counter + 1
                    #create textbox for users name
                    self.txtbx = eztext.Input(maxlength=10,
                                              color=(255, 0, 0),
                                              prompt='Name: ',
                                              value=self.score_name,
                                              x=SCREEN_CENTER[0],
                                              y=SCREEN_CENTER[1])

        if self.score_changed:
            loader.highscore[self.score_changed - 1][0] = str(self.score_name)
            #pass

        font = pygame.font.Font("fonts/OverdriveInline.ttf", 30)
        text_list = ['HighScores']
        for score in loader.highscore:
            text_list.append("{:10}{:3}{:10}".format(score[0], ' - ',
                                                     int(score[1])))
        step_value = 50
        y = len(text_list) * -step_value // 2
        for counter, each in enumerate(text_list):
            if counter == self.score_changed and counter != 0:
                color = RED
            else:
                color = WHITE

            text = font.render(each, True, color)
            text_rect = text.get_rect(center=SCREEN_CENTER)
            screen.blit(text, (text_rect.x, text_rect.y + y))
            y += step_value
Esempio n. 19
0
def start_menu(buttons):
    global game_state, name_entered, txtbx, clicked_mouse_2, score
    start, settings, high_score = buttons
    pos = pygame.mouse.get_pos()
    if start.collidepoint(pos):
        game_state = 1
        name_entered = False
        clicked_mouse_2 = False
        txtbx = eztext.Input(maxlength=20,
                             color=(100, 160, 130),
                             prompt='Player Name')
        new_game()
        score = 0
    if settings.collidepoint(pos):
        game_state = 4
    if high_score.collidepoint(pos):
        game_state = 5
Esempio n. 20
0
def Niveles():

    InputDificultad = eztext.Input(maxlength=1, color=white, prompt='')
    InputDificultad.set_pos(407, 422)
    pygame.display.set_caption('USB\'s Solitaire Chess - ' + Usuario)

    MenuNiveles = True
    while MenuNiveles:

        #Refresca los eventos a esta variable
        eventos = pygame.event.get()
        #Variable que verifica si una tecla esta presionada
        presionada = pygame.key.get_pressed()

        AnimacionBackground()

        #CAMBIAR LAS IMAGENES
        #Cargamos las imagenes con las opciones de los diferentes niveles del juego
        gameDisplay.blit(Dificultad, (180, 125))
        InputDificultad.draw(gameDisplay)
        InputDificultad.update(eventos)
        Nivel = InputDificultad.value  #Guardamos el valor del inputDificultad en la variable Nivel..

        #Evento para salir hacia el menu Principal o para cargar el juego en su respectivo nivel
        for event in eventos:

            if event.type == pygame.locals.QUIT:
                pygame.quit()
                sys.exit()
            if presionada[pygame.K_RETURN] and Nivel == "0":
                return
            if presionada[pygame.K_RETURN] and Nivel == "1":
                MenuDesafio(Nivel)

            if presionada[pygame.K_RETURN] and Nivel == "2":
                MenuDesafio(Nivel)

            if presionada[pygame.K_RETURN] and Nivel == "3":
                pass

            if presionada[pygame.K_RETURN] and Nivel == "4":
                pass

        pygame.display.update()
        fpsClock.tick(FPS)
Esempio n. 21
0
	def passChk(self, password):
	   
		pygame.init() #initialize pygame
		#screen = pygame.display.set_mode((self.width,self.height), FULLSCREEN) #create the screen
		screen = pygame.display.set_mode((WIDTH, HEIGHT), FULLSCREEN) #create the screen
		pygame.mouse.set_visible(False)

		screen.fill((0,0,0)) # fill the screen black

		text = eztext.Input(maxlength=20, color=(255,255,255), prompt='PASSWORD:', font = pygame.font.Font(None, 62))
		clock = pygame.time.Clock() #create the pygame clock

		while True:
			clock.tick(15) # make sure the program is running at 15 fps
			text.set_pos(WIDTH/2.0, HEIGHT/2.0)

			# events for text
			events = pygame.event.get()

			# process other events
			for event in events:
				mods = pygame.key.get_mods()
				if event.type == QUIT: return
				if event.type == KEYDOWN:
					if event.key == K_F10 and mods & pygame.KMOD_RSHIFT and mods & pygame.KMOD_CTRL:
						quit()

			screen.fill((0,0,0)) #clear the screen
			text.update(events) #update text

			# check password input
			if text.chk_value(password):
				print "correct"
				return True
			else:
				print "something wrong"

			text.draw(screen) #blit text on screen
			pygame.display.flip() #refresh display
Esempio n. 22
0
def main():
    global DISPLAYSURF, CLOCK
    pygame.init()
    pygame.display.set_icon(pygame.image.load('icon.icns'))
    DISPLAYSURF = pygame.display.set_mode((gbv.WINWIDTH, gbv.WINHEIGHT))
    pygame.display.set_caption('PikaBall X Connect')
    CLOCK = pygame.time.Clock()
    FONT = pygame.font.Font(None, 140)

    buttonGroup = []
    buttonGroup.append(pygame.sprite.Group())
    buttonGroup.append(pygame.sprite.Group())
    buttonGroup.append(pygame.sprite.Group())

    # the last argument is the option{i}.bmp, can see from the folder
    for i in range(1, 3):
        button = MenuButton(pygame.Rect(460, 100 + 200 * i, 300, 150), i)
        buttonGroup[0].add(button)

    for i in range(3, 5):
        button = MenuButton(pygame.Rect(460, 100 + 200 * (i - 2), 300, 150), i)
        buttonGroup[1].add(button)

    button = MenuButton(pygame.Rect(390, 600, 225, 112), 5)
    buttonGroup[2].add(button)

    txtImgs = []
    txtImgs.append(FONT.render('PikaBall X Connect', 1, (255, 0, 0)))
    txtImgs.append(FONT.render('Server IP', 1, (255, 204, 34)))
    txtImgs.append(FONT.render('Error!', 1, (244, 102, 220)))

    txtbox = eztext.Input(x=270,
                          y=450,
                          maxlength=15,
                          color=(244, 240, 102),
                          prompt='',
                          font=FONT)

    runGame(buttonGroup, txtImgs, txtbox)
Esempio n. 23
0
def save():
    textbox = eztext.Input(maxlength=45,
                           color=(255, 0, 0),
                           prompt="Save name: ")
    looping = True
    while looping:
        pygame.draw.rect(screen, WHITE, ((0, 0), (600, 20)))
        events = pygame.event.get()
        for event in events:
            if event.type == pygame.QUIT:
                return
            elif event.type == pygame.KEYDOWN:
                if event.key == pygame.K_ESCAPE:
                    return
                if event.key == pygame.K_RETURN:
                    looping = False
        val = textbox.update(events)
        textbox.draw(screen)
        pygame.display.flip()
    file = shelve.open(val, 'n')
    file['objects'] = objects
    file.close()
Esempio n. 24
0
def MenuDesafio(Nivel):

    #Muesta el nombre del usuario que esta jugando en la ventana
    pygame.display.set_caption('USB\'s Solitaire Chess - ' + Usuario)

    InputCargado = eztext.Input(maxlength=1, color=white, prompt='')
    InputCargado.set_pos(495, 263)

    while True:
        #Refresca los eventos a esta variable
        eventos = pygame.event.get()

        #Variable que verifica si una tecla esta presionada
        presionada = pygame.key.get_pressed()

        #Animacion del background
        AnimacionBackground()

        for event in eventos:

            if event.type == pygame.locals.QUIT:
                pygame.quit()
                sys.exit()

            if presionada[pygame.K_RETURN] and Opcion_Teclado_Desafio == "1":
                #Llamamos la funcion que contiene la ventana del input para el usuario cree su tablero
                Configuracion_por_teclado(Nivel)

        gameDisplay.blit(CargadoTablero, (198, 90))
        gameDisplay.blit(DesafioTeclado, (90, 350))
        InputCargado.draw(gameDisplay)

        InputCargado.update(eventos)
        Opcion_Teclado_Desafio = InputCargado.value
        pygame.display.update()
        fpsClock.tick(FPS)
Esempio n. 25
0
def game_loop():
    crashed = False

    while crashed == False:
        events = pygame.event.get()

        for event in events:
            # window exiting
            if event.type == pygame.QUIT:
                pygame.quit()
                quit()
        # word display
            if event.type == pygame.KEYDOWN:
                #show_input(events)
                if (event.key == pygame.K_RETURN):
                    print("success")
                    print(event.key)

                    pygame.draw.rect(window, white, ((100, 735), (250, 30)))
                    pygame.display.update()
                    textbox1 = eztext.Input(maxlength=70,
                                            color=(black),
                                            prompt='')
                    #show_input_more(events,textbox1)
                    pygame.display.update()

                    time.sleep(0.5)
                    continue
                #else:
                #    show_input(events)
        # update window
        show_input(events)
        pygame.display.update()

        # fps
        clock.tick(200)
Esempio n. 26
0
click = 0

# 2 - Initialize the game
pygame.init()

# 3 - Load images
#player = pygame.image.load("/resources/images/dude.png")
plano_de_fundo, plano_de_fundo_Rect = carrega_imagem("table_background.jpg", 0)

botaoComecaJogo = BotaoComecaJogo()
posicao_mouse_x, posicao_mouse_y = 0, 0

txtbx = eztext.Input(x=250,
                     y=350,
                     maxlength=45,
                     color=(0, 0, 0),
                     prompt='Digite seu nome:  ')

botoes = pygame.sprite.Group(botaoComecaJogo)
# 4 - keep looping through

pygame.display.set_caption('Burro ou Mico Preto')

thread_estabele_conexao_servidor_aberta = False
servidor_conectado = False
s_servidor_contectado = BoundedSemaphore()


def estabelece_conexao_servidor(nome_jogador):
    global s_servidor_contectado, servidor_conectado, mensagem_erro
def main():
    # initialize pygame
    pygame.init()
    # create the screen
    screen = pygame.display.set_mode((640, 240))
    # fill the screen w/ black
    screen.fill(black)
    ypos = 0
    deltay = 25
    txtbx = []
    elemNumber = 3
    #For getting the return values
    a = ['' for i in range(elemNumber)]
    b = ['default' for i in range(elemNumber)]
    # here is the magic: making the text input
    # create an input with a max length of 45,
    # and a red color and a prompt saying 'type here $i: '
    for i in range(elemNumber):
        txtbx.append(
            eztext.Input(maxlength=6,
                         color=blue,
                         y=ypos,
                         prompt='type here ' + str(i) + ': '))
        ypos += deltay

    foci = 0  #The focus index
    txtbx[foci].focus = True
    txtbx[foci].color = red

    # create the pygame clock
    clock = pygame.time.Clock()
    # main loop!

    while True:
        # make sure the program is running at 30 fps
        clock.tick(30)

        # events for txtbx
        events = pygame.event.get()
        # process other events
        for event in events:
            # close it x button si pressed
            if event.type == QUIT: return

        # clear the screen
        screen.fill(black)  #I like black better :)
        for i in range(elemNumber):
            # update txtbx and get return val
            a[i] = txtbx[i].update(events)
            if i == foci:
                txtbx[i].focus = True
                txtbx[i].color = red
            else:
                txtbx[i].focus = False
                txtbx[i].color = blue

            # blit txtbx[i] on the screen
            txtbx[i].draw(screen)

        #Changing the focus to the next element
        #every time enter is pressed
        for i in range(elemNumber):
            if a[i] != None:
                b[i] = a[i]
                if check_float(b[i]):
                    print "Doing simple operation"
                    print "2*b[" + str(i) + "] = ", 2 * float(b[i])
                txtbx[i].focus = False
                txtbx[i].color = blue
                txtbx[(i + 1) % elemNumber].focus = True
                txtbx[(i + 1) % elemNumber].color = red
                foci = (i + 1) % elemNumber

        # refresh the display
        pygame.display.flip()
        return -cam

    #valor inicial para as funções
    x = -12

    select0 = False
    select1 = False
    select10 = False
    select11 = False
    enter = False
    start = False

    pixelFont = pygame.font.SysFont("pixelmix Regular", 40)
    white = (255, 255, 255)
    question = eztextNum.Input(maxlength=20, color=white, prompt='IP: ')
    name = eztext.Input(maxlength=20, color=white, prompt='USERNAME: ')

    ##################################################################################################

    #loop MENU
    while not select0 or not select1:
        gameDisplay.fill((121, 202, 249))
        mouse_pos = pygame.mouse.get_pos()
        click = pygame.mouse.get_pressed()

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
    #            sys.exit()

            if event.type == pygame.MOUSEBUTTONUP:
Esempio n. 29
0
defineBaseButton = button.Button("Define Base", (0, 0), (160, 60),
                                 defineBaseClick, [],
                                 backgroundColor=RED)
defineVarButton = button.Button("Define Var", (0, 0), (160, 60),
                                defineVarClick, [],
                                backgroundColor=GREEN)
loadImageButton = button.Button("Load Image", (0, 0), (160, 60),
                                loadImageClick, [],
                                backgroundColor=(20, 70, 220))
stupidRulesButton = button.Button("Overlay", (0, 0), (160, 60),
                                  toggleStupidRules, [],
                                  backgroundColor=(162, 158, 20))

lengthInput = eztext.Input(max_length=10,
                           font=font,
                           input_width=140,
                           default_text="length",
                           restricted="0123456789.")
lengthOutput = eztext.Input(max_length=10, font=font, input_width=140)
lengthOutput.lock()
angleOutput = eztext.Input(max_length=10,
                           font=font,
                           input_width=140,
                           default_text="angle")
angleOutput.lock()
imgNum = eztext.Input(max_length=10,
                      font=font,
                      input_width=140,
                      default_text="image num",
                      restricted="0123456789")
baseOutput = eztext.Input(max_length=10,
Esempio n. 30
0
size = 1024

idnum = None

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
s.send('hello')
data = s.recv(size)
s.close()
idnum = int(data)

gridX = 1
gridY = 1
move_tick = 3

txtbx = eztext.Input(maxlength=45, color=(255, 0, 0), prompt='>', x=0, y=400)
#false
txtOn = 0

while True:

    if gridX >= (reqX + 8) - 2:
        if reqX + 8 <= mapsize - 2:
            gridX = gridX - 1
            reqX = reqX + 1
            newReq = True
    if gridX <= (reqX) + 2:
        if reqX >= 1:
            gridX = gridX + 1
            reqX = reqX - 1
            newReq = True