pygame

how to make particles follow my mouse in pygame

≡放荡痞女 提交于 2021-01-27 18:10:30
问题 I'm trying to make sure that the particles that arise when I click my mouse follow my mouse. For some reason, the particles just follow me to the top left. Can anyone tell me what I am doing wrong? Here is my code: import pygame import sys import random import math from pygame.locals import * pygame.init() clock = pygame.time.Clock() screen = pygame.display.set_mode((500,500)) particles = [] while True: screen.fill((0,0,0)) for event in pygame.event.get(): if event.type == MOUSEBUTTONDOWN: mx

pygame.transform.scale does not work on the “game” surface

。_饼干妹妹 提交于 2021-01-27 17:40:31
问题 I am writing a program and I want to zoom in and out where the cursor is positioned. I have tried (maybe foolishly) to pygame.transform.scale2x the window (which is basically my whole window with the game so: window = pygame.display.set_mode((0, 0), pygame.FULLSCREEN) pygame.transform.scale2x(window) ) Is there any other solution? What am I doing wrong with the pygame.transform.scale2x (I reckon pygame.transform is just for images so how can I use it on a surface?)? It would be great if the

Pygame- detect if a key is held down?

蹲街弑〆低调 提交于 2021-01-27 14:33:15
问题 So I am doing a simple thing, and have been following a tutorial on youtube. I have the ability to move the banshee (I used an image from Halo for my ship) using WASD, but I have to repetitively tap keys, whereas I want to be able to move it by holding down the keys. Here's the code; import pygame from pygame.locals import * pygame.init() screen = pygame.display.set_mode((1440,900)) pygame.display.update() black=(0,0,0) white=(255,255,255) background = pygame.image.load("G:/starfield.jpg")#

PyGame: text not appearing

自闭症网瘾萝莉.ら 提交于 2021-01-27 14:10:17
问题 i was following a tutorial and i'm trying to get my text to appear in the screen, here is my code but the text won't appear: from __future__ import division import math import sys import pygame class MyGame(object): def __init__(self): pygame.mixer.init() pygame.mixer.pre_init(44100, -16, 2, 2048) pygame.init() self.width = 800 self.height = 600 self.screen = pygame.display.set_mode((self.width, self.height)) self.bg_color = 0, 0, 0 font = pygame.font.Font(None, 100) text = font.render("text

PyGame: text not appearing

十年热恋 提交于 2021-01-27 13:59:01
问题 i was following a tutorial and i'm trying to get my text to appear in the screen, here is my code but the text won't appear: from __future__ import division import math import sys import pygame class MyGame(object): def __init__(self): pygame.mixer.init() pygame.mixer.pre_init(44100, -16, 2, 2048) pygame.init() self.width = 800 self.height = 600 self.screen = pygame.display.set_mode((self.width, self.height)) self.bg_color = 0, 0, 0 font = pygame.font.Font(None, 100) text = font.render("text

Two different audio file playing on Left channel and right channel with pygame

六眼飞鱼酱① 提交于 2021-01-27 13:44:52
问题 I have a code where I specified two different audio files in two different channels and plays simultaneously, but I need a way to make each file play on only one channel and the other on the other channel. For instance, two audio files playing simultaneously on two seperate channels, Right and Left. Such that an audio plays on right speaker and the other audio plays on left speaker. I tried with the code below, but the audio is not mapping to any specific channel but are playing on both

Playing Videos in PyGame 2

谁说我不能喝 提交于 2021-01-27 12:52:11
问题 Pygame 1.x has a movie module which makes playing movies pretty straightforward. The internet is full of variations of the answer provided in this SO question However, I'm using Pygame 2, and it appears that the movie module has been removed. Or maybe just not implemented yet? I can't find a reference to it in the current docs, nor any examples online. I found this example of using pygame.Overlay with pymedia, but it appears that pymedia does not run on Python 3. I'm new to the Python

I tried to draw a rectangle in Pygame but the colour is flickering…why?

柔情痞子 提交于 2021-01-27 06:27:08
问题 So, I'm trying Pygame again (still a beginner), I tried to draw a rectangle, but the colour just flickers. (turquoise on orange surface) Why does this happen? Here's the snippet of code: from pygame import * from sys import * while True: init() for events in event.get(): if events.type == QUIT: quit() exit() SCREENWIDTH = 900 SCREENHEIGHT = 600 SCREENSIZE = [SCREENWIDTH, SCREENHEIGHT] SCREEN = display.set_mode(SCREENSIZE) bg_col = [255, 123, 67] s1_col = (0, 255, 188) SCREEN.fill(bg_col)

What exactly does pygame.display.set_mode() do?

空扰寡人 提交于 2021-01-27 04:50:38
问题 I've recently started to play around with the pygame python library and I just wanted to see if I was understanding something correctly: The following is some code that sets up the window. In the line that says: windowSurface = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT), 0, 32) , does display refer to a module inside of pygame and is set_mode the name of a class in that module? Is this correct? from pygame.locals import * # set up pygame pygame.init() # set up the window WINDOWWIDTH

What exactly does pygame.display.set_mode() do?

不问归期 提交于 2021-01-27 04:46:48
问题 I've recently started to play around with the pygame python library and I just wanted to see if I was understanding something correctly: The following is some code that sets up the window. In the line that says: windowSurface = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT), 0, 32) , does display refer to a module inside of pygame and is set_mode the name of a class in that module? Is this correct? from pygame.locals import * # set up pygame pygame.init() # set up the window WINDOWWIDTH