Exemplo n.º 1
0
	def __init__( self, pos, look, spin, damage ):
		TrackedEntity.__init__( self )
		Block.__init__( self, pos[0], pos[1], pos[2], 0.2 )
		self.set_color( (150, 150, 0, 0) )

		self.pos, self.spin = pos, spin
		self.vel = look * self.muzzle_velocity
		self.damage = damage

		self.coll = CollGeometry()
		self.coll.add_geometry( CollAABB( Vector3f(), Vector3f(.1, .1, .1) ) )
Exemplo n.º 2
0
	def __init__( self, pos, angles ):
		TrackedEntity.__init__( self )
		Block.__init__( self, pos[0], pos[1], pos[2], 0.1 )
		self.set_color( (0, 0, 100, 0) )

		pos, angles = numpy.array(pos), numpy.array(angles)
		self.vel = numpy.array((0., 0., 0.))
		self.grounded = False

		self.cstate = CharacterState( pos, angles )

		self.coll = CollGeometry()
		self.coll.add_geometry( CollAABB( Vector3f(), Vector3f(.1, .1, .1) ) )
Exemplo n.º 3
0
class World( Entity ):
	drawable = collidable = updatable = True
	server_sendable = True
	client_sendable = batchable = False
	def __init__( self ):
		self.bstate = BlockWorldState()
		self.bstate.random( 10 )
		self.batch = None
		self.coll = CollGeometry()

	def update( self, dt ):
		if not self.bstate.dirty:
			return

		self.coll = CollGeometry()
		self.bstate.dirty = False

		self.ground = Block( -50., -100., -50., 100. )
		self.ground.set_color( (100, 0, 0, 0) )
		self.coll.add_geometry( CollAABB(
			Vector3f( -50., -100., -50. ), Vector3f( 50., 0., 50. ) ) )

		self.blocks = [ self.ground ]
		for b in self.bstate.blocks:
			minx, minz, c = b
			b = Block( minx, 0., minz, 5. )
			b.set_color( (0, 100, c, 0) )

			self.coll.add_geometry( CollAABB(
				Vector3f( minx, 0., minz ), Vector3f( minx+5., 5, minz+5. ) ) )
			self.blocks.append( b )

		self.batch = Batch( self.blocks )

	def collision_geometry( self ):
		return self.coll

	def resolve( self, other, coll ):
		return other.resolve( self, coll )

	def state( self ):
		return self.bstate

	def draw( self ):
		if self.batch:
			self.batch.draw()
Exemplo n.º 4
0
	def update( self, dt ):
		if not self.bstate.dirty:
			return

		self.coll = CollGeometry()
		self.bstate.dirty = False

		self.ground = Block( -50., -100., -50., 100. )
		self.ground.set_color( (100, 0, 0, 0) )
		self.coll.add_geometry( CollAABB(
			Vector3f( -50., -100., -50. ), Vector3f( 50., 0., 50. ) ) )

		self.blocks = [ self.ground ]
		for b in self.bstate.blocks:
			minx, minz, c = b
			b = Block( minx, 0., minz, 5. )
			b.set_color( (0, 100, c, 0) )

			self.coll.add_geometry( CollAABB(
				Vector3f( minx, 0., minz ), Vector3f( minx+5., 5, minz+5. ) ) )
			self.blocks.append( b )

		self.batch = Batch( self.blocks )