Example #1
0
def main():
    scr_width = int(input('SCREEN_WIDTH: '))
    scr_height = int(input('SCREEN_HEIGHT: '))

    new_game = game.Game(scr_width, scr_height)
    new_game.run()

    print('Thanks for playing! ;)')
Example #2
0
#! /usr/bin/env python

from core import game

G = game.Game(True)
G.play()


Example #3
0
while game_is_running:
    menu_result = menu.Menu(
        screen, music_list[MENU_MUSIC], new_scene, menu_bounds,
        ('Trouble in Cloudland', 80, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 4),
        main_menu_dictionary).show()

    if menu_result == START_GAME:
        last_highlighted = settings_list[WORLD_UNLOCKED]
        world_result = menu.Menu(
            screen, music_list[MENU_MUSIC], new_scene, menu_bounds,
            ('Choose a World', 96, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 4),
            world_menu_dictionary, last_highlighted).show()

        if world_result == TUTORIAL:
            game.Game(screen, 0, music_list).run()

        elif world_result == EXIT_OPTIONS:
            world_result = False

        elif world_result is not False:
            utility.fade_music()
            utility.play_music(music_list[world_result - 1], True)
            game.Game(screen, world_result - 1, music_list).run()

    elif menu_result == OPTION_MENU:
        option_result = True
        last_highlighted = 0
        while option_result:
            option_result = menu.Menu(
                screen, music_list[MENU_MUSIC], new_scene, menu_bounds,
Example #4
0
#! /usr/bin/env python

from core import game

game = game.Game()
game.play()

Example #5
0
def main():
    game = g.Game(4)

    pygame.init()

    pygame.display.set_caption("2048")

    screen = pygame.display.set_mode((500, 550))
    screen.fill((127, 102, 102))

    game_font = pygame.font.SysFont("Terminal", 40)

    running = True

    while running:
        for row in range(game.width):
            for col in range(game.width):
                pygame.draw.rect(
                    screen, CELL_COLOR[game.get_field()[row][col]],
                    ((BORDER_WIDTH + (col * (BORDER_WIDTH + CELL_WIDTH))),
                     (BORDER_WIDTH + (row * (BORDER_WIDTH + CELL_WIDTH))),
                     CELL_WIDTH, CELL_WIDTH))

                if game.get_field()[row][col] != game.EMPTY_CELL:
                    text = game_font.render(str(game.get_field()[row][col]),
                                            True, FONT_COLOR)
                    text_rect = text.get_rect(
                        center=((BORDER_WIDTH +
                                 (col * (BORDER_WIDTH + CELL_WIDTH))) +
                                (CELL_WIDTH / 2),
                                (BORDER_WIDTH +
                                 (row * (BORDER_WIDTH + CELL_WIDTH))) +
                                (CELL_WIDTH / 2)))
                    screen.blit(text, text_rect)

        pygame.draw.rect(screen, BOARD, (0, 500, 500, 50))

        text_score = game_font.render("Score : " + str(game.get_score()), True,
                                      FONT_COLOR)
        screen.blit(text_score, text_score.get_rect(center=(250, 525)))

        pygame.display.update()

        if not game.has_moves():
            text_game_over = game_font.render("GAME OVER", True, GAME_OVER)
            screen.blit(text_game_over,
                        text_game_over.get_rect(center=(250, 250)))

            running = False

        for event in pygame.event.get():

            if event.type == pygame.QUIT:
                running = False

            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_DOWN:
                    game.move_down()
                elif event.key == pygame.K_LEFT:
                    game.move_left()
                elif event.key == pygame.K_RIGHT:
                    game.move_right()
                elif event.key == pygame.K_UP:
                    game.move_up()

        time.sleep(0.02)
Example #6
0
#! /usr/bin/env python

from core import game

G = game.Game(False)
G.play()


Example #7
0
from core import board, ui, validate, placement, ai, game

if __name__ == "__main__":
    comp_board = board.Board()
    human_board = board.Board()
    ui = ui.TerminalUi()
    validate = validate.Validate()
    place = placement.Place()
    ai = ai.Ai(validate)
    game = game.Game(comp_board, human_board, ai, ui, validate, place)
    game.play()
Example #8
0
def main():
		G = game.Game()
		G.play()