コード例 #1
0
ファイル: maze.py プロジェクト: KorawitRupanya/Pacman
class MazeWindow(arcade.Window):
    def __init__(self, width, height):
        super().__init__(width, height)

        arcade.set_background_color(arcade.color.BLACK)

        self.world = World(SCREEN_WIDTH, SCREEN_HEIGHT, BLOCK_SIZE)
        self.pacman_sprite = ModelSprite('images/pacman.png',
                                         model=self.world.pacman)

        self.maze_drawer = MazeDrawer(self.world.maze)

    def update(self, delta):
        self.world.update(delta)

    def on_draw(self):
        arcade.start_render()

        self.maze_drawer.draw()
        self.pacman_sprite.draw()

        arcade.draw_text(str(self.world.score), self.width - 60,
                         self.height - 30, arcade.color.WHITE, 20)

    def on_key_press(self, key, key_modifiers):
        self.world.on_key_press(key, key_modifiers)
コード例 #2
0
ファイル: space.py プロジェクト: Nstw/SpaceCraft
class SpaceGameWindow(arcade.Window):
    def __init__(self, width, height):
        super().__init__(width, height)

        arcade.set_background_color(arcade.color.BLACK)

        self.world = World(width, height)
        self.ship_sprite = ModelSprite('images/ship.png',
                                       model=self.world.ship)
        self.gold_sprite = ModelSprite('images/gold.png',
                                       model=self.world.gold)

    def on_draw(self):
        arcade.start_render()
        self.gold_sprite.draw()
        self.ship_sprite.draw()

        arcade.draw_text(str(self.world.score), self.width - 30,
                         self.height - 30, arcade.color.WHITE, 20)

    def update(self, delta):
        self.world.update(delta)
        #--self.ship_sprite.set_position(self.world.ship.x, self.world.ship.y)

    def on_key_press(self, key, key_modifiers):
        self.world.on_key_press(key, key_modifiers)
コード例 #3
0
 def on_mouse_release(self, x, y, button, modifiers):
     if const.GAME_STATE != 1:
         self.world = World()
         self.worldRenderer = WorldRenderer(self.world)
         const.GAME_STATE = 1
     else:
         self.world.on_mouse_release(x, y, button)
コード例 #4
0
ファイル: survive.py プロジェクト: ballsai/SurviveInTheRoom
    def __init__(self, width, height):
        super().__init__(width, height)

        self.world = World(width, height)
        arcade.set_background_color(arcade.color.DARK_SLATE_GRAY)
        self.timer_text = None
        self.background = arcade.load_texture("images/background.png")
        self.intro = arcade.load_texture("images/intro.png")
        self.score_text = None
        self.energy_text = None

        self.wall_1 = ModelSprite("images/wall_01.png",
                                  model=self.world.wall_1)
        self.wall_2 = ModelSprite("images/wall_02.png",
                                  model=self.world.wall_2)
        self.wall_3 = ModelSprite("images/wall_03.png",
                                  model=self.world.wall_3)
        self.wall_4 = ModelSprite("images/wall_04.png",
                                  model=self.world.wall_4)
        self.wall_5 = ModelSprite("images/wall_05.png",
                                  model=self.world.wall_5)
        self.wall_6 = ModelSprite("images/wall_06.png",
                                  model=self.world.wall_6)
        self.wall_7 = ModelSprite("images/wall_09.png",
                                  model=self.world.wall_7)
        self.wall_8 = ModelSprite("images/wall_10.png",
                                  model=self.world.wall_8)
        self.wall_9 = ModelSprite("images/wall_09.png",
                                  model=self.world.wall_9)
        self.wall_10 = ModelSprite("images/wall_10.png",
                                   model=self.world.wall_10)
コード例 #5
0
ファイル: game.py プロジェクト: xorawish/throw-your-knives
    def setup(self):

        arcade.set_background_color(arcade.color.BLACK)

        self.total_time = 0.0
        self.world = World(SCREEN_WIDTH, SCREEN_HEIGHT)
        self.knife_sprite = ModelSprite('images/knife.png',
                                        model=self.world.knife)
        self.knife_sprite2 = ModelSprite('images/knife.png',
                                         model=self.world.knife2)
        self.knife_sprite3 = ModelSprite('images/knife.png',
                                         model=self.world.knife3)
        self.knife_sprite4 = ModelSprite('images/knife.png',
                                         model=self.world.knife4)
        self.knife_sprite5 = ModelSprite('images/knife.png',
                                         model=self.world.knife5)
        self.knife_sprite6 = ModelSprite('images/knife.png',
                                         model=self.world.knife6)
        self.knife_sprite7 = ModelSprite('images/knife.png',
                                         model=self.world.knife7)
        self.knife_sprite8 = ModelSprite('images/knife.png',
                                         model=self.world.knife8)
        self.knife_sprite9 = ModelSprite('images/knife.png',
                                         model=self.world.knife9)
        self.knife_sprite10 = ModelSprite('images/knife.png',
                                          model=self.world.knife10)
        self.target_sprite = ModelSprite('images/target.png',
                                         model=self.world.target)
コード例 #6
0
ファイル: screen.py プロジェクト: KOngTNP/CarParking-Game
    def __init__(self, width, height):
        super().__init__(width, height)
 
        arcade.set_background_color(arcade.color.WHITE)
 
        self.world = World(SCREEN_WIDTH, SCREEN_HEIGHT)
        self.spot_sprite = ModelSprite('pacman.png', model=self.world.spot)
コード例 #7
0
 def setup(self):
     self.world = World(SCREEN_WIDTH, SCREEN_HEIGHT)
     self.coin = arcade.load_texture('pic/coin.png')
     self.skull = arcade.load_texture('pic/skull-model.png')
     self.walk = arcade.load_texture('pic/sandHalf.png')
     self.panda_sprite = self.panda()
     self.backsprite = self.back()
コード例 #8
0
ファイル: space.py プロジェクト: eveem/spacegame_oop
class SpaceGameWindow(arcade.Window):
    def __init__(self, width, height):
        super().__init__(width, height)

        arcade.set_background_color(arcade.color.PINK)

        self.world = World(width, height)
        self.ship_sprite = ModelSprite('images/ship.png',
                                       model=self.world.ship)
        self.gold_sprite = ModelSprite('images/gold.png',
                                       model=self.world.gold)

        self.asteroid_sprites = []
        for asteroid in self.world.asteroids:
            self.asteroid_sprites.append(
                ModelSprite('images/ship.png', scale=0.5, model=asteroid))

    def on_draw(self):
        arcade.start_render()
        self.ship_sprite.draw()
        self.gold_sprite.draw()

        for sprite in self.asteroid_sprites:
            sprite.draw()

        arcade.draw_text(str(self.world.score), self.width - 60,
                         self.height - 60, arcade.color.BLACK, 20)

    def animate(self, delta):
        self.world.animate(delta)

    def on_key_press(self, key, key_modifiers):
        self.world.on_key_press(key, key_modifiers)
コード例 #9
0
 def __init__(self, width, height):
     super().__init__(width, height)
     self.world = World(SCREEN_WIDTH, SCREEN_HEIGHT)
     self.score = 0
     self.wizard_sprite = ModelSprite('images/Wizard.png',
                                      model=self.world.player)
     self.start_game = ModelSprite('images/Start.jpg',
                                   model=self.world.start_game)
     self.end = ModelSprite('images/End.jpg', model=self.world.end)
     self.help_button = False
     self.background = ModelSprite('images/RealBack_1.jpg',
                                   model=self.world.background)
     self.heart = ModelSprite('images/heart.png',
                              model=self.world.heart_life)
     self.another_heart = ModelSprite('images/heart.png',
                                      model=self.world.another_heart)
     self.fire_1 = ModelSprite('images/fire.png', model=self.world.fire_1)
     self.fire_2 = ModelSprite('images/fire.png', model=self.world.fire_2)
     self.fire_3 = ModelSprite('images/fire.png', model=self.world.fire_3)
     self.another_fire = ModelSprite('images/fire.png',
                                     model=self.world.another_fire)
     self.bonus = ModelSprite('images/Bonus.png', model=self.world.bonus)
     self.bonus_1 = ModelSprite('images/Bonus_1.png',
                                model=self.world.bonus_1)
     self.bonus_2 = ModelSprite('images/Bonus_2.png',
                                model=self.world.bonus_2)
     self.zombie = ModelSprite('images/Zombie.png', model=self.world.zombie)
     self.grim = ModelSprite('images/Ghost_1.png', model=self.world.grim)
     self.ghost = ModelSprite('images/Ghost_2.png', model=self.world.ghost)
     self.witch = ModelSprite('images/Witch.png', model=self.world.witch)
     self.TinkerBell = ModelSprite('images/Tinker_Bell.png',
                                   model=self.world.TinkerBell)
     self.Ariel = ModelSprite('images/Royal_3.png', model=self.world.Ariel)
     self.help = ModelSprite('images/Help.jpg', model=self.world.help)
コード例 #10
0
ファイル: snake_.py プロジェクト: Raksani/snake
class SnakeWindow(arcade.Window):
    def __init__(self, width, height):
        super().__init__(width, height)


        self.world = World(SCREEN_WIDTH, SCREEN_HEIGHT)

        # self.snake_sprite = arcade.Sprite('images/block.png')
        # we use class Model sprite instead for collect image data.
        # self.snake_sprite = ModelSprite('images/block.png',
        #                                 model=self.world.snake)
        # self.snake_sprite.set_position(300, 300)
        self.snake_sprite = SnakeSprite(self.world.snake)
        self.heart_sprite = ModelSprite('images/heart.png',
                                        model=self.world.heart)
        arcade.set_background_color(arcade.color.BLACK)
    # create update for update in world class.
    def update(self, delta):
        self.world.update(delta)


    # draw sprite
    def on_draw(self):
        arcade.start_render()
        self.snake_sprite.draw()
        self.heart_sprite.draw()

    def on_key_press(self, key, key_modifiers):
        self.world.on_key_press(key, key_modifiers)
コード例 #11
0
ファイル: space.py プロジェクト: mameaw14/python-space
    def __init__(self, width, height):
        super().__init__(width, height)

        arcade.set_background_color(arcade.color.BLACK)

        self.world = World(width, height)
        self.ship_sprite = ModelSprite('img/ship.png', model=self.world.ship)
コード例 #12
0
def CreateWorld():
    if 'file' not in request.files:
        return Response('no file found', status=400)
    file = request.files['file']
    if not allowed_file(file.filename):
        return Response('invalid file type', status=400)
    try:
        campaignName = Campaign.query.get(
            request.form['campaign_id']).name.replace(' ', '_')
        newWorld = World(
            request.form['name'] or None,
            f'/mediafiles/campaigns/{campaignName}/{secure_filename(file.filename)}',
            request.form['center_lat'], request.form['center_lng'],
            request.form['radius'], request.form['campaign_id'] or None)
        db.session.add(newWorld)
        db.session.commit()
        os.makedirs(
            f'/usr/src/app/mediafiles/campaigns/{campaignName}/{newWorld.name.replace(" ", "_")}',
            exist_ok=True)
        file.save(f'/usr/src/app{newWorld.image}')
        data = jsonify(newWorld.to_dict())
        data.status_code = 201
        return data
    except (IntegrityError, AttributeError) as error:
        return Response(error.args[0], status=400)
コード例 #13
0
ファイル: Icarus.py プロジェクト: cynic4018/Icarus-Falls
    def start(self):
        self.world = World(SCREEN_WIDTH, SCREEN_HEIGHT)
        self.offset = 0
        self.credit_offset = 0
        self.check_credit = False
        self.arrows = []
        self.fires = []
        self.numArrow = 5
        self.bottomFires = []
        self.background = arcade.load_texture(
            ".././images/Back ground/sky.jpg")

        for i in range(self.numArrow):
            self.arrows.append(ArrowSprite(model=self.world.arrow[i]))
        self.arrow_sprite = self.arrows

        for n in range(self.world.fireNumbers):
            self.fires.append(FireSprite(model=self.world.fire[n]))
        self.fire_sprite = self.fires

        for i in range(10):
            self.bottomFires.append(BottomFire(model=self.world.bottomfire[i]))
        self.bottomfires_sprite = self.bottomFires

        self.player_sprite = PlayerSprite(model=self.world.player)
コード例 #14
0
ファイル: snake.py プロジェクト: narisasingngam/SnakeGame
 def __init__(self, width, height):
     super().__init__(width, height)
     arcade.set_background_color(arcade.color.BLACK)
     self.world = World(SCREEN_WIDTH, SCREEN_HEIGHT)
     self.snake_sprite = SnakeSprite(self.world.snake)
     self.heart_sprite = ModelSprite('images/heart.png',
                                     model=self.world.heart)
コード例 #15
0
    def __init__(self, width, height):
        super().__init__(width, height)

        self.world = World(SCREEN_WIDTH, SCREEN_HEIGHT, BLOCK_SIZE)

        self.world.player.turn = 0
        self.player_right_sprite = ModelSprite('images/Gunner_right.png',
                                               model=self.world.player)
        self.player_left_sprite = ModelSprite('images/Gunner_left.png',
                                              model=self.world.player)
        self.bullet_sprite = BulletSprite()
        self.slime_sprite = SlimeSprite()
        self.kingslime_sprite = KingslimeSprite()
        self.checkpoint_sprite = CheckpointSprite()

        ##        if self.world.currentmap == 0:
        ##            self.background = arcade.Sprite("images/background1.jpg")
        ##        if self.world.currentmap == 1:
        ##            self.background = arcade.Sprite("images/background2.png")
        ##        if self.world.currentmap == 2:
        ##            self.background = arcade.Sprite("images/background3.jpg")
        ##        if self.world.currentmap == 3:
        ##            self.background = arcade.Sprite("images/background4.png")
        ##
        self.stage_drawer = StageDrawer(self.world.stage)
コード例 #16
0
class CheckerGameWindow(arcade.Window):
    def __init__(self, width, height):
        super().__init__(width, height)
        self.world = World()
        self.worldRenderer = WorldRenderer(self.world)
        self.src = [
            "images/start.fw.png", "images/board.fw.png", "images/win.fw.png",
            "images/lose.fw.png"
        ]
        self.texture = []
        for src in self.src:
            self.texture.append(arcade.load_texture(src))

    def on_draw(self):
        arcade.start_render()
        arcade.draw_texture_rectangle(const.SCREEN_WIDTH // 2,
                                      const.SCREEN_HEIGHT // 2,
                                      self.texture[const.GAME_STATE].width,
                                      self.texture[const.GAME_STATE].height,
                                      self.texture[const.GAME_STATE], 0)
        if const.GAME_STATE == 1:
            self.worldRenderer.on_draw()

    def animate(self, delta):
        if const.GAME_STATE == 1:
            self.world.animate(delta)

    def on_mouse_release(self, x, y, button, modifiers):
        if const.GAME_STATE != 1:
            self.world = World()
            self.worldRenderer = WorldRenderer(self.world)
            const.GAME_STATE = 1
        else:
            self.world.on_mouse_release(x, y, button)
コード例 #17
0
def save_world(file_data=None, description=""):
    """
    Save file from form data or download

    :param file_data: The Minecraft world file data to be saved.
                      Either as a urllib2 response or a werkzeug FileStorage object
    :param description: Minecraft world description
    :return: World object
    """
    world = World(user_id=current_user.id)
    # Construct file name with world ID and user ID for reference. End with arbitrary string and zip extension
    # Example: 7_3_mc_world.zip
    file_ref_noext = str(world.id) + '_' + str(current_user.id) + '_' + 'mc_world'
    file_ref = file_ref_noext + '.zip'
    # Full path to save zip. Include filename, but not file extension
    if app.config['ABSOLUTE_WORLD_UPLOAD_PATH']:
        save_path = safe_join_all(app.config['ABSOLUTE_WORLD_UPLOAD_PATH'], file_ref_noext)
    else:
        save_path = safe_join_all(app.root_path, app.config['WORLD_UPLOAD_PATH'], file_ref_noext)
    temp_dir = tempfile.gettempdir()
    # Temporary zip file
    zip_path = safe_join_all(temp_dir, file_ref)
    # Temporary unzip directory
    unzip_path = safe_join_all(temp_dir, file_ref_noext)

    # Check if file_data comes from a form submission
    if isinstance(file_data, FileStorage):
        file_data.save(zip_path)
    else:  # Else assume file_data has read() function
        with open(zip_path, 'wb') as world_zip:
            world_zip.write(file_data.read())

    # Rezip
    #######
    with ZipFile(zip_path, 'r') as world_zip:
        # unzip file
        world_zip.extractall(unzip_path)
    # Locate minecraft world inside unzipped directory
    level_path = search_for_file(unzip_path, 'level.dat')
    # Make zip file
    shutil.make_archive(save_path, 'zip', level_path)

    # Clean up temp files
    try:
        # Remove zip file
        os.remove(zip_path)
    except OSError:
        pass
    try:
        # Remove unzip directory
        shutil.rmtree(unzip_path)
    except OSError:
        pass

    # Save world details to database
    world.file_ref = file_ref
    world.description = description
    world.store()
    return world
コード例 #18
0
class SpaceGameWindow(arcade.Window):
    def __init__(self, width, height):
        super().__init__(width, height)

        arcade.set_background_color(arcade.color.BLACK)

        self.all_sprites_list = arcade.SpriteList()
        self.score = 0
        self.world = World(width, height)

        #self.rocketsp = arcade.Sprite('images/Rocket2.png')
        self.rocketsp = ModelSprite('images/Rocket2.png',
                                    model=self.world.rocket)

        #self.aliensp = arcade.Sprite('images/Alien.png')
        self.aliensp = ModelSprite('images/Alien.png', model=self.world.alien)

        self.all_sprites_list.append(self.rocketsp)
        self.all_sprites_list.append(self.aliensp)
        #self.alien_list = arcade.SpriteList()
        #self.alien_list.append(self.aliensp)
        self.score = 0

    def start_new_game(self):
        for i in range(50):
            aliensp = self.world.alien
            #self.aliensp = arcade.Sprite('images/Alien.png')
            #self.aliensp.set_position(self.world.alien.x, self.world.alien.y)
            aliensp.x = random.randrange(SCREEN_WIDTH)
            aliensp.y = SCREEN_HEIGHT

    def update(self, delta):
        self.world.update(delta)
        #self.rocketsp.set_position(self.world.rocket.x, self.world.rocket.y)

    def on_draw(self):

        arcade.start_render()

        #self.all_sprites_list.draw()

        self.rocketsp.draw()
        self.aliensp.draw()

        #self.rocketsp.set_position(self.world.rocket.x, self.world.rocket.y)
        #self.aliensp.set_position(self.world.alien.x, self.world.alien.y)

        output = "Score: {}".format(self.score)
        arcade.draw_text(output, 10, 600, arcade.color.WHITE, 12)

    def on_key_press(self, key, modifiers):
        if key == arcade.key.LEFT:
            self.world.rocket.delta_x = -MOVEMENT_SPEED
        elif key == arcade.key.RIGHT:
            self.world.rocket.delta_x = MOVEMENT_SPEED

    def on_key_release(self, key, modifiers):
        if key == arcade.key.LEFT or key == arcade.key.RIGHT:
            self.world.rocket.delta_x = 0
コード例 #19
0
    def __init__(self, width, height):
        super().__init__(width, height)

        arcade.set_background_color(arcade.color.GRAY)

        self.world = World(SCREEN_WIDTH, SCREEN_HEIGHT)

        self.dot_sprite = ModelSprite('images/dot.png', model=self.world.dot)
コード例 #20
0
 def __init__(self, width, height):
     super().__init__(width, height, "TaLaLap")
     self.world = World(SCREEN_WIDTH, SCREEN_HEIGHT)
     self.coin_list = self.world.coin_list
     self.plus_dam = arcade.Sprite("images/DoubleDam.png", scale=0.7)
     self.double_dam = arcade.Sprite("images/DoubleDamT.png", scale=0.7)
     self.plus_dam.set_position(SCREEN_WIDTH - 40, SCREEN_HEIGHT - 385)
     self.double_dam.set_position(SCREEN_WIDTH - 100, SCREEN_HEIGHT - 385)
コード例 #21
0
ファイル: space.py プロジェクト: tatiiwa/Python-OOP
    def __init__(self, width, height):
        super().__init__(width, height)

        arcade.set_background_color(arcade.color.BLACK)

        self.ship_sprite = arcade.Sprite('images/ship.png')

        self.world = World(width, height)
コード例 #22
0
    def __init__(self, width, height):
        super().__init__(width, height)

        arcade.set_background_color(arcade.color.WHITE)

        self.world = World(SCREEN_WIDTH, SCREEN_HEIGHT)
        self.pacman_sprite = ModelSprite('images/pacman.png',
                                         model=self.world.pacman)
        self.maze_drawer = MazeDrawer(self.world.maze)
コード例 #23
0
ファイル: flappy.py プロジェクト: KorawitRupanya/FlappyBird
    def start(self):
        self.world = World(SCREEN_WIDTH, SCREEN_HEIGHT)

        self.dot_sprite = ModelSprite('images/1.png', model=self.world.player)

        self.pillar_pair_sprites = [
            PillarPairSprite(model=self.world.pillar_pairs[0]),
            PillarPairSprite(model=self.world.pillar_pairs[1])
        ]
コード例 #24
0
ファイル: Space.py プロジェクト: fewgod/OOP
    def __init__(self, width, height):
        super().__init__(width, height)

        arcade.set_background_color(arcade.color.BLACK)
        self.world = World(width, height)  #new object เป็นobject class World
        self.ship_sprite = ModelSprite('images/ship.png',
                                       model=self.world.ship)
        self.gold_sprite = ModelSprite('images/gold.png',
                                       model=self.world.gold)
コード例 #25
0
    def __init__(self, width, height):
        super().__init__(width, height)
        self.world = World(SCREEN_WIDTH, SCREEN_HEIGHT)

        arcade.set_background_color(arcade.color.WHITE_SMOKE)

        self.pan = ModelSprite('images/handpan3.png', model=self.world.pan)
        self.circle = ModelSprite('images/cir.png', model=self.world.circle)
        self.spoon = ModelSprite('images/spoon.png', model=self.world.spoon)
コード例 #26
0
ファイル: dragon.py プロジェクト: noltontarn/dragon
 def setup(self, width, height):
     arcade.set_background_color(arcade.color.BLACK)
     self.world = World(width, height)
     self.background_texture = arcade.load_texture('images/background.png')
     self.dragon_sprite = ModelSprite('images/dragon.png',
                                      model=self.world.dragon)
     self.man_texture = arcade.load_texture('images/man.png')
     self.steak_texture = arcade.load_texture('images/steak.png')
     self.fire_texture = arcade.load_texture('images/fire.png')
コード例 #27
0
def get_worlds():
    """
    http://wiki.guildwars2.com/wiki/API:1/world_names
    """
    for w in api.api_request('world_names'):
        world = World(world_id=w['id'], name=w['name'])
        world.save()

    return World.objects.all()
コード例 #28
0
ファイル: flappy.py プロジェクト: Klan300/flappy
    def __init__(self, width, height):
        super().__init__(width, height)

        arcade.set_background_color(arcade.color.WHITE)

        self.world = World(SCREEN_WIDTH, SCREEN_HEIGHT)
        self.dot_sprite = ModelSprite('images/dot.png',
                                      model=self.world.player)
        self.pillar_pair_sprite = PillarPairSprite(
            model=self.world.pillar_pair)
コード例 #29
0
ファイル: space.py プロジェクト: nongharunana/Space_OOP_Game
    def __init__(self, width, height):
        super().__init__(width, height)

        arcade.set_background_color(arcade.color.BLACK)
        self.world = World(width, height)
        self.ship_sprite = ModelSprite('image/ship',model=self.world.ship)
        self.gold_sprite = ModelSprite('image/gold.png',model=self.world.gold)
        self.asteroid_sprites = []
        for asteroid in self.world.asteroids:
            self.asteroid_sprites.append(ModelSprite('image/ship',scale=0.5,model=asteroid))
コード例 #30
0
 def __init__(self, width, height):
     super().__init__(width, height)
     self.world = World()
     self.worldRenderer = WorldRenderer(self.world)
     self.src = [
         "images/start.fw.png", "images/board.fw.png", "images/win.fw.png",
         "images/lose.fw.png"
     ]
     self.texture = []
     for src in self.src:
         self.texture.append(arcade.load_texture(src))
コード例 #31
0
 def restart(self):
     self.car_list = []
     self.world = World(SCREEN_WIDTH, SCREEN_HEIGHT)
     self.background = arcade.load_texture("Wallpaper2.jpg")
     self.spot_sprite = Spot(100, 50, angle=0)
     self.spot_sprite.add_texture('car_move.png')
     self.world.add_car(self.spot_sprite)
     park_car_list = ['parking_car1.png', 'parking_car2.png']
     for i in self.world.car_park:
         self.car_list.append(
             ModelSprite(random.choice(park_car_list), model=i))
コード例 #32
0
 def game_setup(self, width, height):
     self.world = World(SCREEN_WIDTH, SCREEN_HEIGHT)
     self.background_sprite = ModelSprite("images/Background.png",
                                   model=self.world.background)
     self.background_sprite2 = ModelSprite("images/Background.png",
                                   model=self.world.background2)                              
     self.car_sprite = ModelSprite(self.cartexture,
                                   model=self.world.car)
     self.enemylist = []                              
     self.fpscounter = Fpscounter()
     self.set_update_rate(1/70)
コード例 #33
0
def delete_meeting(meeting_id):
    """ Endpoint to asynchronously delete meeting """
    if not meeting_id:
        return jsonify(
            success=False,
            message=u'Ingen møte ID mottatt'
        )

    meeting = Meeting.get_meeting_by_id(meeting_id)
    # Check if user is owner
    if meeting.user_id == current_user.id:
        # Delete meeting from db before deleting world
        meeting.delete()

        # Object still exists in memory after deleting from db
        if meeting.world_id:
            # Also delete world if it's not favoured
            world = World.get_by_id(meeting.world_id)
            if meeting.user_id == world.user_id and not world.favourite:
                if world.delete():  # Will return false if in use by meeting
                    return jsonify(
                        success=True,
                        message=u'Møtet ble slettet',
                        world_id=world.id
                    )
        return jsonify(
            success=True,
            message=u'Møtet ble slettet'
        )
    return jsonify(
        success=False,
        message=u'Du har ikke tilgang til å slette dette møtet'
    )
コード例 #34
0
def browse_worlds():
    """ Endpoint to asynchronously get Minecraft world list for the current user as partial html """
    world_list = World.get_user_worlds(current_user.id)
    return render_template(
        'browse_worlds.html',
        world_list=world_list
    )
コード例 #35
0
ファイル: __main__.py プロジェクト: firemark/srpp-travel
def run(args):
    world = World.from_file(args.path_to_file)

    print("filename: %s" % world.filename)
    print("magazine x: %d y: %d" % world.magazine)
    print("len of cities: %d" % len(world.cities))
    print("k: %d" % world.k)

    print("----")

    find_routes(world).print_result()
コード例 #36
0
def world_info(world_id):
    """ Endpoint to asynchronously get Minecraft world info as partial html """
    if not world_id:
        return jsonify(
            success=False,
            message=u'Ingen verden ID mottatt'
        )
    world = World.get_by_id(world_id)
    return render_template(
        'world_info.html',
        world=world
    )
コード例 #37
0
def generate_preview(world_id):
    """ Not used? """
    if not world_id:
        return jsonify(
            success=False,
            message=u'Ingen verden ID mottatt'
        )
    w = World.get_by_id(world_id)
    world_ref = w.file_ref
    success = files.generate_world_preview(world_ref)
    if success:
        w.preview = True
        w.store()
        return 'Genererer forhåndsvisning. Dette kan ta noen minutter.'
    else:
        return 'Failure'
コード例 #38
0
def show_preview(world_id):
    """ Render Minecraft world preview page or generate preview if it doesn't exist """
    if not world_id:
        return jsonify(
            success=False,
            message=u'Ingen verden ID mottatt'
        )

    # TODO Check if preview files is present
    world = World.get_by_id(world_id)
    preview = tasks.generate_preview_task.AsyncResult(world.file_ref)
    if preview.status == 'PENDING':
        print(str(world_id) + " PENDING")
        # Probably not started. Start it.
        success = files.generate_world_preview(world.file_ref)
        if success:
            return jsonify(
                status='PENDING',
                message=u'Ingen forhåndsvisning lagret. Ber om forhåndsvisning...'
            )
        else:
            return jsonify(
                status='FAILED',
                message=u'Noe gikk galt!'
            )
    elif preview.status == 'SENT':
        print(str(world_id) + " SENT")
        # Received by the worker, and in queue. Tell user to wait.
        return jsonify(
            status='SENT',
            message=u'Forespørsel om forhåndsvisning er sendt. Hvis det er stor pågang kan dette ta en stund.'
        )
    elif preview.status == 'STARTED':
        print(str(world_id) + " STARTED")
        # Generating preview
        return jsonify(
            status='STARTED',
            message=u'Vi lager en forhåndsvisning. Dette kan ta noen minutter.'
        )
    elif preview.status == 'SUCCESS':
        print(str(world_id) + " SUCCESS")
        # Finished. Show the preview.
        print('forhåndsvisningen er ferdig')
        return render_template(
            'preview.html',
            world_ref=world.file_ref,
        ), 200
コード例 #39
0
def delete_world(world_id):
    """ Endpoint to asynchronously delete Minecraft world """
    if not world_id:
        return jsonify(
            success=False,
            message=u'Ingen verden ID mottatt'
        )

    world = World.get_by_id(world_id)
    # Check if user is owner
    if world.user_id == current_user.id:
        if world.delete():  # Will return false if in use by meeting
            return jsonify(
                success=True,
                message=u'Minecraft verdenen ble slettet'
            )
        return jsonify(
            success=False,
            message=u'Denne Minecraft verdenen er registrert brukt i et møte'
        )
    return jsonify(
        success=False,
        message=u'Du har ikke tilgang til å slette denne Minecraft verdenen'
    )
コード例 #40
0
def toggle_favourite(world_id):
    """ Endpoint to asynchronously toggle a Minecraft world as favourite """
    if not world_id:
        return jsonify(
            success=False,
            message=u'Ingen verden ID mottatt'
        )

    world = World.get_by_id(world_id)
    # Check if current user is owner
    if current_user.id == world.user_id:
        # Invert current setting and store
        world.favourite = not world.favourite
        world.store()

        return jsonify(
            success=True,
            message=u'Lagret som favoritt' if world.favourite else u'Favoritt fjernet',
            favourite=world.favourite
        )
    return jsonify(
        success=False,
        message=u'Du har ikke tilgang til å lagre denne verdenen som favoritt'
    )
コード例 #41
0
ファイル: hello_tavrida.py プロジェクト: phantomii/tavrida
 def create_world(self, request, proxy, value, parent_id):
     w = World(value=value, parent_id=parent_id)
     w.save()
     print "World created: %s" % w
コード例 #42
0
def home():
    """ Renders the home page """
    # Meeting list will be shown at the bottom of the page
    meeting_list = Meeting.get_user_meetings(current_user.id)
    # Selected world (in meeting tab) defaults to None and gets overridden if there is a world selected
    world = None
    # Default to world selection tab
    # 0 is world selection tab and 1 is meeting details tab
    set_tab = 0
    # Locale encoding used for day names
    # preferred_encoding = locale.getpreferredencoding()
    preferred_encoding = 'UTF-8'

    # A form is posted
    if request.method == 'POST':
        # If request is a redirect from map page, we will have a WorldForm
        world_form = forms.WorldForm(request.form)
        if world_form.validate():
            # Go to meeting details tab
            set_tab = 1
            # Show empty meeting form
            meeting_form = forms.MeetingForm()
            try:
                world_id = int(world_form.world_id.data)
                description = world_form.description.data
                world = World.get_by_id(world_id)
                if world:
                    # Update description if changed
                    if world.description != description:
                        world.description = description
                        world.store()
                    # Put world ID in meeting form for reference
                    meeting_form.world_id.process_data(str(world_id))
                else:  # World does not exist
                    flash(u'Den valgte Minecraft verdenen eksisterer ikke')
                    set_tab = 0

            except ValueError:
                # A number was not supplied as world ID
                flash(u'world_id ValueError')

            return render_template(
                'index.html',
                set_tab=set_tab,
                title=u'Hjem',
                meetings=meeting_list,
                form=meeting_form,
                world=world,
                action=url_for('home'),
                locale=preferred_encoding
            )

        # Check if a meeting form is posted
        form = forms.MeetingForm(request.form)
        if form.validate():
            # If valid, put data from form into Meeting object
            meeting = Meeting(user_id=current_user.id)
            form.populate_obj(meeting)
            if meeting.world_id:  # World ID will be none if the posted value is not an integer
                if World.exists(meeting.world_id):  # Check that the world exists in the database
                    meeting.store()

                    # Celery stuff
                    # tasks.meeting_test.apply_async()
                    tasks.meeting_test.apply_async(eta=meeting.start_time, expires=meeting.end_time)

                    flash(u'Nytt møte lagt til')
                    return redirect(url_for('home'))

                else:  # World does not exist
                    flash(u'Den valgte Minecraft verdenen eksisterer ikke')
                    set_tab = 1

            else:  # World probably not chosen
                flash(u'Ingen Minecraft verden valgt')
                set_tab = 0

        else:  # Form not valid
            flash(u'Feil i skjema!')
            set_tab = 1
            try:  # Insert world info
                world_id = int(form.world_id.data)
                world = World.get_by_id(world_id)
            except ValueError:
                pass

    else:  # If not POST
        # Serve blank form
        form = forms.MeetingForm()

    return render_template(
        'index.html',
        set_tab=set_tab,
        title=u'Hjem',
        meetings=meeting_list,
        form=form,
        world=world,
        action=url_for('home'),
        locale=preferred_encoding
    )