Ejemplo n.º 1
0
    def __init__(self, *args, **kwargs):
        print("Init pygame:")
        pygame.init()
        pygame.display.init()

        print("(done)")

        self.rootParent = self
        self.screenSize = SCREEN_SIZE
        self.interiorSize = [
            SCREEN_SIZE[0] * 0.95,
            SCREEN_SIZE[1] * 0.95,
        ]
        self.marginSize = [
            SCREEN_SIZE[0] * 0.025,
            SCREEN_SIZE[1] * 0.025,
        ]

        print('Resolution: {0}x{1}'.format(self.screenSize[0],
                                           self.screenSize[1]))

        # Don't show mouse-pointer:
        self.screen = pygame.display.set_mode(SCREEN_SIZE, pygame.DOUBLEBUF)
        pygame.display.set_caption("Goblins Malditos v2")

        self.clock = pygame.time.Clock()
        self.goblin = goblin.Goblin('data.json')
Ejemplo n.º 2
0
async def test_app_default_config(event_loop):
    cluster = driver.Cluster(event_loop)
    app = goblin.Goblin(cluster)
    assert app.config['scheme'] == 'ws'
    assert app.config['hosts'] == ['localhost']
    assert app.config['port'] == 8182
    assert app.config['ssl_certfile'] == ''
    assert app.config['ssl_keyfile'] == ''
    assert app.config['ssl_password'] == ''
    assert app.config['username'] == ''
    assert app.config['password'] == ''
    assert issubclass(app.config['message_serializer'],
                      driver.GraphSONMessageSerializer)
    await app.close()
Ejemplo n.º 3
0
def add_goblin_2(room, x, y, difficulty):
    gobbo = arcade.Sprite("resources/images/goblin_2.png", .7)
    gobbo.left = x * SPRITE_SIZE + 15
    gobbo.bottom = y * SPRITE_SIZE + 15
    gobbo.Goblin = goblin.Goblin(5, 2, 1, gobbo._get_center_x(),
                                 gobbo._get_center_y())
    gobbo.move = gobbo.Goblin.update
    gobbo.engine = None
    if difficulty <= game.HARD:
        room.hard_enemy_list.append(gobbo)
    if difficulty <= game.MODERATE:
        room.moderate_enemy_list.append(gobbo)
    if difficulty <= game.EASY:
        room.easy_enemy_list.append(gobbo)
Ejemplo n.º 4
0
    def generate_world(self, world_type='Generic'):

        self.maptype = random.choice(['FOREST', 'GRASSLAND', 'VALLEY'])

        if self.maptype == 'FOREST':
            self.game_map = maps.Map(size=[300, 300])
            self.game_map.vegetation.randomize('pareto', 4)
            self.game_map.elevation.randomize('pareto', 5)
            self.game_map.elevation.diffuse(10)
        elif self.maptype == 'GRASSLAND':
            self.game_map = maps.Map(size=[300, 300])
            self.game_map.vegetation.randomize('pareto', 5)
            self.game_map.elevation.randomize('pareto', 5)
            self.game_map.elevation.diffuse(10)
        else:  #VALLEY
            self.game_map = maps.Map(size=[500, 200])
            self.game_map.vegetation.randomize('pareto', 2)
            self.game_map.elevation.randomize('pareto', 5)
            for i in range(0, 15):
                p1 = [random.randint(0, 199), random.randint(20, 480)]
                p2 = [random.randint(0, 199), random.randint(20, 480)]
                p1[0] *= pow(p1[1] / 500., 3)
                p2[0] = 199 - p2[0] * pow(p2[1] / 500., 3)
                print p1, p2
                self.game_map.elevation.data[p1[1], p1[0]] = random.randint(
                    10000, 20000) * p1[1] / 500.
                self.game_map.elevation.data[p2[1], p2[0]] = random.randint(
                    10000, 20000) * p2[1] / 500.
            for i in range(50):
                self.game_map.elevation.diffuse(5)
            self.game_map.elevation.data *= 100 / self.game_map.elevation.data.max(
            )

        treeline = 20
        self.game_map.vegetation.bloom(treeline - self.game_map.elevation.data)

        self.mapscreen = mapgui.MapScreen(name='Home Map')
        globalvars.root.screen_manager.add_widget(self.mapscreen)
        self.mapscreen.ids['mapimg'].process_map(self.game_map)

        for i in range(0, 12):
            g = goblin.Goblin(self.game_map)
            if i == 0: g.wealth = 100
            self.mapscreen.ids['mapimg'].add_widget(g.image())

        globalvars.root.screen_manager.current = self.mapscreen.name
Ejemplo n.º 5
0
def add_goblin_3(room, x, y, difficulty):
    gobbo = arcade.Sprite("resources/images/goblin_3.png", .9)
    gobbo.left = x * SPRITE_SIZE + 15
    gobbo.bottom = y * SPRITE_SIZE + 15
    gobbo.Goblin = goblin.Goblin(15,
                                 5,
                                 2,
                                 gobbo._get_center_x(),
                                 gobbo._get_center_y(),
                                 gobtype=goblin.HOBGOBLIN,
                                 attack_range=60,
                                 movespeed=2)
    gobbo.move = goblin.Goblin.update
    gobbo.engine = None
    if difficulty <= game.HARD:
        room.hard_enemy_list.append(gobbo)
    if difficulty <= game.MODERATE:
        room.moderate_enemy_list.append(gobbo)
    if difficulty <= game.EASY:
        room.easy_enemy_list.append(gobbo)
Ejemplo n.º 6
0
import asyncio
import goblin
from aiogremlin import Cluster

from examples import models
from examples.serializer import message_serializer


def get_hashable_id(val):
    if isinstance(val, dict) and "@type" in val and "@value" in val:
        if val["@type"] == "janusgraph:RelationIdentifier":
            val = val["@value"]["value"]
    return val


loop = asyncio.get_event_loop()

cluster = loop.run_until_complete(
    Cluster.open(loop, message_serializer=message_serializer))

app = goblin.Goblin(cluster, get_hashable_id=get_hashable_id)

app.register_from_module(models)