當前位置: 首頁>>代碼示例>>Python>>正文


Python Sprite.x方法代碼示例

本文整理匯總了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)
開發者ID:Goggles,項目名稱:SideScroll,代碼行數:10,代碼來源:game.py

示例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)
開發者ID:MichaMucha,項目名稱:geoplotlib,代碼行數:10,代碼來源:core.py

示例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)
開發者ID:Goggles,項目名稱:SideScroll,代碼行數:12,代碼來源:game.py

示例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)	
開發者ID:Goggles,項目名稱:SideScroll,代碼行數:12,代碼來源:game.py

示例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) 
開發者ID:Goggles,項目名稱:SideScroll,代碼行數:13,代碼來源:game.py

示例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
開發者ID:ceronman,項目名稱:gamesbook,代碼行數:33,代碼來源:pong.py


注:本文中的pyglet.sprite.Sprite.x方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。