Created
August 14, 2018 12:14
-
-
Save shiroutosan/afd2b7486f3ce39ca04a358da428e85c to your computer and use it in GitHub Desktop.
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
import pygame | |
from pygame.locals import * | |
import sys | |
from character import * | |
def main(): | |
pygame.init() #pygameを初期化 | |
screen = pygame.display.set_mode((400,320)) #画面サイズ800*640を生成,フルスクリーンで表示 | |
bfull = False # フルスクリーンかどうかのフラグ | |
pygame.display.set_caption("まめ") # タイトルバーに表示する文字 | |
mame = player(184,144,"./img/mame32.bmp") # プレイヤーのインスタンスを生成 | |
animcycle = 48 # アニメーション速度 | |
frame = 0 # フレーム番号 | |
direction = 0 # プレイヤーの向き(0:下 4:右 8上 12:左) | |
clock = pygame.time.Clock() | |
while (1): | |
screen.fill((100,100,255)) # ウィンドウ内の色の設定 | |
frame += 2 | |
clock.tick(120) | |
screen.blit(mame.imagelist[int(frame / animcycle) % 4],(mame.x,mame.y)) # 描画 | |
pressed_keys = pygame.key.get_pressed() # 押されたキーを取得 | |
"""フルスクリーン←→ウィンドウの切り替え""" | |
if pressed_keys[K_F2]: # F2キーの押下を検知 | |
if bfull: | |
screen = pygame.display.set_mode((400, 320)) | |
bfull = False # ウィンドウモードに切り替えてフラグをFALSE | |
else: | |
screen = pygame.display.set_mode((400, 320), FULLSCREEN) | |
bfull = True # フルスクリーンモードに切り替えてフラグをTRUE | |
pygame.display.update() # 画面の更新 | |
for event in pygame.event.get(): | |
if event.type == QUIT: # 閉じるボタンが押されたら終了 | |
pygame.quit() # Pygameの終了(画面を閉じる) | |
sys.exit() | |
if __name__=="__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment