Exemplo n.º 1
0
    def __init__(self, parent, pos=(0, 0), vel=(0, 0), screenBoundaries=None):
        boulderPath = pathJoin(('images', 'boulder.png'))
        boulderImage = self.imageCache.getImage(boulderPath,
                                                colorkey='alpha',
                                                mask=True)

        GameObject.__init__(self, boulderImage, parent, pos, vel)

        self.minXPos = screenBoundaries[0] + self.rect.width / 2
        self.maxXPos = screenBoundaries[2] - self.rect.width / 2

        if self.position[0] < self.minXPos:
            self.moveTo((self.minXPos, self.position[1]))
        elif self.position[0] > self.maxXPos:
            self.moveTo((self.maxXPos, self.position[1]))
        self.moveTo(
            (self.position[0], self.position[1] - self.rect.height / 2))

        self.mask = self.imageCache.getMask(boulderPath)
        if screenBoundaries == None:
            raise Exception('Boulders must have screen boundaries')
        self.boundaries = screenBoundaries
        self.acceleration = (0, .001)
        self.damage = 5  #Damage done to ship when it hits
        self.value = 5  #How many points the boulder is worth
Exemplo n.º 2
0
 def __init__(self,gameScene,x,y):
    GameObject.__init__(self,gameScene,x,y,16,16)
    
    self.direction = "right"
    self.img = "stationary"
    
    #Flag indicating if the player is in mid air
    self.jumping = True
    
    #The number of renders until the animation is updated
    self.animationTick = TICKS_BETWEEN_ANIM_FRAMES
    
    #The current frame of the animation
    self.animationFrame = 0
    
    #x and y speeds
    self.xspeed = 0.0
    self.yspeed = 0.0
    
    #The accurate x and y locations
    self.x = x
    self.y = y
    
    #Colours
    self.colour = (255,0,0) #active colour
    self.rColour1 = (0,255,0) #reserve colour 1
    self.rColour2 = (0,0,255) #reserve colour 2
Exemplo n.º 3
0
    def __init__(self, gameScene, x, y):
        GameObject.__init__(self, gameScene, x, y, 16, 16)

        self.direction = "right"
        self.img = "stationary"

        #Flag indicating if the player is in mid air
        self.jumping = True

        #The number of renders until the animation is updated
        self.animationTick = TICKS_BETWEEN_ANIM_FRAMES

        #The current frame of the animation
        self.animationFrame = 0

        #x and y speeds
        self.xspeed = 0.0
        self.yspeed = 0.0

        #The accurate x and y locations
        self.x = x
        self.y = y

        #Colours
        self.colour = (255, 0, 0)  #active colour
        self.rColour1 = (0, 255, 0)  #reserve colour 1
        self.rColour2 = (0, 0, 255)  #reserve colour 2
Exemplo n.º 4
0
 def __init__(self, location, angle):
   GameObject.__init__(self,
     './images/laser.png',
     location,
     angle,
     10)
   self.time = 60
	def __init__(self, world, parent, color, pos, dir, radius, density, posParent=None):
		GameObject.__init__(self, world)

		self.node = parent.attachNewNode("")
		if posParent == None:
			self.node.setPos(*pos)
		else:
			self.node.setPos(posParent, *pos)
		self.node.setColor(*color)
		self.node.setScale(radius)
		self.node.lookAt(self.node, *dir)
		self.parent = parent

		self.color = color
		self.scale = radius

		self.model = loader.loadModel("models/smiley.egg")
		self.model.reparentTo(self.node)

		self.mass = OdeMass()
		self.mass.setSphere(density, radius)
		self.body = OdeBody(world.world)
		self.body.setMass(self.mass)
		self.body.setPosition(self.node.getPos())
		self.body.setQuaternion(self.node.getQuat())
		self.body.setData(self)
		self.geom = OdeSphereGeom(world.space, radius)
		self.geom.setBody(self.body)
		world.space.setSurfaceType(self.geom, world.surfaces["sphere"])
Exemplo n.º 6
0
 def __init__(self, x1, y1, x2, y2, length):
     GameObject.__init__(self, 0, 0)
     self.x1 = x1
     self.y1 = y1
     self.x2 = x2
     self.y2 = y2
     self.length = length
     self.collider = False
Exemplo n.º 7
0
 def __init__(self, speed, location, image, direction=const.rightDir):
     self.direction = direction
     self.speed = speed
     GameObject.__init__(
         self,
         location,
         image
     )
Exemplo n.º 8
0
 def __init__(self, x, y, color, brain):
     GameObject.__init__(self, x, y, BIRD_RADIUS, BIRD_RADIUS, FALL_VELOCITY)
     self.color = color
     self.isFlapping = False
     self.flappingTime = 0
     self.brain = brain
     self.isAlive = True
     self.score = 0
     self.drawable = True
Exemplo n.º 9
0
	def __init__(self, name = "Fireball 1", position = (0.0, 20.0, -40.0), \
			orientation = (0.0, 180.0, 0.0), scale = 0.1, mass = 20, \
			velocity = (0.0, 0.0, 0.0), guid = None, sound = None):
		GameObject.__init__(self, "Fireball", name, position,
				orientation, scale, mass, velocity, guid)

		vertices, vnormals, f, self.vertexCount = \
				graphics.loadObj("data/model/Fireball.obj")
		self.verticesId, self.normalsId = \
				graphics.createVBO(self.data.type, vertices, vnormals)

		self.sound = sound
Exemplo n.º 10
0
    def __init__(self, type, name, position, orientation, scale, mass, objects, server=False, guid=None):
        self.objects = objects

        GameObject.__init__(self, type, name, position, orientation, scale, mass, (0.0, 0.0, 0.0), guid)

        self.intelligenceThread = None

        if server:
            return

        vertices, vnormals, f, self.vertexCount = graphics.loadObj(self.objPath())
        self.verticesId, self.normalsId = graphics.createVBO(self.data.type, vertices, vnormals)
Exemplo n.º 11
0
    def __init__(self, inputManganer):
        GameObject.__init__(self, 200, 100)
        self.width = 24
        self.height = 12
        self.speed = Vector(3, 0)
        self.inputManganer = inputManganer
        self.center = Vector(200, 100)
        self.check = True

        self.a = None
        self.b = None
        self.mid = self.center.addNew(self.speed.unit().mul(self.width / 2))
        self.run = True
Exemplo n.º 12
0
    def __init__(self, parent, pos=(0,0), vel=(0,0), screenBoundaries=None):

        shipPath = pathJoin(('images','ship.png'))
        shipImage = self.imageCache.getImage(shipPath, colorkey='alpha', mask=True)

        GameObject.__init__(self, shipImage, parent, pos, vel)
        self.targetPosition = pos
        self.mask = self.imageCache.getMask(shipPath)
        self.screenBoundaries = screenBoundaries
        self.health = 100
        self.score = 0
        if screenBoundaries != None:
            self.minXPos = screenBoundaries[0] + self.rect.width/2
            self.maxXPos = screenBoundaries[2] - self.rect.width/2
Exemplo n.º 13
0
	def __init__(self, name = "Player 1", position = (0.0, 20.0, -40.0), \
			orientation = (0.0, 180.0, 0.0), scale = 1.0, mass = 100, \
			guid = None, sound = None):
		GameObject.__init__(self, "player1", name, position,
				orientation, scale, mass, (0.0, 0.0, 0.0), guid)
		vertices, vnormals, f, self.vertexCount = \
				graphics.loadObj("data/model/player1.obj")
		self.verticesId, self.normalsId = \
				graphics.createVBO(self.data.type, vertices, vnormals)

		self.sound = sound

		self.can_jump = 0
		self.rotated = 0.0
Exemplo n.º 14
0
    def __init__(self, gameScene, x, y):
        GameObject.__init__(self, gameScene, x, y, 16, 16)
        self.direction = "right"
        self.img = "stationary-right"

        #flag used to stop movement at the beginning of a life
        self.inMotion = False

        #Non-rounded versions of the x and y
        self.x = x
        self.y = y

        #X and Y speeds
        self.xmov = 0
        self.ymov = 0
Exemplo n.º 15
0
 def __init__(self,gameScene,x,y):
    GameObject.__init__(self,gameScene,x,y,16,16)
    self.direction = "right"
    self.img = "stationary-right"
    
    #flag used to stop movement at the beginning of a life
    self.inMotion = False
    
    #Non-rounded versions of the x and y
    self.x = x
    self.y = y
    
    #X and Y speeds
    self.xmov = 0
    self.ymov = 0
Exemplo n.º 16
0
	def __init__(self, world, parent, color, pos, dir, size, density, unglueThreshold=None, shatterLimit=None, shatterThreshold=None):
		GameObject.__init__(self, world)

		if unglueThreshold == None: unglueThreshold = 20
		if shatterLimit == None: shatterLimit = 0
		if shatterThreshold == None: shatterThreshold = 30

		self.size = size
		self.density = density
		self.dir = dir
		self.parent = parent
		self.color = color = makeVec4Color(color)
		
		self.node = parent.attachNewNode("")
		self.node.setPos(*pos)
		self.node.setColorScale(color)
		self.node.setScale(*size)
		self.node.lookAt(self.node, *dir)

		self.model = loader.loadModel("models/box.egg")
		self.model.reparentTo(self.node)
		self.model.setScale(2.0)
		self.model.setPos(-1.0, -1.0, -1.0)

		self.applyTexture()

		self.mass = OdeMass()
		self.mass.setBox(density, Vec3(*size) * 2)
		self.body = OdeBody(world.world)
		self.body.setMass(self.mass)
		self.body.setPosition(self.node.getPos())
		self.body.setQuaternion(self.node.getQuat())
		self.body.setData(self)
		self.geom = OdeBoxGeom(world.space, Vec3(*size) * 2.0)
		self.geom.setBody(self.body)
		world.space.setSurfaceType(self.geom, world.surfaces["box"])

		# Adjust collision bitmasks.
		self.geom.setCategoryBits(GameObject.bitmaskBox)
		self.geom.setCollideBits(GameObject.bitmaskAll & ~GameObject.bitmaskTileGlued)

		# Tile, cement and shatter variables.
		self.tiles = []
		self.cements = []
		self.disableCount = 0
		self.unglueThreshold = unglueThreshold
		self.shatterLimit = shatterLimit
		self.shatterThreshold = shatterThreshold
Exemplo n.º 17
0
    def __init__(self, parent, pos=(0,0), vel=(0,0), id=0, screenBoundaries = None):
        fragmentPath = pathJoin(('images','fragments','fragment'+str(id)+'.png'))
        fragmentImage = self.imageCache.getImage(fragmentPath, colorkey='alpha', mask=False)

        rect = self.imageCache.getRect(fragmentPath)

        GameObject.__init__(self, fragmentImage, parent, pos, vel)

        if screenBoundaries == None:
            raise Exception('Boulders must have screen boundaries')
        self.boundaries = (screenBoundaries[0]-rect.width,
                           screenBoundaries[1]-rect.height,
                           screenBoundaries[2]+rect.width,
                           screenBoundaries[3]+rect.height)

        self.acceleration = (0,0.001)
Exemplo n.º 18
0
    def __init__(self, parent, pos=(0, 0), vel=(0, 0), screenBoundaries=None):

        shipPath = pathJoin(('images', 'ship.png'))
        shipImage = self.imageCache.getImage(shipPath,
                                             colorkey='alpha',
                                             mask=True)

        GameObject.__init__(self, shipImage, parent, pos, vel)
        self.targetPosition = pos
        self.mask = self.imageCache.getMask(shipPath)
        self.screenBoundaries = screenBoundaries
        self.health = 100
        self.score = 0
        if screenBoundaries != None:
            self.minXPos = screenBoundaries[0] + self.rect.width / 2
            self.maxXPos = screenBoundaries[2] - self.rect.width / 2
Exemplo n.º 19
0
	def __init__(self, world, parent, color, pos, dir, radius, density, posParent=None):
		GameObject.__init__(self, world)

		self.color = makeVec4Color(color)
		self.scale = radius
		self.collisionCount = 0

		diameter = 2 * radius
		length = 1.815 * diameter

		self.node = parent.attachNewNode("")
		if posParent == None:
			self.node.setPos(*pos)
		else:
			self.node.setPos(posParent, *pos)
		self.node.setColorScale(self.color)
		self.node.setTransparency(TransparencyAttrib.MAlpha)
		self.node.setScale(radius)
		self.node.lookAt(self.node, *dir)
		self.node.setHpr(self.node.getHpr() + Vec3(0, 270, 0))

		self.model = loader.loadModel("models/bullet.egg")
		self.model.reparentTo(self.node)
		self.model.setPos(-0.1, -0.1, 0.15)
		self.model.setScale(0.4)

		self.mass = OdeMass()
		self.mass.setCylinder(density, 3, radius, length)
		self.body = OdeBody(world.world)
		self.body.setMass(self.mass)
		self.body.setPosition(self.node.getPos())
		self.body.setQuaternion(self.node.getQuat())
		self.body.setData(self)
		self.body.setGravityMode(False)
		self.geom = OdeCylinderGeom(world.space, radius, length)
		self.geom.setBody(self.body)
		world.space.setSurfaceType(self.geom, world.surfaces["bullet"])

		# Adjust collision bitmasks.
		self.geom.setCategoryBits(GameObject.bitmaskBullet)
		self.geom.setCollideBits(GameObject.bitmaskAll & ~GameObject.bitmaskCharacter)

		# Keep the bullet hidden for a split second so it doesn't appear too close to the camera.
		self.node.hide()
		taskMgr.doMethodLater(0.1, self.showTask, 'show-bullet')
Exemplo n.º 20
0
    def __init__(self, parent, pos=(0,0), vel=(0,0), screenBoundaries = None):
        boulderPath = pathJoin(('images','boulder.png'))
        boulderImage = self.imageCache.getImage(boulderPath, colorkey='alpha', mask=True)

        GameObject.__init__(self, boulderImage, parent, pos, vel)
        
        self.minXPos = screenBoundaries[0] + self.rect.width/2
        self.maxXPos = screenBoundaries[2] - self.rect.width/2
        
        if self.position[0] < self.minXPos:
            self.moveTo((self.minXPos, self.position[1]))
        elif self.position[0] > self.maxXPos:
            self.moveTo((self.maxXPos, self.position[1]))
        self.moveTo((self.position[0],self.position[1]-self.rect.height/2))
        
        self.mask = self.imageCache.getMask(boulderPath)
        if screenBoundaries == None:
            raise Exception('Boulders must have screen boundaries')
        self.boundaries = screenBoundaries
        self.acceleration = (0,.001)
        self.damage = 5 #Damage done to ship when it hits
        self.value = 5 #How many points the boulder is worth
    def __init__(self,
                 world,
                 parent,
                 color,
                 pos,
                 dir,
                 radius,
                 density,
                 posParent=None):
        GameObject.__init__(self, world)

        self.node = parent.attachNewNode("")
        if posParent == None:
            self.node.setPos(*pos)
        else:
            self.node.setPos(posParent, *pos)
        self.node.setColor(*color)
        self.node.setScale(radius)
        self.node.lookAt(self.node, *dir)
        self.parent = parent

        self.color = color
        self.scale = radius

        self.model = loader.loadModel("models/smiley.egg")
        self.model.reparentTo(self.node)

        self.mass = OdeMass()
        self.mass.setSphere(density, radius)
        self.body = OdeBody(world.world)
        self.body.setMass(self.mass)
        self.body.setPosition(self.node.getPos())
        self.body.setQuaternion(self.node.getQuat())
        self.body.setData(self)
        self.geom = OdeSphereGeom(world.space, radius)
        self.geom.setBody(self.body)
        world.space.setSurfaceType(self.geom, world.surfaces["sphere"])
Exemplo n.º 22
0
    def __init__(self,
                 parent,
                 pos=(0, 0),
                 vel=(0, 0),
                 id=0,
                 screenBoundaries=None):
        fragmentPath = pathJoin(
            ('images', 'fragments', 'fragment' + str(id) + '.png'))
        fragmentImage = self.imageCache.getImage(fragmentPath,
                                                 colorkey='alpha',
                                                 mask=False)

        rect = self.imageCache.getRect(fragmentPath)

        GameObject.__init__(self, fragmentImage, parent, pos, vel)

        if screenBoundaries == None:
            raise Exception('Boulders must have screen boundaries')
        self.boundaries = (screenBoundaries[0] - rect.width,
                           screenBoundaries[1] - rect.height,
                           screenBoundaries[2] + rect.width,
                           screenBoundaries[3] + rect.height)

        self.acceleration = (0, 0.001)
Exemplo n.º 23
0
 def __init__(self, x, y, path):
     GameObject.__init__(self, x, y)
     self.box_collider = BoxCollider(5, 5)
Exemplo n.º 24
0
 def __init__(self):
     GameObject.__init__(
         self,
         Location(self.getRandomLocation(), self.getRandomLocation()),
         './images/food-image.png'
     )
Exemplo n.º 25
0
 def __init__(self):
     ''' target: 'player' lub 'enemy'. Określa z czym rakieta koliduje '''
     GameObject.__init__(self)
     self.__target = None       # W co powinna trafić. Możliwe wartości to: 'player' i 'enemy'
     self.__damage = 2          # Obrażenia zadawane przez rakietę
Exemplo n.º 26
0
 def __init__(self, location, image):
     GameObject.__init__(self, location, image)
Exemplo n.º 27
0
 def __init__(self, width, height):
     GameObject.__init__(self, 0, 0)
     self.width = width
     self.height = height
Exemplo n.º 28
0
 def __init__(self):
     GameObject.__init__(self)
Exemplo n.º 29
0
 def __init__(self,gameScene,x,y,colour):
    GameObject.__init__(self,gameScene,x,y,16,16,colour)
Exemplo n.º 30
0
 def __init__(self, x, y, w, h, color):
     GameObject.__init__(self, x, y, w, h)
     self.color = color
Exemplo n.º 31
0
 def __init__(self,gameScene,x,y):
    GameObject.__init__(self,gameScene,x,y,16,16)
Exemplo n.º 32
0
 def __init__(self, location, angle, speed, level):
     GameObject.__init__(self, './images/asteroid.png', location, angle,
                         speed)
     self.level = level
     self.health = level
Exemplo n.º 33
0
 def __init__(self,gameScene,x,y,colour):
    GameObject.__init__(self,gameScene,x,y,16,16,colour)
Exemplo n.º 34
0
 def __init__(self):
     GameObject.__init__(self, 400, 320)
     self.renderer = ImageRenderer(
         "/Users/apple/Desktop/ai:mlPr/carDrive/mapImages/map.png")
Exemplo n.º 35
0
 def __init__(self, x, y, id):
     GameObject.__init__(self, x, y, GRAPH_NODE_RADIUS, GRAPH_NODE_RADIUS)
     self.color = GRAPH_NODE_COLOR
     self.id = id
Exemplo n.º 36
0
    def __init__(self):
        GameObject.__init__(self, './images/player.png',
                            Location(screenX / 2, screenY / 2), Angle(0), 0)

        self.lives = 3
        self.health = 3
Exemplo n.º 37
0
 def __init__(self, gameScene, x, y):
     GameObject.__init__(self, gameScene, x, y, 16, 16)
Exemplo n.º 38
0
 def __init__(self, position, animationFrames, animationFrameRate=3):
     GameObject.__init__(self, position, animationFrames,
                         animationFrameRate)
Exemplo n.º 39
0
 def __init__(self): 
     t = choice(pData)
     GameObject.__init__(self, t.x, t.y)
     self.box_collider = BoxCollider(20, 20)
     self.renderer = ImageRenderer("/Users/apple/Desktop/ai:mlPr/carDrive/assets/images/point.png")
Exemplo n.º 40
0
 def __init__(self):
     GameObject.__init__(self)