pygame

how to add a stopwatch to pygame?

为君一笑 提交于 2021-02-16 20:53:26
问题 I am making a game about falling circles and the player, which is basically a square, has to avoid them. The code is almost done but I have a problem with how to add a stopwatch to the game on the window? I have no idea where to put this type of code can anyone help me? I have all of the code done except for the stopwatch. import pygame from pygame.locals import * import os import random import math import sys import time white = (255,255,255) blue = (0,0,255) gravity = 10 size =10 height =

Pygame game help: Easing/Acceleration

房东的猫 提交于 2021-02-16 20:08:55
问题 Hi can someone help me with my pygame game, it's my first game and im really bad at this. Essentially im trying to make one of those sumo games where 2 players are on an icey ring (circle stage) and they have to push each other off to score points, im having trouble with the ice physics right now i understand that there has to be some type of acceleration when the key is held down and friction when it is released and im trying to do that right now but currently when the key is pressed it only

Is there a way to get the coordinates of a specific object/click in pygame?

烈酒焚心 提交于 2021-02-16 20:08:07
问题 I want to write a program where if I click, a circle is drawn on the pygame screen. If I click again, another circle is drawn as well as a line connecting it to the previous circle drawn. Is there any way to track the coordinates of where you last clicked? ps. I want to create like a star constellation effect after many clicks (to help you visualize) 回答1: Add a list for the mouse positions: points = [] Add the position to list when the mouse is clicked: if e.type == MOUSEBUTTONDOWN: if e

Where to put images folder in python exe?

时光总嘲笑我的痴心妄想 提交于 2021-02-16 18:35:47
问题 I have converted a python game I designed into an exe. Running the exe itself causes it to flash and then close, meaning an error has occured. Running it from the Command Prompt causes the error as well, but documents it: Cannot load image: Playfield.png Couldn't open images\Playfield.png This is telling me that the load_image block is failing. I have encountered this before when I did not have an images directory. I attempted to move the images folder to the dist directory. This is the error

how to make sprite move upwards and downwards with joystick in pygame

删除回忆录丶 提交于 2021-02-16 18:26:24
问题 I am trying to create a project that I have made before but apart from this time I am going to be using a play-station one remote I was given for free from my school. The problem that when I move the joystick upwards and downwards it shows the same coordinates.(If you do not understand what I mean then look at the picture below). Then also I am not sure what I wold need to put into the if statement so that it checks if the joystick is upwards or downwards. I am also having trouble thinking on

How to make transparent pygame.draw.circle [duplicate]

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-16 18:00:32
问题 This question already has answers here : Draw a transparent rectangle in pygame (5 answers) Closed 2 months ago . How to make pygame.draw.circle transparent (add alpha level), as for "surface" "set_alpha"? I found a solution only in changing the color of pygame.draw.circle to less bright 回答1: You've to use a pygame.Surface. Create a Surface with a per pixel alpha image format. e.g: radius = 100 circle = pygame.Surface((radius*2, radius*2), pygame.SRCALPHA) And draw a transparent circle on it.

pygame installation via pip

别来无恙 提交于 2021-02-16 15:20:16
问题 I'm trying to install pygame in my python 2.7. I do it in this python because for some reason if I try to install pip in python 3.7 it won't work. From the terminal I entered: sudo pip install pygame And supposedly I installed it well, but when I try to do the import it tells me: Traceback (most recent call last): File "example.py", line 1, in <module> import pygame ImportError: No module named pygame if i try to do again sudo pip install pygame : Requirement already satisfied: pygame in

Pygame : trying to understand the Sprite class

跟風遠走 提交于 2021-02-16 14:39:09
问题 I found on the Pygame documentation a class named Sprite . I read the explanation but I didn't understood what this class is used for. I understood that we were using it to inherit other classes with the constructor, but that's all. If someone has a clear explanation of the usefulness of the class, and how to use it well , I am interested. 回答1: Right, so move your mouse cursor around. That's a Sprite. It's a square bitmap, with some transparency. But only the visible parts mean anything - you

What Does The antialias mean in this Font render code for pygame mean?

£可爱£侵袭症+ 提交于 2021-02-16 14:21:46
问题 class Score(pygame.Surface): pygame.font.Font.render(Text, antialias, color, Background) I am trying to make a code that will implement a Text file that gets on to my pygame surface. I want It to show up on the top right hand corner of the screen. My issue is that i have no understanding what the antialias does and what do I put on the antialias code spot. Do I put an Int or some sort of String. Here is more of the code to show just to give you an idea of what i'm going for. I hope this helps

Embed a .wav file in Python with pyinstaller

那年仲夏 提交于 2021-02-16 14:12:53
问题 This is the code I am running: import tkinter from pygame import mixer root = tkinter.Tk() mixer.init() mixer.music.load(r'C:\Users\George\AppData\Local\Programs\Python\Python36-32\Scripts\Music\Am_lie_-_JY_Suis_Jamais_All_-Yann_Tiersen.wav') mixer.music.play() root.mainloop() I convert this to windows .exe with py2exe giving: pyinstaller -w -F -i "C:\Users\George\AppData\Local\Programs\Python\Python36-32\Scripts\test.ico" sound.py What I want to do is make the wav file embedded in the python