This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# テクスチャの UV テーブル | |
spriteUV = ((0, 0, 0.125, 0.1875), | |
(0.125, 0, 0.125, 0.1875), | |
(0.25, 0, 0.125, 0.1875), | |
(0.375, 0, 0.125, 0.1875), | |
(0.5, 0, 0.125, 0.1875), | |
(0.625, 0, 0.125, 0.1875)) | |
# スプライト制御 | |
class PronamaChanSprite: | |
# 開始設定(今回の場合、x 座標の初期値だけ外部から指定する) | |
def setup(self, x): | |
self.x = x | |
self.y = random.random() | |
self.current_index = random.randint(0, len(spriteUV) - 1) | |
self.scale = 1 # テクスチャ画像のスケール(1倍にすると画面の縦幅の大きさで描画される) | |
# 更新処理(描画ごとに呼ばれる) | |
def update(self, aspect): | |
# スプライトインデックス更新 | |
self.current_index += 1 | |
if self.current_index >= len(spriteUV): | |
self.current_index = 0 | |
# 移動 | |
self.x -= 0.015 * aspect # 0.015 は移動量 | |
if self.x <= 0: | |
# 左側に移動したら位置を再設定 | |
self.setup(1 + self.scale * 0.125 * aspect) # 0.125 はテクスチャ内でのキャラの横幅 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment