コード例 #1
0
def main():
    world = load_world(WORLD_FILE)

    window = Window(world=world,
                    width=800,
                    height=600,
                    caption='PythonCraft',
                    resizable=True)
    setup()
    pyglet.app.run()
コード例 #2
0
def main(world_size):
    width, height = (world_size, ) * 2
    world = convert_heightmap(generate_heightmap(7487670, width, height),
                              width, height)
    window = Window(world=world,
                    width=800,
                    height=600,
                    caption='PythonCraft',
                    resizable=True)
    setup()
    pyglet.app.run()
コード例 #3
0
def main():

    from homescreen import HomeScreen
    from app import App

    graphics.setup()
    graphics.initFonts()

    homescreen = HomeScreen()
    homescreen.play(graphics.screen)

    app = App(graphics.screen)
    while True:
        app.run(graphics.screen)
        pygame.display.flip()  # call it once to avoid flickering
コード例 #4
0
ファイル: test.py プロジェクト: marcomorucci/alliance-game
def test_sh_player():

    weights = {
        "unit_weight": 1.242,
        "node_weight": -0.4971,
        "occ_weight": 0,
        "occ_new_weight": 0.05953,
        "n_enemies_weight": 0.2306,
        "enemy_occ_nodes_weight": -1.126,
        "enemy_unit_weight": -0.2431,
        "empty_node_weight": -0.7042,
        "attacker_weight": -0.3131,
        "defender_weight": 0.06549,
        "occ_attacker_weight": -0.2173,
        "occ_defender_weight": 0.4239,
        "enemy_occ_attacker_weight": 0.3953,
        "enemy_occ_defender_weight": -0.02868,
    }

    nodes = [
        GameNode(0, [], [1, 2]),
        GameNode(1, [], [0, 2]),
        GameNode(2, [], [0, 1, 3]),
        GameNode(3, [], [2, 4, 5]),
        GameNode(4, [], [3, 5]),
        GameNode(5, [], [3, 4]),
    ]

    players = [
        ShortHorizonPlayer(0, [Unit(0, nodes[0])], [nodes[0]], nodes[0], **weights),
        ShortHorizonPlayer(1, [Unit(1, nodes[1])], [nodes[1]], nodes[1], **weights),
        ShortHorizonPlayer(2, [Unit(2, nodes[4])], [nodes[4]], nodes[4], **weights),
        ShortHorizonPlayer(3, [Unit(3, nodes[5])], [nodes[5]], nodes[5], **weights),
    ]

    nodes[0].add_unit(players[0].units[0])
    nodes[1].add_unit(players[1].units[0])
    nodes[4].add_unit(players[2].units[0])
    nodes[5].add_unit(players[3].units[0])

    graph = GameGraph(nodes)

    game = Game(players, graph)

    game.update_state([], False)

    def next_round(event):
        win = game.play_round()
        if win is None:
            graphics.draw(f, w, l, game.state)
        else:
            graphics.draw_winner(w, win)

    f, w, l = graphics.setup(game.state, next_round)

    graphics.draw(f, w, l, game.state)
    graphics.show()
コード例 #5
0
def test_human_player():

    nodes = [
        GameNode(0, [], [1, 2]),
        GameNode(1, [], [0, 2]),
        GameNode(2, [], [0, 1, 3]),
        GameNode(3, [], [2, 4, 5]),
        GameNode(4, [], [3, 5]),
        GameNode(5, [], [3, 4])
    ]

    players = [
        HumanPlayer(0, [HumanInteractionUnit(0, nodes[0])], [nodes[0]],
                    nodes[0]),
        HumanPlayer(1, [HumanInteractionUnit(1, nodes[1])], [nodes[1]],
                    nodes[1]),
        HumanPlayer(2, [HumanInteractionUnit(2, nodes[4])], [nodes[4]],
                    nodes[4]),
        HumanPlayer(3, [HumanInteractionUnit(3, nodes[5])], [nodes[5]],
                    nodes[5])
    ]

    nodes[0].add_unit(players[0].units[0])
    nodes[1].add_unit(players[1].units[0])
    nodes[4].add_unit(players[2].units[0])
    nodes[5].add_unit(players[3].units[0])

    graph = GameGraph(nodes)

    game = Game(players, graph)

    game.update_state([], False)

    def next_round(event):
        win = game.play_round()
        if win is None:
            graphics.draw(f, w, l, game.state)
        else:
            graphics.draw_winner(w, win)

    f, w, l = graphics.setup(game.state, next_round)

    for p in players:
        p.canvas = w

    graphics.draw(f, w, l, game.state)
    graphics.show()
コード例 #6
0
ファイル: test.py プロジェクト: marcomorucci/alliance-game
def test_human_player():

    nodes = [
        GameNode(0, [], [1, 2]),
        GameNode(1, [], [0, 2]),
        GameNode(2, [], [0, 1, 3]),
        GameNode(3, [], [2, 4, 5]),
        GameNode(4, [], [3, 5]),
        GameNode(5, [], [3, 4]),
    ]

    players = [
        HumanPlayer(0, [HumanInteractionUnit(0, nodes[0])], [nodes[0]], nodes[0]),
        HumanPlayer(1, [HumanInteractionUnit(1, nodes[1])], [nodes[1]], nodes[1]),
        HumanPlayer(2, [HumanInteractionUnit(2, nodes[4])], [nodes[4]], nodes[4]),
        HumanPlayer(3, [HumanInteractionUnit(3, nodes[5])], [nodes[5]], nodes[5]),
    ]

    nodes[0].add_unit(players[0].units[0])
    nodes[1].add_unit(players[1].units[0])
    nodes[4].add_unit(players[2].units[0])
    nodes[5].add_unit(players[3].units[0])

    graph = GameGraph(nodes)

    game = Game(players, graph)

    game.update_state([], False)

    def next_round(event):
        win = game.play_round()
        if win is None:
            graphics.draw(f, w, l, game.state)
        else:
            graphics.draw_winner(w, win)

    f, w, l = graphics.setup(game.state, next_round)

    for p in players:
        p.canvas = w

    graphics.draw(f, w, l, game.state)
    graphics.show()
コード例 #7
0
ファイル: main.py プロジェクト: mhaqcks/ludum-dare-support
import graphics
from level import Level
import agent
from math import floor
import pyglet

import logging
logging.basicConfig(level=loggin.DEBUG)


if __name__ == '__main__':
    import argparse

    graphics.setup()

    pyglet.gl.glClearColor(1, 1, 1, 1)

    level = Invaders()

    graphics.set_level(level)

    parser = argparse.ArgumentParser()
    parser.parse_args()

    graphics.go()

コード例 #8
0
def main(n, m, screen):
    background_image = pygame.image.load('images/background.jpg')
    screen.blit(background_image, (0, 0))
    (n, m) = (m, n) if n > m else (n, m)
    dp = [[0] * (1 << n) for i in range(1 << n)]
    answers = [[0] * (1 << n) for i in range(m)]
    graphics.setup()
    graphics.grid(n, m, screen)
    graphics.signes(screen)

    def wait():
        tj = 1
        while tj:
            for event in pygame.event.get():
                if event.type == pygame.MOUSEBUTTONDOWN:
                    tj = 0
                    break

    pygame.display.update()

    def fillTable(n: int):
        if n == m == 2:
            wait()
        for i in range(1 << n):
            for j in range(1 << n):
                t = True
                for k in range(n - 1):
                    bit1 = i & (1 << k)
                    bit2 = i & (1 << (k + 1))
                    bit3 = j & (1 << k)
                    bit4 = j & (1 << (k + 1))
                    if bit1 and bit2 and bit3 and bit4:
                        t = False
                        graphics.twoProfiles(i, j, screen, k)
                        break
                    if not bit1 and not bit2 and not bit3 and not bit4:
                        t = False
                        graphics.twoProfiles(i, j, screen, k)
                        break
                graphics.illustrate(j, i, t, screen)
                if t: graphics.twoProfiles(i, j, screen)
                pygame.display.update()
                if n == m == 2:
                    wait()
                dp[i][j] = 1 if t else 0

    fillTable(n)
    num = 0
    for i in range(1 << n):
        answers[0][i] = 1
        num += 1
        graphics.writeNumTwo(0, i, answers[0][i], screen, background_image)
        graphics.writeNum(0, num, screen, background_image)
        pygame.display.update()
        if n == m == 2:
            wait()

    for k in range(1, m):
        num = 0
        for i in range(1 << n):
            for j in range(1 << n):
                graphics.drawInGrid(k, i, j, screen, n, m)
                answers[k][i] += dp[i][j] * answers[k - 1][j]
                num += dp[i][j] * answers[k - 1][j]
                graphics.writeNum(k, num, screen, background_image)
                graphics.writeNumTwo(k, i, answers[k][i], screen,
                                     background_image)
                pygame.display.update()

    ans = 0
    for i in range(1 << n):
        ans += answers[m - 1][i]
    print(ans)

    graphics.printAns(screen, ans)
    pygame.display.update()
    if n == m == 2:
        wait()
コード例 #9
0
    from lib.betterLogger import redo_logger_formatting, BetterLogger
    redo_logger_formatting()
    Logger.info("Base: Kivy logger overwritten")
    base_logger: BetterLogger = BetterLogger(name="Base")

    """
    from resources import Resources, setup

    setup()
    Resources.load_all()
    Logger.info("Base: resources setup and loaded")"""

    from lib.saveManager import SaveManager
    SaveManager.setup()
    base_logger.log_info("SaveManager setup")


    import graphics
    graphics.setup()
    base_logger.log_info("Graphics module setup")

    graphics.load_pre_load_kv()
    base_logger.log_info("Pre load kv language loaded")

    base_logger.log_info("Graphics ready too start")

    graphics.start()

    base_logger.log_info("App has finished!")
コード例 #10
0
def test_sh_player():

    weights = {
        "unit_weight": 1.242,
        "node_weight": -0.4971,
        "occ_weight": 0,
        "occ_new_weight": 0.05953,
        "n_enemies_weight": 0.2306,
        "enemy_occ_nodes_weight": -1.126,
        "enemy_unit_weight": -0.2431,
        "empty_node_weight": -0.7042,
        "attacker_weight": -0.3131,
        "defender_weight": 0.06549,
        "occ_attacker_weight": -0.2173,
        "occ_defender_weight": 0.4239,
        "enemy_occ_attacker_weight": 0.3953,
        "enemy_occ_defender_weight": -0.02868
    }

    nodes = [
        GameNode(0, [], [1, 2]),
        GameNode(1, [], [0, 2]),
        GameNode(2, [], [0, 1, 3]),
        GameNode(3, [], [2, 4, 5]),
        GameNode(4, [], [3, 5]),
        GameNode(5, [], [3, 4])
    ]

    players = [
        ShortHorizonPlayer(0, [Unit(0, nodes[0])], [nodes[0]], nodes[0],
                           **weights),
        ShortHorizonPlayer(1, [Unit(1, nodes[1])], [nodes[1]], nodes[1],
                           **weights),
        ShortHorizonPlayer(2, [Unit(2, nodes[4])], [nodes[4]], nodes[4],
                           **weights),
        ShortHorizonPlayer(3, [Unit(3, nodes[5])], [nodes[5]], nodes[5],
                           **weights)
    ]

    nodes[0].add_unit(players[0].units[0])
    nodes[1].add_unit(players[1].units[0])
    nodes[4].add_unit(players[2].units[0])
    nodes[5].add_unit(players[3].units[0])

    graph = GameGraph(nodes)

    game = Game(players, graph)

    game.update_state([], False)

    def next_round(event):
        win = game.play_round()
        if win is None:
            graphics.draw(f, w, l, game.state)
        else:
            graphics.draw_winner(w, win)

    f, w, l = graphics.setup(game.state, next_round)

    graphics.draw(f, w, l, game.state)
    graphics.show()
コード例 #11
0
ファイル: init.py プロジェクト: Olaxan/nebula-example
import entities as ent
import transform as trf
import graphics as gfx
import character as char
import nmath as nm

for i in range(5):
	e = ent.create_entity()
	
	e.register_component("Transform")
	e.register_component("Graphics")
	e.register_component("Character")

	trf.set_world_transform(e, nm.Matrix44.translation(nm.Point(i * -2, 0, i * -2)))
	
	gfx.set_resource_uri(e, "mdl:Units/Unit_Footman.n3")
	gfx.set_tag(e, "Examples")
	gfx.set_visibility_type(e, 0)
	gfx.setup(e)
	
	char.set_skeleton_uri(e, "ske:Units/Unit_Footman.nsk3")
	char.set_animation_uri(e, "ani:Units/Unit_Footman.nax3")
	char.set_tag(e, "Examples")
	char.setup(e)
	char.play(e, 0, 0)
コード例 #12
0
ファイル: main.py プロジェクト: sammyers/PythonCraft
def main():
    world = load_world(WORLD_FILE)

    window = Window(world=world, width=800, height=600, caption='PythonCraft', resizable=True)
    setup()
    pyglet.app.run()
コード例 #13
0
ファイル: main.py プロジェクト: wolfd/TorusCraft
def main(world_size):
    width, height = (world_size,) * 2
    world = convert_heightmap(generate_heightmap(7487670, width, height), width, height)
    window = Window(world=world, width=800, height=600, caption='PythonCraft', resizable=True)
    setup()
    pyglet.app.run()