遊戲編程基礎day6

畫圓
pygame.draw.circle(畫在哪,線的顏色,圓心的座標,半徑,線寬=0(顏色全部填充))
畫矩形
pygame.draw.rect(畫在哪,線的顏色,矩形範圍(x,y,w,h),線寬=0(顏色全部填充))
畫多邊形
pygame.draw.polygon(畫在哪,線的顏色,多邊形多個頂點座標列表,width=0)
畫橢圓
pygame.draw.ellipse(畫在哪,線的顏色,矩形範圍(x,y,w,h),線寬=0

畫一條弧線

pygame.draw.arc(畫在哪,線的顏色,矩形範圍,起始弧度,終止弧度(0-2π),線寬=1)

遊戲動畫

import pygame
import math
pygame.init()
screen_obj = pygame.display.set_mode((600,700))
screen_obj.fill((255,255,255))
pygame.display.set_caption('遊戲動畫')
pygame.draw.circle(screen_obj,(0,255,0),(300,60),60)
pygame.display.flip()
circle_y = 60
num = 1
speed = 1
while 1:
    num += 1
    if num % 100 == 0:
        pygame.draw.circle(screen_obj,(255,255,255),(300, circle_y), 60)
        circle_y += speed
        pygame.draw.circle(screen_obj,(0, 255, 0), (300, circle_y), 60)
        if circle_y+60 == 700 :
            speed = -1
        elif circle_y == 60:
            speed = 1
        pygame.display.update()
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章