源代码
import math,random,sys,time
import pygame
from pygame.locals import *
class Point(object):
def __init__(self,x,y):
self.__x=x
self.__y=y
#X property
def getx(self):
return self.__x
def setx(self,x):
self.__x=x
x=property(getx,setx)
#Y property
def gety(self):
return self.__y
def sety(self,y):
self.__y=y
y=property(gety,sety)
def __str__(self):
return "{X:"+"{:.0f}".format(self.__x)+",Y:"+"{:.0f}".format(self.__y)+"}"
#print_text function
def print_text(font,x,y,text,color=(255,255,255)):
imgText=font.render(text,True,color)
screen.blit(imgText,(x,y))
#warp_angle function
def warp_angle(angle):
return angle%360
#main program begins
pygame.init()
screen=pygame.display.set_mode((800,600))
pygame.display.set_caption("Orbiting_Spaceship