- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用以下 setup.py:
from cx_Freeze import setup, Executable
exe = Executable(
script="stars.pyw",
)
setup(
executables = [exe]
)
构建以下 Pygame 示例:
import random, math, pygame
import pygame._view
from pygame.locals import *
#constants
WINSIZE = [640, 480]
WINCENTER = [320, 240]
NUMSTARS = 150
def init_star():
"creates new star values"
dir = random.randrange(100000)
velmult = random.random()*.6+.4
vel = [math.sin(dir) * velmult, math.cos(dir) * velmult]
return vel, WINCENTER[:]
def initialize_stars():
"creates a new starfield"
stars = []
for x in range(NUMSTARS):
star = init_star()
vel, pos = star
steps = random.randint(0, WINCENTER[0])
pos[0] = pos[0] + (vel[0] * steps)
pos[1] = pos[1] + (vel[1] * steps)
vel[0] = vel[0] * (steps * .09)
vel[1] = vel[1] * (steps * .09)
stars.append(star)
move_stars(stars)
return stars
def draw_stars(surface, stars, color):
"used to draw (and clear) the stars"
for vel, pos in stars:
pos = (int(pos[0]), int(pos[1]))
surface.set_at(pos, color)
def move_stars(stars):
"animate the star values"
for vel, pos in stars:
pos[0] = pos[0] + vel[0]
pos[1] = pos[1] + vel[1]
if not 0 <= pos[0] <= WINSIZE[0] or not 0 <= pos[1] <= WINSIZE[1]:
vel[:], pos[:] = init_star()
else:
vel[0] = vel[0] * 1.05
vel[1] = vel[1] * 1.05
def main():
"This is the starfield code"
#create our starfield
random.seed()
stars = initialize_stars()
clock = pygame.time.Clock()
#initialize and prepare screen
pygame.init()
screen = pygame.display.set_mode(WINSIZE)
pygame.display.set_caption('Stars')
white = 255, 240, 200
black = 20, 20, 40
screen.fill(black)
#main game loop
done = 0
while not done:
draw_stars(screen, stars, black)
move_stars(stars)
draw_stars(screen, stars, white)
pygame.display.update()
for e in pygame.event.get():
if e.type == QUIT or (e.type == KEYUP and e.key == K_ESCAPE):
done = 1
break
elif e.type == MOUSEBUTTONDOWN and e.button == 1:
WINCENTER[:] = list(e.pos)
clock.tick(50)
# if python says run, then we should run
if __name__ == '__main__':
main()
重要的是要说明我使用的是 Pygame 非官方版本:pygame-1.9.2pre.win-amd64-py3.3.exe
但脚本在编译前工作正常。
最佳答案
重新发布作为答案:
这是我们偶尔会看到的错误,但还没有抽出时间来修复。您可以通过在脚本中添加一行来解决它:
import re
关于python - cx_Freeze 不适用于 pygame(已尝试 "import pygame._view"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15595224/
运行在 py2exe 中编译的 exe 现在给我这个错误: C:\Users\digiholic\git\universalSmashSystem\main.exe\zipextimporter.py
我正在尝试分发我使用 pygame 制作的游戏。 我经历了似乎数百个 stackoverflow 问题和网上论坛的徒劳追逐,最终开始使用 pygame2exe 并且非常接近但出现 ImportErro
CGridView 小部件已经具有查看、更新、删除选项。但我在基于 jquery 移动的项目中使用 CListView 小部件,但在为删除选项创建 ajax 链接时遇到问题。不知道如何在 _view.
CGridView 小部件已经具有查看、更新、删除选项。但我在基于 jquery 移动的项目中使用 CListView 小部件,但在为删除选项创建 ajax 链接时遇到问题。不知道如何在 _view.
我正在尝试使用以下 setup.py: from cx_Freeze import setup, Executable exe = Executable( script="stars.pyw", )
我正在开发一个 Swift 应用程序,遇到了一个疯狂的奇怪问题。我有一个简单的 Storyboard View Controller 设置,它有 3 个 UIButtons 一个 UIImageVie
我一直在浏览关于这个错误的无数帖子: Undefined symbols for architecture i386: "_OBJC_IVAR_$_UIViewController._view",
嗨! Web 开发的新手,尤其是 couchdb。 现在我试图了解如何调用 View 。我通过基于 Simplest possible form found on Kan.so 的应用程序生成并提交到
这是我的代码的 MRE: import pygame pygame.init() screen = pygame.display.set_mode((800, 600)) screen.fill((2
我是一名优秀的程序员,十分优秀!