本文整理汇总了Python中pyglet.sprite.Sprite.x方法的典型用法代码示例。如果您正苦于以下问题:Python Sprite.x方法的具体用法?Python Sprite.x怎么用?Python Sprite.x使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyglet.sprite.Sprite
的用法示例。
在下文中一共展示了Sprite.x方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fire
# 需要导入模块: from pyglet.sprite import Sprite [as 别名]
# 或者: from pyglet.sprite.Sprite import x [as 别名]
def fire(self):
"""Create a new bullet"""
bullet = Sprite(images['bullet'], batch=self.bullet_batch)
bullet.x = self.player.x + self.player.width
bullet.y = self.player.y + self.player.height / 2 - bullet.height / 2
self.bullets.append(bullet)
示例2: sprites
# 需要导入模块: from pyglet.sprite import Sprite [as 别名]
# 或者: from pyglet.sprite.Sprite import x [as 别名]
def sprites(self, image, x, y, scale=1.0):
from pyglet.sprite import Sprite
for i in range(len(x)):
sprite = Sprite(image, batch=self._batch)
sprite.x = x[i]
sprite.y = y[i]
sprite.scale = scale
self._sprites.append(sprite)
示例3: background_2
# 需要导入模块: from pyglet.sprite import Sprite [as 别名]
# 或者: from pyglet.sprite.Sprite import x [as 别名]
def background_2(self, dt):
"""Random stars created in back moving faster"""
fast_star = Sprite(images['star'], batch=self.fast_star_batch)
fast_star.y = random.uniform(0, self.height)
fast_star.x = self.width
fast_star.scale = random.uniform(0.2, 2)
self.fast_stars.append(fast_star)
示例4: enemy
# 需要导入模块: from pyglet.sprite import Sprite [as 别名]
# 或者: from pyglet.sprite.Sprite import x [as 别名]
def enemy(self, dt):
"""creates enemies """
enemy = Sprite(images['windows'], batch=self.enemy_batch)
enemy.y = random.uniform(0, self.width)
enemy.x = self.width
enemy.startX = enemy.x
enemy.startY = enemy.y
self.win_enemy.append(enemy)
示例5: background_1
# 需要导入模块: from pyglet.sprite import Sprite [as 别名]
# 或者: from pyglet.sprite.Sprite import x [as 别名]
def background_1(self, dt):
"""create random number of stars at random y co ordinates"""
#for star in self.star:
star = Sprite(images['star'], batch=self.star_batch)
star.y = random.uniform(0,self.width-2)
star.x = self.width
star.scale = random.uniform(0.2, 2)
self.stars.append(star)
示例6: Window
# 需要导入模块: from pyglet.sprite import Sprite [as 别名]
# 或者: from pyglet.sprite.Sprite import x [as 别名]
import math
from pyglet import app, resource, clock
from pyglet.media import Player
from pyglet.sprite import Sprite
from pyglet.text import Label
from pyglet.window import Window, key
window = Window()
MAX_BALL_SPEED = 500
INITIAL_BALL_SPEED = 400
ball_image = resource.image('images/ball.png')
ball = Sprite(ball_image)
ball.x = window.width / 2 - ball.width/2
ball.y = window.height / 2 - ball.width/2
ball.speed_x = INITIAL_BALL_SPEED
ball.speed_y = INITIAL_BALL_SPEED
PADDLE_MARGIN = 10
paddle_image = resource.image('images/paddle.png')
paddle1 = Sprite(paddle_image)
paddle1.x = PADDLE_MARGIN
paddle1.y = window.height / 2 - paddle1.height / 2
paddle1.speed = 400
paddle2 = Sprite(paddle_image)
paddle2.x = window.width - paddle2.width - PADDLE_MARGIN
paddle2.y = window.height / 2 - paddle2.height / 2