0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

pygameコピペ用

Last updated at Posted at 2022-04-09

基本的な部分


import pygame as pg, sys
pg.init()
# スクリーンセット
screen = pg.display.set_mode((800, 600))

##################
必要に応じて処理書く
##################

# 描画用のループ
while True:
    # スクリーンの背景色
    screen.fill(pg.Color("WHITE"))
    # 再描画
    pg.display.update()
  # 更新の速さ(1秒間に60回以下実行)
    pg.time.Clock().tick(60)
  
  # ウィンドウの閉じるを押したとき終了
    for event in pg.event.get():
        if event.type == pg.QUIT:
            pg.quit()
            sys.exit()

テキスト

pygame.font

# 引数(ファイル名, サイズ)
font = pg.font.Font(None, 300)
# 引数(テキスト, antialias, 色, (背景色))
text = font.render("Text Write", True, pg.Color("BLUE"))
# 引数(文字, 場所(x, y))
screen.blit(text, (100, 400))

四角、ライン、丸

pygame.rect

# 四角:引数(描画するスクリーン, 色, (x, y, 横幅, 縦幅))
pg.draw.rect(screen, pg.Color("RED"), (0, 0, 150, 150))
# ライン:引数(描画するスクリーン, 色, (開始位置x, 開始位置y), (終了位置x, 終了位置y), 太さ)
pg.draw.line(screen, pg.Color("GREEN"), (100, 100), (300, 300), 5)
# 丸:引数(描画するスクリーン, 色, (x, y, 横幅, 縦幅), 太さ)
pg.draw.ellipse(screen, pg.Color("GREEN"), (400, 400, 100, 100), 5)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?