当前位置: 首页>>代码示例>>Python>>正文


Python Vector.rotatey方法代码示例

本文整理汇总了Python中vector.Vector.rotatey方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.rotatey方法的具体用法?Python Vector.rotatey怎么用?Python Vector.rotatey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vector.Vector的用法示例。


在下文中一共展示了Vector.rotatey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Arrow

# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import rotatey [as 别名]
class Arrow(Protagonist):
    def __init__(self, texture, program, x, y, position, collisionMap, mesh):
        super(Arrow, self).__init__(texture, program, x, y, position, collisionMap, mesh)
        self.cooldown = 2.0
        self.maxSpeed = 20
        self.velocity = Vector(20.0, 0.0, 0.0)

    def update(self, delta, state):
        self.velocity = self.velocity * 0.99
        facingVelocity = self.velocity.rotatey(self.angle)
        movedBy = facingVelocity * delta
        if not self.collisionMap.collision(self.position + movedBy, self.x / 6):
            self.position = self.position + movedBy
            self.modelview = Matrix().translate(self.position.x, self.position.y, self.position.z) * Matrix().rotatey(
                -self.angle
            )
        else:
            self.velocity = self.velocity * 0.5

        self.cooldown -= delta
        if self.cooldown < 0:
            return False
        return True
开发者ID:seken,项目名称:nink,代码行数:25,代码来源:arrow.py

示例2: Protagonist

# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import rotatey [as 别名]
class Protagonist(object):
	def __init__(self, texture, program, x, y, position, collisionMap, mesh):
		super(Protagonist, self).__init__()
		self.tex = texture
		self.prog = program
		self.x = float(x)
		self.y = float(y)
		self.cooldown = 0.0
		self.collisionMap = collisionMap
		self.health = 100
		self.velocity = Vector(0.0, 0.0, 0.0)
		self.position = Vector(position[0], self.y/2, position[1])
		self.maxSpeed = 4
		self.modelview = Matrix().translate(position[0], self.y/2, position[1])
		self.moved = False
		self.angle = 0
		self.mesh = mesh
		with nested(self.tex):
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
	
	def update(self, delta, state):
		self.cooldown-= delta
		if self.moved:
			self.moved = False
		else:
			self.velocity = self.velocity * 0.8
			if self.velocity.len() < 0.1:
				self.velocity = Vector()
		facingVelocity = self.velocity.rotatey(self.angle)
		movedBy = facingVelocity * delta
		if not self.collisionMap.collision(self.position + movedBy, self.x/4):
			self.position = self.position + movedBy
			self.modelview = Matrix().translate(self.position.x, self.position.y, self.position.z) * Matrix().rotatey(-self.angle)
		
	def move(self, dvel):
		self.moved = True
		if self.velocity.len() == self.maxSpeed:
			return
		else:
			self.velocity = self.velocity + dvel
		if self.velocity.len() > self.maxSpeed:
			self.velocity.norm(self.maxSpeed)
			
	def teleport(self, x, y):
		self.position.x = x
		self.position.z = y
	
	def turn(self, angle):
		self.angle = self.angle + angle
		
	def point(self, angle):
		self.angle = angle
	
	def draw(self, projection, camera, player_position, r):
		self.prog.vars.mvp = projection * camera * self.modelview
		self.prog.vars.playerLight = r*0.1 + 0.9
		self.prog.vars.playerPosition = player_position.tuple()
		self.prog.vars.modelview = self.modelview
		with nested(self.prog, self.tex):
			self.mesh.draw(GL_QUADS)
			
	def hit(self):
		self.health -= 10
		
	def within(self, position):
		position = position - self.position
		
		for i in xfrange(0.0, 1.0, 0.05):
			point = self.position + (position * i)
			if self.collisionMap.collision(point, self.x/4):
				return False
		
		return True
		
	def depth(self, proj_cam):
		mat = proj_cam * self.modelview
		vector = mat.col(3)
		return -vector.z
		
开发者ID:seken,项目名称:nink,代码行数:81,代码来源:protagonist.py


注:本文中的vector.Vector.rotatey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。