기금넷 공식사이트 - 재경 문답 - 스파이게임

스파이게임

#!/usr/bin/env python

# -*- 코딩: utf-8 -*-

sys 가져오기

무작위 가져오기 randint, 시드

pygame 가져오기

from pygame.locals import *

SCREEN_X = 640

SCREEN_Y = 480

pygame.init()

def Convert_strs_to_color(color_list):

return Color(int(color_list[0]), int(color_list[1]), int(color_list[2]))

//원 그리기 방법

def draw_circle(surface, color):

radius = randint(10, 100 )

pos = (randint(반경, SCREEN_X-반경), randint(반경, SCREEN_Y-반경))

pygame.draw.circle(표면, 색상, 위치, 반경, 1 )

//직사각형을 그리는 방법

def draw_ectangle(surface, color):

height = randint(10, 100)

width = randint(20, 250)

left = randint(0, SCREEN_X-너비)

top = randint(0, SCREEN_Y-높이)

pygame .draw.lect(surface, color, (left, top, width, height), 1)

//그리기 방법

def draw_line(surface, color):

// p>

start_pos = (randint(0, SCREEN_X), randint(0, SCREEN_Y))

True:

end_pos = (randint(0, SCREEN_X), randint (0, SCREEN_Y))

# 같은 위치에 있지 않은지 확인하세요

if end_pos != start_pos:

break

영역 채우기

Surface.fill 메소드는 직사각형 영역을 색상으로 채울 수 있습니다. 예를 들어

surface.fill((255, 0, 0), (100, 200, 100, 100))

첫 번째 매개변수는 채워질 색상을 지정하고, 두 번째 매개변수 이 매개변수는 채워질 직사각형 영역을 지정합니다. 두 번째 매개변수를 지정하지 않으면 전체 표면이 채워집니다. 두 번째 매개변수는 채워질 영역을 제한합니다.

이 함수는 영향을 받은 표면적을 반환합니다.

/blog/static/483763592010386487676/