本文整理汇总了Python中enemy.Enemy.draw方法的典型用法代码示例。如果您正苦于以下问题:Python Enemy.draw方法的具体用法?Python Enemy.draw怎么用?Python Enemy.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类enemy.Enemy
的用法示例。
在下文中一共展示了Enemy.draw方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MainWindow
# 需要导入模块: from enemy import Enemy [as 别名]
# 或者: from enemy.Enemy import draw [as 别名]
class MainWindow(window.Window):
def __init__(self, *args, **kwargs):
#Let all of the standard stuff pass through
window.Window.__init__(self, *args, **kwargs)
self.initGL()
self.bird = Bird()
self.world = World()
self.enemy = Enemy()
def initGL(self):
glClearColor(0.0, 0.0, 0.0, 0.0) # This Will Clear The Background Color To Black
glClearDepth(1.0) # Enables Clearing Of The Depth Buffer
glDepthFunc(GL_LESS) # The Type Of Depth Test To Do
glEnable(GL_DEPTH_TEST) # Enables Depth Testing
glShadeModel(GL_SMOOTH) # Enables Smooth Color Shading
glEnable(GL_TEXTURE_2D) # Enable Texture Mapping
glShadeModel(GL_SMOOTH) # Enable Smooth Shading
glClearColor(0.0, 0.0, 0.0, 0.5) # Black Background
glClearDepth(1.0) # Depth Buffer Setup
glEnable(GL_DEPTH_TEST) # Enables Depth Testing
glDepthFunc(GL_LEQUAL) # The Type Of Depth Testing To Do
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) # Really Nice Perspective Calculations
glLightfv(GL_LIGHT1, GL_AMBIENT, vec(*LightAmbient))
glLightfv(GL_LIGHT1, GL_DIFFUSE, vec(*LightDiffuse))
glLightfv(GL_LIGHT1, GL_POSITION, vec(*LightPosition))
glEnable(GL_LIGHT1)
glColor4f(1.0,1.0,1.0,0.5)
glBlendFunc(GL_SRC_ALPHA,GL_ONE)
def rotate_world(self):
# know bird.roty is off of (1,0)
ref_angle = self.bird.roty
point1=0
if (ref_angle >= 0 and ref_angle<=90):
point1 = math.atan(ref_angle * math.pi/180.0)
elif (ref_angle >= 90 and ref_angle<=180):
point1 = math.atan((180-ref_angle) * math.pi/180.0)
elif (ref_angle >= 180 and ref_angle<=270):
point1 = -math.atan((ref_angle-180) * math.pi/180.0)
else:
point1 = math.atan((ref_angle) * math.pi/180.0)
point2=0
if (ref_angle >= 0 and ref_angle<=90):
point2 = math.atan((90-ref_angle) * math.pi/180.0)
elif (ref_angle >= 90 and ref_angle<=180):
point2 = math.atan((90.0-ref_angle) * math.pi/180.0)
elif (ref_angle >= 180 and ref_angle<=270):
point2 = math.atan((ref_angle-270) * math.pi/180.0)
else:
# between -90 and 0
point2 = math.atan((ref_angle+90) * math.pi/180.0)
self.world.rotate(1, point2, -point1)
def animate_bird(self, interval):
self.bird.flap()
self.rotate_world()
self.enemy.move(45)
def update(self):
pass
def draw(self):
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glLoadIdentity()
glPushMatrix()
self.world.draw()
glPopMatrix()
glPushMatrix()
self.bird.draw()
glPopMatrix()
glPushMatrix()
self.enemy.draw()
glPopMatrix()
def main_loop(self):
clock.set_fps_limit(30)
clock.schedule_interval(self.animate_bird, 0.01)
while not self.has_exit:
self.dispatch_events()
self.clear()
self.update()
self.draw()
#Tick the clock
clock.tick()
self.flip()
#.........这里部分代码省略.........
示例2: World
# 需要导入模块: from enemy import Enemy [as 别名]
# 或者: from enemy.Enemy import draw [as 别名]
class World(object):
def __init__(self, main):
self.main = main
self.scr = self.main.scr
self.size = self.main.size
self.wsx = self.wsy = 0
self.vwsx = self.vwsy = 0
self.projectile = Projectile(self)
self.player = Player(self)
self.enemyC = Enemy(self)
self.effectC = Effect(self)
self.entitylist = []
self.bg = p.Color("black")
self.s1 = Slider(
{
"window": self.scr,
"pos": [500, 500, 50, 30],
"color": (0, 255, 200),
"color2": (255, 0, 55),
"colorindex": 100,
"steps": {"startpoint": 1, "endpoint": 10},
"font": {"size": 15, "clicksize": 20},
}
)
def restart(self):
self.__init__(self.main)
def shiftworld(self):
self.s1.pos[0] -= self.vwsx / 3.0
self.s1.pos[1] -= self.vwsy / 3.0
def update(self):
self.scr.fill(self.bg)
self.vwsx = self.player.vx
self.vwsy = self.player.vy
self.wsx += self.vwsx
self.wsy += self.vwsy
self.entitylist = [self.player] + [e for e in self.enemyC.opponentlist]
if self.main.holdingSpace:
self.player.shoot(
{
"dad": self.player,
"color": (0, 250, 100),
"colorindex": (0, 100, 50),
"angle": self.player.rotation,
"radius": 2,
"speed": 16,
"damage": 1.5,
"lifetime": 90,
"pos": self.player.pos,
}
)
self.player.update()
self.enemyC.update()
self.effectC.update()
self.projectile.udpate()
self.shiftworld()
Stars.update(self)
self.s1.update()
def draw(self):
Stars.draw()
self.s1.draw()
self.effectC.draw()
self.projectile.draw()
self.enemyC.draw()
self.player.draw()
Messages.message(self.scr, str(self.wsx) + " " + str(self.wsy), (10, 40), p.Color("magenta"))
Messages.message(self.scr, len(self.projectile.projectiles), (10, 70), p.Color("magenta"))
Messages.message(self.scr, self.enemyC.totaldied, (10, 100), p.Color("green"))