コード例 #1
0
# -*- encoding: utf-8 -*-
'''
@File : 5_fight.py
@Time : 2020/04/14 20:22:04
@Author : xdbcb8 
@Version : 1.0
@Contact : [email protected]
'''

# here put the import lib

from Dog import Dog
from People import People
from random import randint

dog = [Dog(), Dog(), Dog()]
people = [People(), People()]


def choose_attact(a, b):
    # 判断游戏是否还可以进行下去
    flag1 = True
    flag2 = True
    for f in a:
        if f.get_blood() > 0 and f.get_attack() > 0:
            flag1 = False
    for s in b:
        if s.get_blood() > 0 and f.get_attack() > 0:
            flag2 = False

    if flag1:
コード例 #2
0
#int to make pathfinding slower.
patienceCounter = 0

dogImage = pygame.image.load('collie.png')
sheepImage = pygame.image.load('sheep.png')

#Make the Graph
graph = Graph()

#draw graph/obstacles
buildGates(graph)
buildObstacles(graph)

#Make the Player
dog = Dog(Constants.POSITION, Constants.PLAYER_MAX_SPEED, Constants.GET_SIZE,
          Constants.COLOR, dogImage)

#Make the Sheep
sheep_list = []
sheep = Sheep(
    Vector(random.randrange(int(bounds.x * .4), int(bounds.x * .6)),
           random.randrange(int(bounds.y * .6), int(bounds.y * .8))),
    Constants.SHEEP_SPEED, Constants.SHEEP_ANGULAR_SPEED,
    Vector(Constants.DOG_WIDTH,
           Constants.DOG_HEIGHT), (0, 255, 0), Constants.MAXTIME, sheepImage)
sheep_list.append(sheep)
'''for x in range(Constants.SHEEP_AMOUNT):
	sheep = Sheep(Vector(random.uniform(32,Constants.WORLD_WIDTH-32), random.uniform(32, Constants.WORLD_HEIGHT-32)),Constants.SHEEP_MAX_SPEED, Constants.GET_SIZE, Constants.SHEEP_COLOR, Constants.MAXTIME, sheepSurface)
	sheep_list.append(sheep)
'''
clock = pygame.time.Clock()
コード例 #3
0
ファイル: fight.py プロジェクト: vegetdove/learngit
 def __init__(self):
     self.humans = [Human(str(i)) for i in range(2)]
     self.dogs = [Dog(str(i)) for i in range(3)]
     self.cur.add('Human' if randint(0, 1) else 'Dog')