美文网首页
PYGAME BASIC

PYGAME BASIC

作者: gaoljay | 来源:发表于2016-09-05 14:42 被阅读0次

Color:

red 0-255
green 0-255
blue 0-255

Coordinate:

(x, y)
x: from left to right
y: from top to bottom

Display String:

<pre>import pygame
import sys
from pygame.locals import *
</br>

initialization

pygame.init()
</br>

initial your screen

screen = pygame.display.set_mode((600,500))
</br>

initial the font you want to use--font, size

my_font = pygame.font.Font(None, 60)
</br>

set up colors

white = 255, 255, 255
blue = 0, 0, 255
</br>

set up text you want to write in your screen---string, alias, color

textImage = my_font.render("Hello Pygame", True, white)
</br>

how to draw

1. clean screen

2. draw it

3. display it in screen

</br>

screen.fill(blue)

screen.blit(textImage, (100, 100))

pygame.display.update()

</br>

add loop so it will not close

while True:
for event in pygame.event.get():
if event.type in (QUIT, KEYDOWN):
sys.exit()
screen.fill(blue)
screen.blit(textImage, (100, 100))
pygame.display.update()
</pre>

Draw a line:

 pygame.draw.line(screen, color, positionX1,positionX2, width)

Draw a circle:

 pygame.draw.circle(screen, color, position, radius, width)

Draw a rectangle:

position = 0, 0, 100, 100
pygame.draw.rect(screen, color, position, width)

Draw an arc:

position = 0, 0, 100, 100
pygame.draw.arc(screen, color, position, start_angle, end_angle, width)

wertyuiop[]

相关文章

  • PYGAME BASIC

    Color: red 0-255green 0-255blue 0-255 Coordinate: (x, y)x...

  • 2018-09-04-pygame

    一、pygame基本操作 import pygame——导入pygame模块 pygame.init()——初始化...

  • Pygame入门--飞机大战案例

    Pygame的快速入门 #导入pygame模块 import pygame #游戏初始化 pygame.init(...

  • Day_10 异常与pygame

    异常捕获 pygame操作流程 pygame显示文字 pygame显示图片与图片操作 pygame基本显示

  • Pygame-hello world

    使用pygame 模块名功能pygame.cdrom访问光驱pygame.cursors加载光标pygame.di...

  • pygame - alphabet

    pygame install pygame install[https://www.pygame.org/wiki...

  • Day12 pygame

    1.pygame基本操作: 1.导入pygame: import pygame.2.初始化:pygame init...

  • Day-18正则表达式2

    pygame游戏基本框架的创建 pygame中图片的显示 字体的显示 图形 Pygame Pygame有很多的模块...

  • day11-pygame笔记

    1pygame事件 import pygame pygame.display.set_caption('游戏事件'...

  • Python——Pygame模块

    学习资料: Pygame官网 pygame系列 PyGame - Python Wiki 用Python和Pyga...

网友评论

      本文标题:PYGAME BASIC

      本文链接:https://www.haomeiwen.com/subject/asurettx.html