pygame

Install pygame with anaconda on mac

感情迁移 提交于 2021-02-11 10:22:09
问题 I was having problems trying to install pygame on a mac where python was installed with anaconda. I searched in SO and no solution worked. But it seems I have worked it out (haven't checked yet throughly ) so I write it here 回答1: First, tlatorre does not have a Osx version it seems. So I did this: anaconda search -t conda pygame and you can see in the reply several places (including tlatorre) with pygame. You can see that tlatorre only has linux-64 version. Also quasiben seems to have a Osx

The method for the use of about pygame.sprite.groupcollide

怎甘沉沦 提交于 2021-02-11 08:45:01
问题 Look at this code (She may be a little long): #Begin import pygame from pygame.locals import * global x, y, picPath x, y, picPath = 100, 100, 'C:\\Pic\\' class Ball(pygame.sprite.Sprite): def __init__(self): pygame.sprite.Sprite.__init__(self) self.image = pygame.image.load(picPath + 'boll.png') self.image.set_colorkey(0xffffff, 0) self.rect = self.image.get_rect() def update(self, pos): screen.blit(self.image, pos) class Stone(pygame.sprite.Sprite): def __init__(self): pygame.sprite.Sprite._

Random systematic movement in pygame

こ雲淡風輕ζ 提交于 2021-02-11 06:18:37
问题 I am making a Covid simulator and need my balls to move around randomly. However, I want them to stay moving in the first random direction that the chose, and only chnage direction if it hits another cell or hits the wall. My current code is as follow: import random import pygame # --- constants --- (UPPER_CASE_NAMES) GREEN1 = (0, 255, 0) # Healthy cells RED = (255, 0, 0) # Infected cells GREEN2 = (0, 100, 0) # Healthy cells not susecptible BLACK = (0, 0, 0) # Dead cells WHITE = (255, 255,

Random systematic movement in pygame

廉价感情. 提交于 2021-02-11 06:18:26
问题 I am making a Covid simulator and need my balls to move around randomly. However, I want them to stay moving in the first random direction that the chose, and only chnage direction if it hits another cell or hits the wall. My current code is as follow: import random import pygame # --- constants --- (UPPER_CASE_NAMES) GREEN1 = (0, 255, 0) # Healthy cells RED = (255, 0, 0) # Infected cells GREEN2 = (0, 100, 0) # Healthy cells not susecptible BLACK = (0, 0, 0) # Dead cells WHITE = (255, 255,

How do I make image rotate with mouse python [duplicate]

廉价感情. 提交于 2021-02-11 04:31:23
问题 This question already has answers here : How to rotate an image(player) to the mouse direction? (2 answers) How do I rotate an image around its center using Pygame? (6 answers) How can you rotate an image around an off center pivot in Pygame (1 answer) Closed last month . So I have been trying to make it so my cannon image will rotate to where my mouse is, but the code I'm trying is buggy. My cannon dose not follow my mouse and I lose my other sprite when I put my rotating code, I have tried

How to test if a 2d point in pygame screen is part of a 3d object in PyOpenGL?

99封情书 提交于 2021-02-10 21:38:34
问题 I am making a game (RPG) in PyOpenGL which I have a crosshair. I want to check if a 3d object is in the crosshair (or detect if it is at a point), which is a 2d overlay. How can I do that? I tried to use screen.get_at() function, but it displays an error "Cannot call on OpenGL surfaces". Also, it is not good because it only detects a colour, not an object (although you can use the colour to determine an object, but what if there are several objects that have the same colour?). This is what I

How to test if a 2d point in pygame screen is part of a 3d object in PyOpenGL?

亡梦爱人 提交于 2021-02-10 21:38:06
问题 I am making a game (RPG) in PyOpenGL which I have a crosshair. I want to check if a 3d object is in the crosshair (or detect if it is at a point), which is a 2d overlay. How can I do that? I tried to use screen.get_at() function, but it displays an error "Cannot call on OpenGL surfaces". Also, it is not good because it only detects a colour, not an object (although you can use the colour to determine an object, but what if there are several objects that have the same colour?). This is what I

How to set waits for object in pygame without freezing other objects

故事扮演 提交于 2021-02-10 18:55:07
问题 Lets say I have class Truck. There are many instances of this class, on arrival to specific point instance should "unload" it's cargo - simply not move for N seconds, while other trucks should keep moving, unless they arrived to their unloading points. I do the stop part by setting movement vector to (0,0) and then resetting it back to original. But how to wait N seconds without freezing other cars? From what I've found so far I think I need to somehow apply pygame.time.set_timer , but it is

How to set waits for object in pygame without freezing other objects

空扰寡人 提交于 2021-02-10 18:52:06
问题 Lets say I have class Truck. There are many instances of this class, on arrival to specific point instance should "unload" it's cargo - simply not move for N seconds, while other trucks should keep moving, unless they arrived to their unloading points. I do the stop part by setting movement vector to (0,0) and then resetting it back to original. But how to wait N seconds without freezing other cars? From what I've found so far I think I need to somehow apply pygame.time.set_timer , but it is

Pygame - Collisions on the sides of a platform [duplicate]

非 Y 不嫁゛ 提交于 2021-02-10 18:43:41
问题 This question already has answers here : How do I detect collision in pygame? (4 answers) How to detect collisions between two rectangular objects or images in pygame (1 answer) Closed 4 days ago . I am currently trying to make my own platformer on pygame . I have coded the collisions for the top and bottom of the platform so that the player can only jump on top of the platform if they are falling onto it. However, if the player walks into the side of the platform, he snaps on top of it. How