pygame

Assigning different palette indices to a paletted image

时光总嘲笑我的痴心妄想 提交于 2019-12-23 17:22:17
问题 I'm writing a game with Python and Pygame. For this, the graphics will be in the style of old video game consoles like the NES. Therefore, the graphics consist of a single tileset file with 2-bit (4-colour) images, and I want to be able to assign an arbitrary 4-colour palette to these images when loading them. What I want to do is use an 8-bit (256-colour) palette mode, with a palette that I have divided into 64 sub-palettes of 4 colours each. Every time I load a 16x16 tile from the 2-bit

Is there an online Python interpreter with the Pygame module? [closed]

泄露秘密 提交于 2019-12-23 15:14:41
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I was wondering if there is an online python interpreter with Pygame. It would be great if there is one, because when I share a game, I don't have to compile it first, I just send the code, and possibly upload the textures to a storage server and change the URL for the image location. Is there an online Python

Pygame event queue

…衆ロ難τιáo~ 提交于 2019-12-23 14:53:04
问题 I would like to know if there is a way of using poll() or get() without removing the events from the queue. In my game, I check input at different places (not only in the main loop) and sometimes I need to check the same event at different places but when i check it once it removes it from the queue. I tried using peek() but the problem is that I can't get the key corresponding to the event done. while 1: event = pygame.event.poll() if event.type == KEYDOWN: return event.key else: pass #works

Fully transparent windows in Pygame?

泄露秘密 提交于 2019-12-23 09:09:29
问题 Is it possible to get a fully transparent window in Pygame (see the desktop through it)? I've found how to create a window without a frame, but there doesn't seem to be any obvious way to make it transparent. I'd be willing to tie into system-specific technology/frameworks as long as there are solutions for both Windows and Mac OS X, but I'm not sure which direction to be looking. The only topic I was able to find recommended using wxPython, which isn't something I can do for this particular

How to invert colors of an image in pygame?

故事扮演 提交于 2019-12-23 07:56:39
问题 I have a pygame Surface and would like to invert the colors. Is there any way quicker & more pythonic than this? It's rather slow. I'm aware that subtracting the value from 255 isn't the only definition of an "inverted color," but it's what I want for now. I'm surprised that pygame doesn't have something like this built in! Thanks for your help! import pygame def invertImg(img): """Inverts the colors of a pygame Screen""" img.lock() for x in range(img.get_width()): for y in range(img.get

Save a list of objects on exit of pygame game [closed]

断了今生、忘了曾经 提交于 2019-12-23 06:12:44
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 years ago . So I have a list of defined classes that gets exported on the exit of the program.. and it looks like this: <__main__.Block object at 0x02416B70>, <__main__.Block object at 0x02416FF0>, <__main__.Block object at 0x0241C070>, <__main__.Block object at 0x0241C0D0>, <__main__.Block object at

Save a list of objects on exit of pygame game [closed]

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 06:12:30
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 years ago . So I have a list of defined classes that gets exported on the exit of the program.. and it looks like this: <__main__.Block object at 0x02416B70>, <__main__.Block object at 0x02416FF0>, <__main__.Block object at 0x0241C070>, <__main__.Block object at 0x0241C0D0>, <__main__.Block object at

Can this PyGame code run 60fps for >40 critters?

笑着哭i 提交于 2019-12-23 05:29:11
问题 In my other question, some of the posters asked to see the code and suggested I make a new question. As requested, here is most of the code I'm using. I've removed the Vector class, simply because it's a lot of code. It's well-understood math that I got from someone else (https://gist.github.com/mcleonard/5351452), and cProfile didn't have much to say about any of the functions there. I've provided a link in the code, if you want to make this run-able. This code should run, if you paste the

how do i determine a sprite's position in pygame?

扶醉桌前 提交于 2019-12-23 05:22:09
问题 I'm new to pygame and am making a zombie running game. I am controlling the human with the arrow keys and I would like to have a zombie run toward the player's position when the zombie is first created. I am unsure how to determine the players position to set the zombie in the correct direction. The zombie doesn't have to follow the human, just head in the direction of the players position when the zombie is created. class Human(pygame.sprite.Sprite): def __init__(self): pygame.sprite.Sprite.

hiding highscore text file in exe using py2exe/pygame2exe

ぃ、小莉子 提交于 2019-12-23 05:08:14
问题 I have a highscore system in my game that I made in Pygame , it saves name and score in text files name.txt and score.txt but the problem is that anyone can edit that text files.So could i hide them in exe file. python version 2.7 setup script: pygame2exe And if it's possible could I do it without extra modules. UPDATE:I'll obviously need to encrypt text somehow.Can you suggest some simple encryption alghoritham? Note that I use numbers and newlines . I would still want to put file in exe.