コード例 #1
0
ファイル: cod.py プロジェクト: schedin/python-edu
def main():
    conny_tank = tank.Tank('German', 'Tiger')
    thomas_tank = tank.Tank('America', 'Sherman')
    lasse_tank = tank.Tank('Brish', 'Churchill')

    conny_tank.accel(38)
    thomas_tank.accel(29)
    lasse_tank.rotate_left(320)

    lasse_tank.shoot()
    conny_tank.take_damage(63)
    thomas_tank.take_damage(34)

    print(
        f"Conny's tank is at {conny_tank.origin} and health is {conny_tank._health}"
    )

    print(f"The health of conny's and thomas's is {conny_tank + thomas_tank}")

    print(dir(tank))
    if hasattr(tank, '__str__'):
        print("tank has str")

    if hasattr(thomas_tank, '__str__'):
        print(f"Status of thomas_tank: {thomas_tank}")

    #thomas_tank.set_health(100)
    #print(f"Health of thomas_tank: {thomas_tank.get_health()}")

    thomas_tank.tank_health = 99
    print(f"Health of thomas_tank: {thomas_tank.tank_health}")
コード例 #2
0
ファイル: main.py プロジェクト: niapaulson/Tanks
	def __init__(self, width=1200, height=675):

		pg.init()
		pg.mixer.init()
		self.width = width
		self.height = height
		self.screen = pg.display.set_mode((self.width, self.height))
		pg.display.set_caption("Tanks")
		pg.display.update() 
		self.background = u.loadImage("myBackground.png")[0]#pg.Surface(self.screen.get_size()).convert()
		self.screen.blit(self.background, (0, 0))
		self.wall = u.loadImage("myWall.png")
		self.screen.blit(self.wall[0],(600,375))
		self.tank1 = tank.Tank(10, u.GROUND, "myTank.png", "myShootyThing45.png",1)
		self.screen.blit(self.tank1.image, (100, 577))
		self.screen.blit(self.tank1.shootyThingImage, (0, 0))
		self.tank2 = tank.Tank(-10, u.GROUND, "myTank2.png", "myShootyThing2_45.png",2)
		self.screen.blit(self.tank2.image, (1100, 577))
		self.screen.blit(self.tank2.shootyThingImage, (0, 0))
		self.spritegroup = pg.sprite.Group()
		self.smallfont = pg.font.SysFont("comicsansms",25)
		self.medfont = pg.font.SysFont("comicsansms",50)
		self.largefont = pg.font.SysFont("comicsansms",80)
		self.music = u.loadMusic("IntroMusic.mp3")		
		#self.icon = pg.image.load('myTank.png')
		pg.sprite.RenderPlain()
		pg.display.flip()
		#pg.display.set_icon(self.icon)#best size is 32*32
		self.clock = pg.time.Clock()
		self.buttong = pg.draw.rect(self.screen,u.GREEN,(100,500,100,50))
		self.buttony = pg.draw.rect(self.screen,u.YELLOW,(300,500,100,50))
		self.buttonr = pg.draw.rect(self.screen,u.RED,(500,500,100,50))
コード例 #3
0
    def test_project_root_mismatch(self):
        """
        Case that root name specified in projects yml file does not exist in roots file.
        """
        # remove root name from the roots file
        self.setup_multi_root_fixtures()
        self.tk = tank.Tank(self.project_root)

        # should be fine
        folder.configuration.FolderConfiguration(self.tk, self.schema_location)

        roots_file = os.path.join(self.tk.pipeline_configuration.get_path(),
                                  "config", "core", "schema",
                                  "alternate_1.yml")

        fh = open(roots_file, "r")
        data = yaml.load(fh)
        fh.close()
        data["root_name"] = "some_bogus_Data"
        fh = open(roots_file, "w")
        fh.write(yaml.dump(data))
        fh.close()

        self.tk = tank.Tank(self.project_root)

        self.assertRaises(TankError, folder.configuration.FolderConfiguration,
                          self.tk, self.schema_location)
コード例 #4
0
ファイル: main.py プロジェクト: niapaulson/Tanks
    def __init__(self, width=1200, height=675):

        pg.init()
        pg.mixer.init()
        self.width = width
        self.height = height
        self.screen = pg.display.set_mode((self.width, self.height))
        pg.display.set_caption("Tanks")
        pg.display.update()
        self.background = u.loadImage("myBackground.png")[
            0]  #pg.Surface(self.screen.get_size()).convert()
        self.screen.blit(self.background, (0, 0))
        self.wall = u.loadImage("theBarrierReal.jpg")[0]
        self.screen.blit(self.wall, (600, 0))
        self.tank1 = tank.Tank(10, u.GROUND, "myTank.png",
                               "myShootyThing45.png", 1, 1)
        self.screen.blit(self.tank1.image, (100, 577))
        self.screen.blit(self.tank1.shootyThingImage, (0, 0))
        #self.tank2 = tank.Tank(-10, u.GROUND, "myTank2.py", "myShootyThing2_45.png",2, 1)
        self.tank2 = tank.Tank(-10, u.GROUND, "trumpsan.png",
                               "myShootyThing2_45.png", 2, 3)
        self.screen.blit(self.tank2.image, (1100, 577))
        #self.screen.blit(self.tank2.shootyThingImage, (0, 0))
        self.spritegroup = pg.sprite.Group()
        self.smallfont = pg.font.SysFont("japan", 25)
        self.medfont = pg.font.SysFont("japan", 50)
        self.largefont = pg.font.SysFont("electron", 80)
        #self.music = u.loadMusic("IntroMusic.mp3")
        self.music = u.loadMusic("RealGameMusic.mp3")
        pg.sprite.RenderPlain()
        pg.display.flip()
        self.clock = pg.time.Clock()
        self.buttong = pg.draw.rect(self.screen, u.GREEN, (100, 500, 100, 50))
        self.buttony = pg.draw.rect(self.screen, u.YELLOW, (300, 500, 100, 50))
        self.buttonr = pg.draw.rect(self.screen, u.RED, (500, 500, 100, 50))
コード例 #5
0
    def setUp(self):
        super(TestCreateFilesystemStructure, self).setUp()
        self.setup_fixtures()

        self.tk = tank.Tank(self.project_root)

        self.seq = {
            "type": "Sequence",
            "id": 2,
            "code": "seq_code",
            "project": self.project
        }
        self.shot = {
            "type": "Shot",
            "id": 1,
            "code": "shot_code",
            "sg_sequence": self.seq,
            "project": self.project
        }
        self.step = {
            "type": "Step",
            "id": 3,
            "code": "step_code",
            "short_name": "step_short_name"
        }
        self.asset = {
            "type": "Asset",
            "id": 4,
            "sg_asset_type": "assettype",
            "code": "assetname",
            "project": self.project
        }
        self.task = {
            "type": "Task",
            "id": 1,
            "content": "this task",
            "entity": self.shot,
            "step": {
                "type": "Step",
                "id": 3
            },
            "project": self.project
        }

        # Add these to mocked shotgun
        self.add_to_sg_mock_db([
            self.shot, self.seq, self.step, self.project, self.asset, self.task
        ])

        self.tk = tank.Tank(self.project_root)

        # add mock schema data so that a list of the asset type enum values can be returned
        data = {}
        data["properties"] = {}
        data["properties"]["valid_values"] = {}
        data["properties"]["valid_values"]["value"] = ["assettype"]
        data["data_type"] = {}
        data["data_type"]["value"] = "list"
        self.add_to_sg_schema_db("Asset", "sg_asset_type", data)
コード例 #6
0
ファイル: main.py プロジェクト: dreamghosttsukimi/game
def init_game(windowsize, count):
    gmap = mymap.Map(windowsize)
    if mapfile:
        gmap.set_map(mapfile)
    else:
        gmap.random_map()
    player = tank.Tank(True, gmap, count)
    enemynum = random.randint(1, 10)
    enemies = []
    for i in range(enemynum):
        count += 1
        enemies.append(tank.Tank(False, gmap, count))

    return gmap, player, enemies
コード例 #7
0
    def setUp(self):
        """Sets up entities in mocked shotgun database and creates Mock objects
        to pass in as callbacks to Schema.create_folders. The mock objects are
        then queried to see what paths the code attempted to create.
        """
        super(TestSchemaCreateFoldersSecondaryEntity, self).setUp()
        self.setup_fixtures("optional_folder_fields")
        self.shot = {
            "type": "Shot",
            "id": 1,
            "code": "shot_code",
            "sg_other_field": None,
            "project": self.project
        }

        entities = [self.shot, self.project]

        # Add these to mocked shotgun
        self.add_to_sg_mock_db(entities)

        self.tk = tank.Tank(self.project_root)

        self.schema_location = os.path.join(self.project_root, "tank",
                                            "config", "core", "schema")

        self.FolderIOReceiverBackup = folder.folder_io.FolderIOReceiver.execute_folder_creation
        folder.folder_io.FolderIOReceiver.execute_folder_creation = execute_folder_creation_proxy
コード例 #8
0
    def setUp(self):
        super(TestEnvironment, self).setUp()
        self.setup_fixtures()

        self.test_env = "test"
        self.test_engine = "test_engine"

        # create env object
        tk = tank.Tank(self.project_root)
        self.env = tk.pipeline_configuration.get_environment(self.test_env)

        # get raw environment
        env_file = os.path.join(self.project_config, "env", "test.yml")
        fh = open(env_file)
        self.raw_env_data = yaml.load(fh)
        fh.close()

        # get raw app metadata
        app_md = os.path.join(self.project_config, "test_app", "info.yml")
        fh = open(app_md)
        self.raw_app_metadata = yaml.load(fh)
        fh.close()

        # get raw engine metadata
        eng_md = os.path.join(self.project_config, "test_engine", "info.yml")
        fh = open(eng_md)
        self.raw_engine_metadata = yaml.load(fh)
        fh.close()
コード例 #9
0
    def setUp(self):
        super(TestValidateSettings, self).setUp()
        # set up data so as to supply a valid context
        seq = {"type": "Sequence", "name": "seq_name", "id": 3}
        seq_path = os.path.join(self.project_root, "sequence/Seq")
        self.add_production_path(seq_path, seq)
        shot = {
            "type": "Shot",
            "name": "shot_name",
            "id": 2,
            "project": self.project
        }
        shot_path = os.path.join(seq_path, "shot_code")
        self.add_production_path(shot_path, shot)
        # a second shot path without sequence
        shot_path_2 = os.path.join(self.project_root, "shot_code")
        self.add_production_path(shot_path_2, shot)

        # setup context with values for project and shot
        self.tk = tank.Tank(self.project_root)
        self.context = self.tk.context_from_path(shot_path)

        # The validation code needs a name for error reporting
        self.app_name = "test_app"

        # keys for templates
        self.keys = {
            "Sequence": StringKey("Sequence"),
            "Shot": StringKey("Shot")
        }
コード例 #10
0
    def test_skip_invalid(self):
        """Test that files not valid for an template are not returned.

        This refers to bug reported in Ticket #17090
        """
        keys = {
            "Shot": StringKey("Shot"),
            "Sequence": StringKey("Sequence"),
            "Step": StringKey("Step"),
            "name": StringKey("name"),
            "version": IntegerKey("version", format_spec="03")
        }

        definition = "sequences/{Sequence}/{Shot}/{Step}/work/{name}.v{version}.nk"
        template = TemplatePath(definition, keys, self.project_root,
                                "my_template")
        tk = tank.Tank(self.project_root)
        tk._templates = {template.name: template}
        bad_file_path = os.path.join(self.project_root, "sequences",
                                     "Sequence1", "Shot1", "Foot", "work",
                                     "name1.va.nk")
        good_file_path = os.path.join(self.project_root, "sequences",
                                      "Sequence1", "Shot1", "Foot", "work",
                                      "name.v001.nk")
        self.create_file(bad_file_path)
        self.create_file(good_file_path)
        ctx_fields = {"Sequence": "Sequence1", "Shot": "Shot1", "Step": "Foot"}
        result = tk.paths_from_template(template, ctx_fields)
        self.assertIn(good_file_path, result)
        self.assertNotIn(bad_file_path, result)
コード例 #11
0
ファイル: blackearth.py プロジェクト: cgrooves/black-earth
    def create_tanks(self, num_tanks):
        # Populate a list based on number of tanks
        # The list will be useful for keeping track of all of the tanks, and
        # being able to do the same operation (such a "draw") on them all very
        # easily.
        self.tanksList = []
        for n in range(1, num_tanks + 1):
            new_tank = tank.Tank(name=f"Player {n}",
                                 parent=self,
                                 position=pymunk.Vec2d(
                                     WindowConfig.WIDTH * n / (num_tanks + 1),
                                     WindowConfig.HEIGHT / 3),
                                 color=next(TankConfig.COLORS))

            self.tanksList.append(new_tank)

        # Create a circular Iterator for the tank list
        # An Iterator is something different from a list, though certainly you can
        # "iterate" through things like lists and tuples and even dictionaries.
        # In other words, lists and tuples and dictionaries can themselves be termed
        # "Iterators". I still want a list of tanks, but I also want something that
        # points to that list, but I can use to cycle through them endlessly. I know
        # that I want this, because I know that I just want to be able to keep going
        # to whatever Tank's turn is next. Next, next, next. Me calling "next" shouldn't
        # alter the list of tanks; I can have two "views" of the same data: the list
        # view, and the endless cycle view.
        self.tanksCycle = itertools.cycle(self.tanksList)

        # Set the active player
        self.activeTank = next(self.tanksCycle)
コード例 #12
0
    def setUp(self):

        super(TestStaticFolderFilters, self).setUp()
        self.setup_fixtures("static_filters_core")

        self.tk = tank.Tank(self.project_root)

        self.shot_aaa = {
            "type": "Shot",
            "id": 1,
            "code": "aaa",
            "project": self.project
        }

        self.shot_bbb = {
            "type": "Shot",
            "id": 2,
            "code": "bbb",
            "project": self.project
        }

        self.add_to_sg_mock_db([self.shot_aaa, self.shot_bbb])

        self.aaa = os.path.join(self.project_root, "aaa")
        self.aaa_work = os.path.join(self.project_root, "aaa", "work")
        self.aaa_pub = os.path.join(self.project_root, "aaa", "publish")

        self.bbb = os.path.join(self.project_root, "bbb")
        self.bbb_work = os.path.join(self.project_root, "bbb", "work")
        self.bbb_pub = os.path.join(self.project_root, "bbb", "publish")
コード例 #13
0
ファイル: test_shotgun.py プロジェクト: tonybarbieri/tk-core
    def test_sequence_abstracted_path(self):
        """Test that if path supplied represents a sequence, the abstract version of that
        sequence is used."""
        tk = tank.Tank(self.project_root)
        # mock shotgun
        tk._tank__sg = self.sg_mock

        # make sequence key
        keys = {"seq": tank.templatekey.SequenceKey("seq", format_spec="03")}
        # make sequence template
        seq_template = tank.template.TemplatePath("/folder/name_{seq}.ext",
                                                  keys, self.project_root)
        tk.templates["sequence_template"] = seq_template

        seq_path = os.path.join(self.project_root, "folder", "name_001.ext")

        # mock sg.create, check it for path value
        tank.util.register_publish(tk, self.context, seq_path, self.name,
                                   self.version)

        # check that path is modified before sent to shotgun
        expected_path = os.path.join(self.project_root, "folder",
                                     "name_%03d.ext")
        project_name = os.path.basename(self.project_root)
        expected_path_cache = "%s/%s/%s" % (project_name, "folder",
                                            "name_%03d.ext")

        # look at values sent to the Mocked shotgun.create
        actual_path = tk.shotgun.create.call_args[0][1]["path"]["local_path"]
        actual_path_cache = tk.shotgun.create.call_args[0][1]["path_cache"]

        self.assertEqual(expected_path, actual_path)
        self.assertEqual(expected_path_cache, actual_path_cache)
コード例 #14
0
    def setUp(self):
        super(TestApplication, self).setUp()
        self.setup_fixtures()

        # setup shot
        seq = {"type": "Sequence", "name": "seq_name", "id": 3}
        seq_path = os.path.join(self.project_root, "sequences/Seq")
        self.add_production_path(seq_path, seq)
        shot = {
            "type": "Shot",
            "name": "shot_name",
            "id": 2,
            "project": self.project
        }
        shot_path = os.path.join(seq_path, "shot_code")
        self.add_production_path(shot_path, shot)
        step = {"type": "Step", "name": "step_name", "id": 4}
        self.shot_step_path = os.path.join(shot_path, "step_name")
        self.add_production_path(self.shot_step_path, step)

        self.test_resource = os.path.join(self.project_root, "tank", "config",
                                          "foo", "bar.png")
        os.makedirs(os.path.dirname(self.test_resource))
        fh = open(self.test_resource, "wt")
        fh.write("test")
        fh.close()

        tk = tank.Tank(self.project_root)
        context = tk.context_from_path(self.shot_step_path)
        self.engine = tank.platform.start_engine("test_engine", tk, context)
コード例 #15
0
ファイル: main.py プロジェクト: coojee2012/LearnPython
    def start(self):
        _dispaly.init()
        MainGame.window = _dispaly.set_mode([SCREEN_WIDTH, SCREEN_HEIGT])

        _dispaly.set_caption("坦克又见坦克")

        self.music.playbgm(bgmFile='img/start.wav')
        # 加载我方坦克
        MainGame.TANK_P1 = tank.Tank(MainGame.window, 400, 300)
        # 加载敌方坦克
        self.creatEnemyTank()
        self.creatWalls()

        # 循环刷新窗体
        while True:
            # 不循环事件会卡住
            for event in pygame.event.get():
                if event.type == QUIT:
                    pygame.quit()
                    sys.exit(0)  # 0正常退出程序
                else:
                    self.doneEvent(event)

            MainGame.window.fill(COLOR_BG)
            if len(MainGame.EnemyTanks) == 0:
                x = random.randint(10, 700)
                y = random.randint(10, 500)
                MainGame.window.blit(
                    self.getTextSurface("You Win Press 'R' Restart"), (x, y))
                time.sleep(1)
                _dispaly.update()
                continue
            if not MainGame.TANK_P1.live:
                x = random.randint(10, 700)
                y = random.randint(10, 500)
                MainGame.window.blit(
                    self.getTextSurface("You Loss Press 'R' Restart"), (x, y))
                time.sleep(1)
                _dispaly.update()
                continue

            MainGame.window.blit(
                self.getTextSurface(u"Remain %d Tankers" %
                                    len(MainGame.EnemyTanks)), (5, 5))
            if MainGame.TANK_P1.live:
                MainGame.TANK_P1.displayTank()
                MainGame.TANK_P1.hitWalls(MainGame.Walls)
                MainGame.TANK_P1.hitTank(MainGame.EnemyTanks, MainGame.TANK_P1)

            self.blitWalls()
            self.blitEnemyTank()
            self.blitBullets()
            self.blitExploads()
            #根据坦克的开关状态调用坦克的移动方法
            if MainGame.TANK_P1 and not MainGame.TANK_P1.stop:
                MainGame.TANK_P1.move()
            time.sleep(0.02)
            _dispaly.update()
コード例 #16
0
    def setUp(self):
        super(TestFolderCreationEdgeCases, self).setUp()
        self.setup_fixtures()

        self.tk = tank.Tank(self.project_root)

        self.seq = {
            "type": "Sequence",
            "id": 2,
            "code": "seq_code",
            "project": self.project
        }
        self.shot = {
            "type": "Shot",
            "id": 1,
            "code": "shot_code",
            "sg_sequence": self.seq,
            "project": self.project
        }
        self.step = {
            "type": "Step",
            "id": 3,
            "code": "step_code",
            "short_name": "step_short_name"
        }
        self.task = {
            "type": "Task",
            "id": 1,
            "content": "this task",
            "entity": self.shot,
            "step": {
                "type": "Step",
                "id": 3
            },
            "project": self.project
        }

        # Add these to mocked shotgun
        self.add_to_sg_mock_db(
            [self.shot, self.seq, self.step, self.project, self.task])

        self.tk = tank.Tank(self.project_root)

        self.path_cache = path_cache.PathCache(self.tk.pipeline_configuration)
コード例 #17
0
    def setUp(self):
        """Sets up entities in mocked shotgun database and creates Mock objects
        to pass in as callbacks to Schema.create_folders. The mock objects are
        then queried to see what paths the code attempted to create.
        """
        super(TestSchemaCreateFoldersStepAndUserSandbox, self).setUp()
        self.setup_fixtures("humanuser_step_core")
        self.seq = {
            "type": "Sequence",
            "id": 2,
            "code": "seq_code",
            "project": self.project
        }

        self.shot = {
            "type": "Shot",
            "id": 1,
            "code": "shot_code",
            "sg_sequence": self.seq,
            "project": self.project
        }

        self.step = {
            "type": "Step",
            "id": 3,
            "code": "step_code",
            "short_name": "step_short_name"
        }

        self.task = {
            "type": "Task",
            "id": 23,
            "entity": self.shot,
            "step": self.step,
            "project": self.project
        }

        cur_login = tank.util.login.get_login_name()

        self.humanuser = {"type": "HumanUser", "id": 2, "login": cur_login}

        entities = [
            self.shot, self.task, self.seq, self.step, self.project,
            self.humanuser
        ]

        # Add these to mocked shotgun
        self.add_to_sg_mock_db(entities)

        self.tk = tank.Tank(self.project_root)

        self.schema_location = os.path.join(self.project_root, "tank",
                                            "config", "core", "schema")

        self.FolderIOReceiverBackup = folder.folder_io.FolderIOReceiver.execute_folder_creation
        folder.folder_io.FolderIOReceiver.execute_folder_creation = execute_folder_creation_proxy
コード例 #18
0
def setUpThread():
    global CLOCK
    global playerReady, Bullet
    global waitFlag
    global team1, team2
    for F in playerName.keys():
        Bullet[F] = None
    for F in playerName.keys():
        playerDead[F] = 0
    for F in playerName.keys():
        playerReady[F] = 0
    team1, team2 = utilites.shuffle(playerName)
    for F in team1.keys():
        team1[F] = tank.Tank(playerName[F], utilites.teamSide(0), -110 + setting.HEIGHT, -1)
    for F in team2.keys():
        team2[F] = tank.Tank(playerName[F], utilites.teamSide(1), -110 + setting.HEIGHT, 1)
    CLOCK = clockThread()
    time.sleep(5)
    CLOCK.start()
コード例 #19
0
    def setUp(self):
        super(TestUpdateEnvironment, self).setUp()
        self.setup_fixtures()

        self.test_env = "test"
        self.test_engine = "test_engine"

        # create env object
        tk = tank.Tank(self.project_root)
        self.env = tk.pipeline_configuration.get_environment(self.test_env)
コード例 #20
0
 def test_good_path(self):
     app_path = os.path.join(self.project_config, "test_app")
     tk = tank.Tank(self.project_root)
     # make a dev location and create descriptor
     app_desc = descriptor.get_from_location(descriptor.AppDescriptor.APP,
                                             tk.pipeline_configuration, {
                                                 "type": "dev",
                                                 "path": app_path
                                             })
     result = application.get_application(self.engine, app_path, app_desc,
                                          {}, "instance_name")
     self.assertIsInstance(result, application.Application)
コード例 #21
0
class GameWindow(pyglet.window.Window):
    def __init__(self, *arg, **kwargs):
        super().__init__(*arg, **kwargs)

    player_tank = []
    piece_of_tank = {}
    tank_1 = tank.Tank(240, 300)
    tu = turret.Turret(tank_1.x, tank_1.y)
    ch = chassis.Chassis(tank_1.x, tank_1.y)

    # Dict des instances du tank
    piece_of_tank['tank'] = tank_1
    piece_of_tank['turret'] = tu
    piece_of_tank['chassis'] = ch

    # Creation des sprites
    chassis_1 = ch.create_chassis('assets/sprites/chassis_2.png')
    turret_1 = tu.create_turret("assets/sprites/turret_2.png")

    # liste des sprites
    player_tank.append(chassis_1)
    player_tank.append(turret_1)

    def on_draw(
        self
    ):  # Surcharge la methode de on_draw de la superclass pyglet.window.Window
        self.clear()
        # boucle sur liste des sprites
        for t in self.player_tank:
            t.draw()

    def on_mouse_motion(self, x, y, dx, dy):
        self.mouse_x = int(float(x))
        self.mouse_y = int(float(y))

    def on_key_press(self, symbol, modifiers):
        self.player.isKeyPressed = True
        if symbol == key.Z:
            self.direction = 'head'
        elif symbol == key.S:
            self.direction = 'back'
        elif symbol == key.D:
            self.direction = 'right'
        elif symbol == key.Q:
            self.direction = 'left'

    def on_key_release(self, symbol, modifiers):
        self.player.isKeyPressed = False
        self.direction = "none"

    def update(self, dt):
        self.tu.rotate(dt)
コード例 #22
0
ファイル: main.py プロジェクト: coojee2012/LearnPython
    def restart(self):
        MainGame.EnemyTanks = []
        MainGame.Walls = []
        MainGame.Bullets = []
        MainGame.Exploads = []
        MainGame.TANK_P1 = None

        self.music.playbgm(bgmFile='img/start.wav')
        # 加载我方坦克
        MainGame.TANK_P1 = tank.Tank(MainGame.window, 400, 300)
        # 加载敌方坦克
        self.creatEnemyTank()
        self.creatWalls()
コード例 #23
0
ファイル: start.py プロジェクト: emtee40/opensourcestand
    def __init__(self, ioloop):
        self.ioloop = ioloop
        self.serv = server.TopServer(self)
        #self.tank = tank.Tank(options.options.tank, 43000)
        self.tank = tank.Tank('192.168.1.2', 43000)
        self.state = State.RESULTS
        self.user = None
        self.rps = rps.RPSCounter()
        self.top = top.Top()
        self.users = users.Userlist()

        self.timer_counter = None
        self.timer_fn = None
        self.timer_cb = tornado.ioloop.PeriodicCallback(self.timer, 1000, self.ioloop)
コード例 #24
0
ファイル: gms5.py プロジェクト: VinTurnier/gms_app
 def changeTank(self):
     try:
         self.tank = tank.Tank(self.station.stationId)
         tankName = self.mainWindow.tankSelect_comboBox.currentText()
         fuel_receive_today = self.a_query.received_quantity_for(tankName,self.mainWindow.tank_dateEdit.text())
         stockEoPD = self.a_query.end_of_previous_day_volume_for(tankName,self.mainWindow.tank_dateEdit.text())
         sales_and_stockEoD = self.a_query.sales_and_stockEoD_for(tankName,self.mainWindow.tank_dateEdit.text())
         lost_fuel = self.a_query.calculated_lost_for(tankName,self.mainWindow.tank_dateEdit.text())
         self.mainWindow.fuelReceived_doubleSpinBox.setValue(fuel_receive_today)
         self.mainWindow.StockBoD_doubleSpinBox.setValue(stockEoPD)
         self.mainWindow.sales_doubleSpinBox.setValue(sales_and_stockEoD['sales'])
         self.mainWindow.StockEoD_doubleSpinBox.setValue(sales_and_stockEoD['stockEoD'])
         self.mainWindow.lost_fuel_doubleSpinBox.setValue(lost_fuel)
     except:
         self.mainWindow.lost_fuel_doubleSpinBox.setValue(0)
コード例 #25
0
    def test_project_one_yml_missing(self):
        """
        Case that there are mutiple projects, one non-primary without yaml a file
        """
        self.setup_multi_root_fixtures()
        self.tk = tank.Tank(self.project_root)

        # should be fine
        folder.configuration.FolderConfiguration(self.tk, self.schema_location)

        project_yml = os.path.join(self.schema_location, "alternate_1.yml")
        os.remove(project_yml)

        self.assertRaises(TankError, folder.configuration.FolderConfiguration,
                          self.tk, self.schema_location)
コード例 #26
0
def __tank_startup_node_callback():
    """
    Callback that fires every time a node gets created.
    
    Carefully manage exceptions here so that a bug in Tank never
    interrupts the normal workflows in Nuke.    
    """
    try:
        # look for the root node - this is created only when a new or existing file is opened.
        tn = nuke.thisNode()
        if tn != nuke.root():
            return

        if nuke.root().name() == "Root":
            # file->new
            # base it on the context we 'inherited' from the prev session
            # get the context from the previous session - this is helpful if user does file->new
            project_root = os.environ.get("TANK_NUKE_ENGINE_INIT_PROJECT_ROOT")
            tk = tank.Tank(project_root)

            ctx_yaml = os.environ.get("TANK_NUKE_ENGINE_INIT_CONTEXT")
            if ctx_yaml:
                try:
                    new_ctx = yaml.load(ctx_yaml)
                except:
                    new_ctx = tk.context_empty()
            else:
                new_ctx = tk.context_empty()

        else:
            # file->open
            file_name = nuke.root().name()

            try:
                tk = tank.tank_from_path(file_name)
            except tank.TankError, e:
                __create_tank_disabled_menu(e)
                return

            # try to get current ctx and inherit its values if possible
            curr_ctx = None
            if tank.platform.current_engine():
                curr_ctx = tank.platform.current_engine().context

            new_ctx = tk.context_from_path(file_name, curr_ctx)

        # now restart the engine with the new context
        __engine_refresh(tk, new_ctx)
コード例 #27
0
    def test_context_determines_fields(self):
        """
        Case that field has no direct value in the context, but does have a value
        when calling Context.as_template_fields.
        """
        # template with fields not in required fields or context's attributes
        field_name = "Sequence"
        template = tank.template.TemplatePath("sequence/{%s}" % field_name,
                                              self.keys, self.project_root)
        # tank instance with this template
        tk = tank.Tank(self.project_root)
        tk.templates = {self.template_name: template}

        # If no error, then success
        validate_settings(self.app_name, tk, self.context, self.metadata,
                          self.config)
コード例 #28
0
    def test_fields_from_context(self):
        """
        Case that a template's fields that are not part of the metadata's 
        required fields have value in the context.
        """
        # template with fields matching context attributes
        field_name = "Shot"

        template = tank.template.TemplatePath("{%s}" % field_name, self.keys,
                                              self.project_root)
        # tank instance with this template
        tk = tank.Tank(self.project_root)
        tk.templates = {self.template_name: template}

        # If no error, then success
        validate_settings(self.app_name, tk, self.context, self.metadata,
                          self.config)
コード例 #29
0
    def test_default_values_detected(self):
        """
        Case that field's value cannot be determined by the context, but field has a default value.
        """
        # template with field with default value
        field_name = "field_1"
        self.keys[field_name] = StringKey(field_name, default="default")

        template = tank.template.TemplatePath("{%s}" % field_name, self.keys,
                                              self.project_root)
        # tank instance with this template
        tk = tank.Tank(self.project_root)
        tk.templates = {self.template_name: template}

        # If no error, then success
        validate_settings(self.app_name, tk, self.context, self.metadata,
                          self.config)
コード例 #30
0
ファイル: levelscene.py プロジェクト: morganq/picketpuzzle
    def place_obj_by_index(self, index, x, y):
        o = None
        if index == game.OBJ['factory']:  # Factory
            o = factory.Factory(x, y)
            self.factories.append(o)
            self.game_group.add(o)
            self.animatedsprites.append(o)

        if index == game.OBJ['cityhall']:  # City Hall

            o = cityhall.CityHall(x, y)
            self.cityhalls.append(o)
            self.game_group.add(o)
            self.animatedsprites.append(o)

        elif index == game.OBJ['police']:  # Police
            o = police.Police(x, y)
            self.game_group.add(o)
            self.animatedsprites.append(o)
            o.set_starting_dir(self.road_grid)

        elif index == game.OBJ['soldier']:  # Soldier
            o = soldier.Soldier(x, y)
            self.game_group.add(o)
            self.animatedsprites.append(o)
            o.set_starting_dir(self.road_grid)

        elif index == game.OBJ['start']:  #Starting tile
            o = starttile.StartTile(x, y)
            self.game_group.add(o)
            self.animatedsprites.append(o)

        elif index == game.OBJ['celltower']:
            o = celltower.CellTower(x, y)
            self.game_group.add(o)
            self.animatedsprites.append(o)

        elif index == game.OBJ['tank']:
            o = tank.Tank(x, y)
            self.game_group.add(o)
            self.animatedsprites.append(o)
            self.tanks.append(o)
            o.set_starting_dir(self.road_grid)

        self.object_grid[y][x] = o