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


Python Sprite.y方法代码示例

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


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

示例1: fire

# 需要导入模块: from pyglet.sprite import Sprite [as 别名]
# 或者: from pyglet.sprite.Sprite import y [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)
开发者ID:Goggles,项目名称:SideScroll,代码行数:10,代码来源:game.py

示例2: sprites

# 需要导入模块: from pyglet.sprite import Sprite [as 别名]
# 或者: from pyglet.sprite.Sprite import y [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)
开发者ID:MichaMucha,项目名称:geoplotlib,代码行数:10,代码来源:core.py

示例3: background_2

# 需要导入模块: from pyglet.sprite import Sprite [as 别名]
# 或者: from pyglet.sprite.Sprite import y [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)
开发者ID:Goggles,项目名称:SideScroll,代码行数:12,代码来源:game.py

示例4: enemy

# 需要导入模块: from pyglet.sprite import Sprite [as 别名]
# 或者: from pyglet.sprite.Sprite import y [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)	
开发者ID:Goggles,项目名称:SideScroll,代码行数:12,代码来源:game.py

示例5: background_1

# 需要导入模块: from pyglet.sprite import Sprite [as 别名]
# 或者: from pyglet.sprite.Sprite import y [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) 
开发者ID:Goggles,项目名称:SideScroll,代码行数:13,代码来源:game.py

示例6: Window

# 需要导入模块: from pyglet.sprite import Sprite [as 别名]
# 或者: from pyglet.sprite.Sprite import y [as 别名]
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
paddle2.speed = 400
开发者ID:ceronman,项目名称:gamesbook,代码行数:32,代码来源:pong.py


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