-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyGameBasic.py
More file actions
70 lines (49 loc) ยท 1.92 KB
/
pyGameBasic.py
File metadata and controls
70 lines (49 loc) ยท 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import pygame
pygame.init()
BLACK = (0,0,0)
WHITE = (255,255,255)
BLUE = (0,0,255)
GREEN = (0,255,0)
RED = (255,0,0)
PI = 3.141592653
#์๋ก์ด ์ฐฝ screen ํฌ๊ธฐ ์ ์ธ ๋ฐ display
size = (400,500)
screen = pygame.display.set_mode(size)
#๊ฒ์ ํ์ดํ ์ง์
pygame.display.set_caption("TEST GAME TITLE")
done = False
clock = pygame.time.Clock()
while not done:
for event in pygame.event.get(): #์ ์ ๊ฐ ์ด๋ค ํ๋์ ํ์ ๋
if event.type == pygame.QUIT: #์ ์ ํด๋ฆญ ์ ์ฐฝ ๋ซ๊ธฐ
done = True
screen.fill(WHITE)
#(0,0)์์ (100,100)์ผ๋ก ๋๊ป๋ 5
pygame.draw.line(screen,GREEN, [0,0], [100,100], 5)
#10๊ฐ๊ฒฉ์ผ๋ก y์ถ ๋๋ฆฌ๋ฉฐ (0,10,20,30,40,50,60,70,80,90)
for y_offset in range(0,100,10):
pygame.draw.line(screen,RED,[0,10 + y_offset], [100,110 + y_offset], 5)
#์ฌ๊ฐํ ๊ทธ๋ฆฌ๊ธฐ (ํ์ ์์ )
pygame.draw.rect(screen, GREEN, [0,400,500,100],0)
#์ 0,1,2,3 ์ด 4๊ฐ ๊ทธ๋ฆฌ๊ธฐ
for i in range(0,20,5):
pygame.draw.ellipse(screen, BLACK, [20,20+i,250,100],2)
#์์์ , ๋๋๋ ์ PI = 180
pygame.draw.arc(screen, BLACK, [20, 220, 250, 200], 0, PI/2,2)
pygame.draw.arc(screen, GREEN, [20, 220, 250, 200], PI / 2, PI, 2)
pygame.draw.arc(screen, BLUE, [20, 220, 250, 200], PI, 3 * PI / 2, 2)
pygame.draw.arc(screen, RED, [20, 220, 250, 200], 3 * PI / 2, 2 * PI, 2)
#์ผ๊ฐํ
pygame.draw.polygon(screen, BLACK, [[100, 100], [0, 200], [200, 200]], 5)
#๊ฐ์ฒด ์์ฑ(filename, size)
#font = pygame.font.SysFont('Calibri', 25, True, False)
font = pygame.font.SysFont(None, 25)
#(text, antialias, color) antialias -> true๋ฉด smooth edge
text = font.render("My text", True, BLACK)
screen.blit(text, [250, 250])
#๋์คํ๋ ์ด ๊ฐฑ์ ๋ฐ ํ๋ฉดํ์
pygame.display.flip()
#์ด๋น 60ํ๋ ์์ผ๋ก ์ ํ
clock.tick(60)
#ํ๋ก๊ทธ๋จ ์ข
๋ฃ
pygame.quit()