pygame

Pygame collision detection not working how I want it to

非 Y 不嫁゛ 提交于 2019-12-31 04:24:27
问题 Collisions are not working the way I want them to. I want it so that whenever you hit a boat, you are sent back to MENUSTATE, and whenever you hit a fish, the image disappears and the game keeps running. From what I've tried, the game will go back to MENUSTATE after a boat collision for as long as the two objects are still colliding, but will go back to GAMESTATE when it's done. How can I have it so it permanently stays in the MENUSTATE after a collision with the boat, and how would I go

How to rotate an image(player) to the mouse direction?

此生再无相见时 提交于 2019-12-31 04:01:08
问题 Im thinking about making a 2d shooting game in pygame and i want to make my player(Player_1) point to the mouse direction.I looked for a solution for hours and tried all solution i could find but none had worked so can you pls help me ? Here's my code: import pygame, sys, os from pygame.locals import * os.environ['SDL_VIDEO_CENTERED'] = '1' pygame.init() #Exit settings def quit(): pygame.quit() sys.quit() def events(): for event in pygame.event.get(): if event.type == QUIT or (event.type ==

Puzzled by my sprite's unequal +/ - velocity

♀尐吖头ヾ 提交于 2019-12-31 02:59:04
问题 I have two sprites in my game. The zombie sprite works perfectly, moving in all directions at a velocity of 1.0. My player sprite however, despite moves more slowly in the positive x/y direction, despite all values in all directions being 2.25. For the life of me I can't seem to see what is wrong here. Full working code: import pygame import random import sys import itertools import math import time from datetime import datetime from librarymodified import * from pygame.locals import * #

Creating multiple screens in pygame

痞子三分冷 提交于 2019-12-31 02:34:11
问题 Is there any way way to create multiple screens in Pygame without redrawing to the screen every time. For example, if we want to create a splash screen, then a main menu with buttons. On clicking the 'Start Game' button, it would go to a new screen which is the actual game. What I mean is anything similar to the 'Form' on Visual Studio or the Activites on Android. 回答1: Depends on what you mean. If you mean making multiple windows at the same time, no, you can't do that--it's a limitation of

Pygame with Multiple Windows

白昼怎懂夜的黑 提交于 2019-12-31 02:26:28
问题 I need to to build an application that has multiple windows. In one of these windows, I need to be able to play a simple game and another window has to display questions and get response from a user that influences the game. (1) I was wanting to use pygame in order to make the game. Is there a simple way to have pygame operate with multiple windows? (2) If there is no easy way to solve (1), is there a simple way to use some other python GUI structure that would allow for me to run pygame and

how do i get coordinates of image shown in opencv

时光毁灭记忆、已成空白 提交于 2019-12-31 01:25:26
问题 Sorry but title doesnt really make sense i am trying to make an ai that clicks on the ball to make it bounce. for context heres a picture of the application in the game when you click the ball it goes up and then comes back down and the aim of the game is to keep it up. i have writen some code that turns the image into a mask with opencv, heres a picture of the result what i now need to do is find the location of the ball in pixels/coordinates so i can make the mouse move to it and click it.

Pygame - Loading images in sprites

我们两清 提交于 2019-12-30 22:53:38
问题 How do I load an image into a sprite instead of drawing a shape for the sprite? Ex: I load a 50x50 image into a sprite instead of drawing a 50x50 rect Here is my sprite code so far: class Player(pygame.sprite.Sprite): def __init__(self, color, width, height): super().__init__() #Config self.image = pygame.Surface([width, height]) self.image.fill(WHITE) self.image.set_colorkey(WHITE) # Draw pygame.draw.rect(self.image, color , [0, 0, width, height]) # Fetch self.rect = self.image.get_rect()

Pygame - Loading images in sprites

佐手、 提交于 2019-12-30 22:52:07
问题 How do I load an image into a sprite instead of drawing a shape for the sprite? Ex: I load a 50x50 image into a sprite instead of drawing a 50x50 rect Here is my sprite code so far: class Player(pygame.sprite.Sprite): def __init__(self, color, width, height): super().__init__() #Config self.image = pygame.Surface([width, height]) self.image.fill(WHITE) self.image.set_colorkey(WHITE) # Draw pygame.draw.rect(self.image, color , [0, 0, width, height]) # Fetch self.rect = self.image.get_rect()

Pack program *and* dynamically loaded files into single executable? (python + pygame, or language agnostic)

拥有回忆 提交于 2019-12-30 14:41:05
问题 There are plenty of great answers to questions about making a standalone executable, but I can't figure out how to pack art assets (or dynamically loaded files) into it as well. Why would I want to do this? Because it would be great to distribute a simple (throw away) game that lives entirely in a single executable with no installer. As far as I can tell from searching, there are two basic approaches. 1) Avoid art assets in favor of content generation. I could have a program that turns a

Pack program *and* dynamically loaded files into single executable? (python + pygame, or language agnostic)

旧城冷巷雨未停 提交于 2019-12-30 14:40:30
问题 There are plenty of great answers to questions about making a standalone executable, but I can't figure out how to pack art assets (or dynamically loaded files) into it as well. Why would I want to do this? Because it would be great to distribute a simple (throw away) game that lives entirely in a single executable with no installer. As far as I can tell from searching, there are two basic approaches. 1) Avoid art assets in favor of content generation. I could have a program that turns a