pygame自己的函数绘制三角形 填充纹理

文章描述了一个使用Python的pygame库创建动态图形并进行像素级操作的程序,包括多线程控制对象位置变化,以及实时更新屏幕像素。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在这里插入图片描述
在这里插入图片描述

import sys
import time,sched
from threading import Timer
import datetime
import numpy as np
import pygame
from pygame import surface
from pygame._sprite import Group
import threading
import math

class lu:
    def __init__(self):
        self.x = self
        self.y = self
        self.z = self
        self.x1 = self
        self.y1 = self
        self.color = self
        self.screen = self
        self.p = self

    def zhuanhuan(self, x, y, z):
        shiju = 300
        self.x1 = shiju * x / z
        self.y1 = shiju * y / z
        # p3.append((self.x1, self.y1))
        # pygame.draw.polygon(screen, (0, 244, 0), self.p)
        # return (self.x1,self.y1)


pygame.init()  # 初始化pygame
size = width, height = 1100, 900  # 设置窗口大小
screen = pygame.display.set_mode(size)  # 显示窗口
color = (255, 255, 255)

f = False

fcclock = pygame.time.Clock()



# for i in range(6):
h1 = lu()
h1.x = 0
h1.y = 0
h1.width = 662
h1.height = 35
h1.screen = screen


p3 = []


z = [{
   'x1': 114, 'y1': 140, 'z1': 150}, {
   'x1': 594, 'y1': 11, 'z1': 350}, {
   'x1': 700, 'y1': 280, 'z1': 450},
     ]
#ax=70
#ay=580
#bx=160
#by=300
#cx=200
#cy=580
image = pygame.image.load("1.png")
img=pygame.image.load("1.png").convert_alpha()

def huizhi(x, y, z):
    shiju = 300
    x1 = shiju * x / z
    y1 = shiju * y / z
    # p.append((x1,y1))
    return x1, y1



zhuan=False
ax=0
ay=0
by=0
bx=0
cx=
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值