本文整理汇总了Python中shader.Shader.upload_player方法的典型用法代码示例。如果您正苦于以下问题:Python Shader.upload_player方法的具体用法?Python Shader.upload_player怎么用?Python Shader.upload_player使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shader.Shader
的用法示例。
在下文中一共展示了Shader.upload_player方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
# 需要导入模块: from shader import Shader [as 别名]
# 或者: from shader.Shader import upload_player [as 别名]
def render(self):
glClearColor(1,0,1,1)
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
with self.hpmeter as hud:
hud.clear((0.3,0,0,1))
hud.cr.identity_matrix()
hud.rectangle(0,0, hud.width, hud.height * self.player.hp_ratio, (0,0.3,0,1))
hud.cr.translate(18,0)
hud.cr.rotate(math.pi*0.5)
hud.text(' Energy: %d / %d' % (int(math.ceil(self.player.hp/10)) * 10, Player.max_hp), self.font2, color=(1,0.8,0,1))
with self.hud:
self.hud.clear((0,0,0,0))
self.hud.cr.identity_matrix()
t = pygame.time.get_ticks() / 1000.0
s = (t - self.texttime) / 4.0
if s > 1.0:
if len(self.textbuf) > 0:
self.texttime = pygame.time.get_ticks() / 1000.0
self.text = self.textbuf.pop(0)
else:
a = min(1.0-s, 0.2) * 5
self.hud.cr.translate(0,25)
self.hud.text(self.text, self.font, color=(1,0.8,0,a), width=self.hud.width, alignment=ALIGN_CENTER)
view = Matrix.lookat(
self.player.pos.x, self.player.pos.y+7, 15,
self.player.pos.x, self.player.pos.y+7, 0,
0,1,0)
with self.fbo as frame:
frame.clear(0,0.03,0.15,1)
Shader.upload_projection_view(self.projection, view)
Shader.upload_player(self.player)
self.shader.bind()
# parallax background
pm1 = Matrix.identity()
pm1[3,0] = self.player.pos.x * 0.35 - 20
pm1[3,1] = self.player.pos.y * 0.5 - 20
pm1[0,0] = 42.0 * self.parallax_rep
pm1[1,1] = 42.0
self.parallax.texture_bind()
Shader.upload_model(pm1)
self.repquad.draw()
Shader.upload_projection_view(self.projection, view)
self.map.draw()
# entities
for obj in self.map.pickups:
obj.draw(self.quad)
self.player.draw()
# parallax 2
pm1 = Matrix.identity()
pm1[3,0] = self.player.pos.x * -2.0 + 100
pm1[3,1] = self.player.pos.y * 0.5 - 45 * 3 + 10
pm1[0,0] = 45.0 * self.parallax_rep * 3
pm1[1,1] = 45 * 3
self.parallax2.texture_bind()
Shader.upload_model(pm1)
self.repquad.draw()
mat = Matrix.identity()
mat[0,0] = self.size.x
mat[1,1] = self.size.y
Shader.upload_projection_view(self.ortho, Matrix.identity())
Shader.upload_model(mat)
self.fbo.bind_texture()
self.herp.bind()
self.quad.draw()
# messagebox
mat = Matrix.identity()
mat[3,0] = self.size.x / 2 - self.hud.width / 2
mat[3,1] = self.size.y - self.hud.height
Shader.upload_model(mat)
self.hud.draw()
# hpmeter
mat = Matrix.identity()
mat[3,1] = self.size.y / 2 - self.hpmeter.height / 2
Shader.upload_model(mat)
self.hpmeter.draw()
Shader.unbind()
pygame.display.flip()