pygame-surface

How do I get the Mouse Position on a Pygame Scaled Surface?

社会主义新天地 提交于 2021-02-17 01:50:39
问题 The game I'm making blits everything onto a pygame.surface which is then scaled to the size of the user's display, maintaining aspect ratio, before the surface is then blitted to the main screen. The problem I'm having now, is that when I query the mouse position (because I want to do a hover effect on certain sprites), it's way off where the sprite is but the x and y match the sprite's coords. Is this because I've scaled the surface? And if so, is there a built-in Pygame method for assigning

How do I get the Mouse Position on a Pygame Scaled Surface?

眉间皱痕 提交于 2021-02-17 01:50:05
问题 The game I'm making blits everything onto a pygame.surface which is then scaled to the size of the user's display, maintaining aspect ratio, before the surface is then blitted to the main screen. The problem I'm having now, is that when I query the mouse position (because I want to do a hover effect on certain sprites), it's way off where the sprite is but the x and y match the sprite's coords. Is this because I've scaled the surface? And if so, is there a built-in Pygame method for assigning

How do I get the Mouse Position on a Pygame Scaled Surface?

大兔子大兔子 提交于 2021-02-17 01:48:46
问题 The game I'm making blits everything onto a pygame.surface which is then scaled to the size of the user's display, maintaining aspect ratio, before the surface is then blitted to the main screen. The problem I'm having now, is that when I query the mouse position (because I want to do a hover effect on certain sprites), it's way off where the sprite is but the x and y match the sprite's coords. Is this because I've scaled the surface? And if so, is there a built-in Pygame method for assigning

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

How can I make the ball move instead of stretch in pygame?

雨燕双飞 提交于 2021-02-13 05:42:25
问题 I'm building a pong game trying to get better at programming but Im having trouble moving the ball. When the move_right method is called the ellipse stretches to the right instead of moving to the right. I've tried putting the ball variable in the init method but that just makes it not move at all even though the variables should be changing on account of the move_right method. I have also tried setting the x and y positions as parameters in the Ball class,but that just stretches it also. I

Is there a way to place number on the center of the screen in pygame?

走远了吗. 提交于 2021-02-13 05:41:25
问题 I am working with pygame, to display the score I have images from 0 to 9 and need to place them centralized, but i can't just put it in the middle because the size of the score can change, the only solution I found until now is to hardcode it for scores up to 9, then up to 99 etc like in the code below if len(str(self.value)) == 1: win.blit(self.imgs[self.value], ((x - self.imgs[self.value].get_width(), y))) elif len(str(self.value)) == 2: win.blit(self.imgs[int(str(self.value)[0])], (x -

How do I make the screen ignore the background color of some image?

馋奶兔 提交于 2021-02-12 09:22:31
问题 I'm using python 2.7, and I am currently working on a basic game in pyagme for my school work. I downloaded an image from google, and it has a background color and I know it's RGB. I remember that there is a method that makes the screen ignore this RGB for the picture (the picture will appear without the background color) but I don't remember it. import pygame WINDOW_WIDTH = 1200 WINDOW_LENGTH = 675 IMAGE = r'C:\Users\omero\Downloads\BattleField.jpg' PISTOL_IMAGE = r'C:\Users\omero\Downloads

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

Subsurface rect outside of surface area when using get_clip() in Pygame?

帅比萌擦擦* 提交于 2021-02-10 14:50:20
问题 I am currently working on a pygame, trying to animate my character so that as the player moves him the program will cycle through four sprite image subsurfaces. I already setup a class for this: import pygame from pygame.locaks import * class Prota: def __init__(self, sheet): self.sheet = pygame.image.load(sheet).convert_alpha() self.image_rect = self.sheet.get_rect() self.image_rect_h = (self.image_rect.height) #num of rows self.image_rect_w = (self.image_rect.width/16) #num of columns self

How to draw sprite on a sprite so that both of them will be seen in pygame [duplicate]

≯℡__Kan透↙ 提交于 2021-02-10 14:24:51
问题 This question already has answers here : How do I blit a PNG with some transparency onto a surface in Pygame? [duplicate] (4 answers) Closed 24 days ago . I have two sprites one of them is a tank sprite the other is a protection sprite. I want to draw the protection sprite on the tank sprite. The images of the sprites are as follows: When I draw the protection sprite on the tank sprite, the result is the following: Center of the protection sprite is empty (according to photoshop, I checked