ひろひろの生活日記(LIFE Of HIROHIRO)

パソコン講習とソフト開発をしています。自作小説も掲載しています。ネット情報発信基地(上野博隆)Hirotaka Ueno

pythonのコーディングを載せてみました。

2020年05月19日 05時43分20秒 | ゲーム開発(Game development)

コーディング掲載しました。

人形が回転します。

 

<pre><code>

# Blit test
import pygame

WIDTH = 640
HEIGHT= 480
BLUE  = (   0,   0, 255)
BLACK = (   0,   0,   0)
WHITE = ( 255, 255, 255)
pygame.init()
screen = pygame.display.set_mode((WIDTH,HEIGHT))
myfont = pygame.font.Font(None, 32)
myclock = pygame.time.Clock()
image1 = pygame.image.load("man.png").convert()

screen.fill(BLUE)
screen.blit(image1, (0, 0))

for i in range(9):
  angle = i * 45
  pos = (i * 64, 80)
  image2 = pygame.transform.rotate(image1,angle)
  screen.blit(image2, pos)
  pos = (i * 64, 140)
  image2.set_colorkey(BLACK)
  screen.blit(image2, pos)
  imagetext=myfont.render(str(angle),True,WHITE)
  postext = (i * 64, 190)
  screen.blit(imagetext, postext)

pygame.display.flip()
endflag = 0

while endflag == 0:
  for event in pygame.event.get():
    if event.type == pygame.QUIT: endflag = 1
  myclock.tick(60)

pygame.quit()

# Blit test
import pygame

WIDTH = 640
HEIGHT= 480
BLUE  = (   0,   0, 255)
BLACK = (   0,   0,   0)
WHITE = ( 255, 255, 255)
pygame.init()
screen = pygame.display.set_mode((WIDTH,HEIGHT))
myfont = pygame.font.Font(None, 32)
myclock = pygame.time.Clock()
image1 = pygame.image.load("man.png").convert()

screen.fill(BLUE)
screen.blit(image1, (0, 0))

for i in range(9):
  angle = i * 45
  pos = (i * 64, 80)
  image2 = pygame.transform.rotate(image1,angle)
  screen.blit(image2, pos)
  pos = (i * 64, 140)
  image2.set_colorkey(BLACK)
  screen.blit(image2, pos)
  imagetext=myfont.render(str(angle),True,WHITE)
  postext = (i * 64, 190)
  screen.blit(imagetext, postext)

pygame.display.flip()
endflag = 0

while endflag == 0:
  for event in pygame.event.get():
    if event.type == pygame.QUIT: endflag = 1
  myclock.tick(60)

pygame.quit()

</code></pre>


コメント    この記事についてブログを書く
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする
« ざわざわ病 | トップ | 体重2020年5月19日(73キロ) »
最新の画像もっと見る

コメントを投稿

ブログ作成者から承認されるまでコメントは反映されません。

ゲーム開発(Game development)」カテゴリの最新記事