Ejemplo n.º 1
0
def pauseMenu(mc):
    bg = gui.GUI_TEXTURES["black"]
    bg.width = scene.WIDTH
    bg.height = scene.HEIGHT
    bg.blit(0, 0)

    mp = pygame.mouse.get_pos()

    drawInfoLabel(scene,
                  f"Game menu",
                  xx=scene.WIDTH // 2,
                  yy=scene.HEIGHT - scene.HEIGHT // 4,
                  style=[('', '')],
                  size=12,
                  anchor_x='center')

    # Back to Game button
    resumeButton.x = scene.WIDTH // 2 - (resumeButton.button.width // 2)
    resumeButton.y = scene.HEIGHT // 2 - (resumeButton.button.height // 2) - 50
    resumeButton.update(mp, mc)
    #

    # Quit to title button
    quitWorldButton.text = "Quit to title"
    quitWorldButton.x = scene.WIDTH // 2 - (quitButton.button.width // 2)
    quitWorldButton.y = scene.HEIGHT // 2 - (quitButton.button.height // 2)
    quitWorldButton.update(mp, mc)
    #

    pygame.display.flip()
    clock.tick(MAX_FPS)
Ejemplo n.º 2
0
def drawDeathScreen(mc):
    bg = gui.GUI_TEXTURES["red"]
    bg.width = scene.WIDTH
    bg.height = scene.HEIGHT
    bg.blit(0, 0)

    mp = pygame.mouse.get_pos()

    drawInfoLabel(scene,
                  f"You died!",
                  xx=scene.WIDTH // 2,
                  yy=scene.HEIGHT - scene.HEIGHT // 4,
                  style=[('', '')],
                  size=34,
                  anchor_x='center')

    # Back to Game button
    respawnButton.x = scene.WIDTH // 2 - (respawnButton.button.width // 2)
    respawnButton.y = scene.HEIGHT // 2 - (respawnButton.button.height //
                                           2) - 50
    respawnButton.update(mp, mc)
    #

    # Quit to title button
    quitWorldButton.text = "Title screen"
    quitWorldButton.x = scene.WIDTH // 2 - (quitButton.button.width // 2)
    quitWorldButton.y = scene.HEIGHT // 2 - (quitButton.button.height // 2)
    quitWorldButton.update(mp, mc)
    #

    pygame.display.flip()
    clock.tick(MAX_FPS)
Ejemplo n.º 3
0
def quitToMenu():
    global PAUSE, IN_MENU, mainFunction

    tex = gui.GUI_TEXTURES["options_background"]
    tex2 = gui.GUI_TEXTURES["black"]
    for x in range(0, scene.WIDTH, tex.width):
        for y in range(0, scene.HEIGHT, tex.height):
            tex.blit(x, y)
            tex2.blit(x, y)
    drawInfoLabel(scene,
                  "Quitting to main menu",
                  xx=scene.WIDTH // 2,
                  yy=scene.HEIGHT // 2,
                  style=[('', '')],
                  size=12,
                  anchor_x='center')
    pygame.display.flip()
    clock.tick(MAX_FPS)

    PAUSE = True
    IN_MENU = True

    sound.initMusic(False)

    sound.musicPlayer.play()
    sound.musicPlayer.set_volume(sound.volume)

    scene.resetScene()
    scene.initScene()

    player.position = [0, -90, 0]
    player.hp = -1
    player.playerDead = False

    gc.collect()
    mainFunction = drawMainMenu
Ejemplo n.º 4
0
def genWorld(mc):
    global IN_MENU, PAUSE, resizeEvent
    chunkCnt = 220

    tex = gui.GUI_TEXTURES["options_background"]
    tex2 = gui.GUI_TEXTURES["black"]
    for ix in range(0, scene.WIDTH, tex.width):
        for iy in range(0, scene.HEIGHT, tex.height):
            tex.blit(ix, iy)
            tex2.blit(ix, iy)

    scene.genWorld()
    if scene.worldGen.start - len(scene.worldGen.queue) > chunkCnt:
        scene.genTime = 16
        IN_MENU = False
        PAUSE = False

    proc = round(
        (scene.worldGen.start - len(scene.worldGen.queue)) * 100 / chunkCnt)
    drawInfoLabel(scene,
                  "Loading world...",
                  xx=scene.WIDTH // 2,
                  yy=scene.HEIGHT // 2,
                  style=[('', '')],
                  size=12,
                  anchor_x='center')
    drawInfoLabel(scene,
                  f"Generating terrain {proc}%...",
                  xx=scene.WIDTH // 2,
                  yy=scene.HEIGHT // 2 - 39,
                  style=[('', '')],
                  size=12,
                  anchor_x='center')

    pygame.display.flip()
    clock.tick(MAX_FPS)
Ejemplo n.º 5
0
def drawMainMenu(mc):
    global mainMenuRotation, IN_MENU, PAUSE
    glFogfv(GL_FOG_COLOR, (GLfloat * 4)(0.5, 0.7, 1, 1))
    glFogf(GL_FOG_START, 0)
    glFogf(GL_FOG_END, 1000)

    scene.set3d()

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    glLoadIdentity()

    glPushMatrix()
    glRotatef(mainMenuRotation[0], 1, 0, 0)
    glRotatef(mainMenuRotation[1], 0, 1, 0)
    glTranslatef(0, 0, 0)

    scene.draw()
    scene.drawPanorama()

    glPopMatrix()
    scene.set2d()
    mp = pygame.mouse.get_pos()

    tex = gui.GUI_TEXTURES["game_logo"]
    tex.blit(scene.WIDTH // 2 - (tex.width // 2),
             scene.HEIGHT - tex.height - (scene.HEIGHT // 15))

    drawInfoLabel(scene,
                  f"Minecraft {MC_VERSION}",
                  xx=10,
                  yy=10,
                  style=[('', '')],
                  size=12)

    # Singleplayer button
    singleplayerButton.x = scene.WIDTH // 2 - (
        singleplayerButton.button.width // 2)
    singleplayerButton.y = scene.HEIGHT // 2 - (
        singleplayerButton.button.height // 2) - 25
    singleplayerButton.update(mp, mc)
    #

    # Options button
    optionsButton.x = scene.WIDTH // 2 - (optionsButton.button.width // 2)
    optionsButton.y = scene.HEIGHT // 2 - (optionsButton.button.height //
                                           2) + 25
    optionsButton.update(mp, mc)
    #

    # Quit button
    quitButton.x = scene.WIDTH // 2 - (quitButton.button.width // 2)
    quitButton.y = scene.HEIGHT // 2 - (quitButton.button.height // 2) + 75
    quitButton.update(mp, mc)
    #

    # Splash
    glPushMatrix()
    glTranslatef((scene.WIDTH // 2 + (tex.width // 2)) - 90,
                 scene.HEIGHT - tex.height - (scene.HEIGHT // 15) + 15, 0.0)
    glRotatef(20.0, 0.0, 0.0, 1.0)
    var8 = 1.8 - abs(
        math.sin((getElpsTime() % 1000) / 1000.0 * math.pi * 2.0) * 0.1)
    var8 = var8 * 100.0 / ((24 * 12) + 32)
    drawInfoLabel(scene,
                  splash,
                  xx=1,
                  yy=1,
                  style=[('', '')],
                  scale=var8,
                  size=30,
                  anchor_x='center',
                  label_color=(255, 255, 0),
                  shadow_color=(63, 63, 0))
    glPopMatrix()
    #

    pygame.display.flip()
    clock.tick(MAX_FPS)

    if mainMenuRotation[0] < 25:
        mainMenuRotation[2] = False
    if mainMenuRotation[0] > 75:
        mainMenuRotation[2] = True

    if mainMenuRotation[2]:
        mainMenuRotation[0] -= 0.008
    else:
        mainMenuRotation[0] += 0.008
    mainMenuRotation[1] += 0.02
Ejemplo n.º 6
0
            gui.shows["crosshair"][1] = (-100, -100)
        if scene.allowEvents["grabMouse"] and pygame.mouse.get_focused():
            pygame.mouse.set_pos((scene.WIDTH // 2, scene.HEIGHT // 2))
        scene.updateScene()

        player.inventory.draw()
        gui.update()

        if showInfoLabel:
            drawInfoLabel(
                scene, f"Minecraft {MC_VERSION} ({MC_VERSION}/vanilla)\n"
                f"{round(clock.get_fps())} fps\n"
                f"\n"
                f"XYZ: {round(player.x(), 3)} / {round(player.y(), 5)} / {round(player.z(), 3)}\n"
                f"Block: {round(player.x())} / {round(player.y())} / {round(player.z())}\n"
                f"Facing: {player.rotation[1]} / {player.rotation[0]}\n"
                f"Biome: {getBiomeByTemp(scene.worldGen.perlinBiomes(player.x(), player.z()) * 3)}\n"
                f"Looking at: {scene.lookingAt}\n"
                f"Count of chunks: {scene.worldGen.start - len(scene.worldGen.queue)} "
                f"({scene.worldGen.start})",
                shadow=False,
                label_color=(224, 224, 224),
                xx=3)
        pygame.display.flip()
        clock.tick(MAX_FPS)
    elif PAUSE and not IN_MENU:
        scene.allowEvents["movePlayer"] = False
        scene.allowEvents["keyboardAndMouse"] = False
        if scene.allowEvents["showCrosshair"]:
            gui.shows["crosshair"][1] = (scene.WIDTH // 2 - 9,
                                         scene.HEIGHT // 2 - 9)
        else: