pygame

Im making a simple TicTacToe in pyjama but I am running into some errors

ε祈祈猫儿з 提交于 2021-02-10 18:29:23
问题 The draw Board functions has an if statement to see which colour circle it should draw. But when the mouse button is clicked it draws the circle in the right x coordinate but in the opposite y coordinate. Also, the end is a little bit weird I want to display the winner and then wait using time.wait but it waits and then prints the statement for a second. If you could run it, you would understand. I am also looking for general improvements that I could make. import pygame, sys import numpy as

Making an object move in an orbit when I have the x and y coordinates

匆匆过客 提交于 2021-02-10 14:53:23
问题 This code is mostly just the generic start up of a pygame window but I'm trying to make it so the object moves (the planet object I've made) in the orbit around the sun object I've made for the coordinates I've given it. I know the x and y values are updating but I don't understand why the object doesn't move. #import the library import pygame import math #classes class button: def _init_ (self,screen, colour, x, y, width,height, letter): self.screen = screen self.colour = colour self.x = x

Making an object move in an orbit when I have the x and y coordinates

我的未来我决定 提交于 2021-02-10 14:53:06
问题 This code is mostly just the generic start up of a pygame window but I'm trying to make it so the object moves (the planet object I've made) in the orbit around the sun object I've made for the coordinates I've given it. I know the x and y values are updating but I don't understand why the object doesn't move. #import the library import pygame import math #classes class button: def _init_ (self,screen, colour, x, y, width,height, letter): self.screen = screen self.colour = colour self.x = x

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

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

落花浮王杯 提交于 2021-02-10 14:23:20
问题 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

Pygame fade to black function

妖精的绣舞 提交于 2021-02-10 13:43:17
问题 I'm coding a game in python 3 using pygame latest version. I have a function that is intended to slowly fade the screen until it is totally black. It should do so by blitting a low-alpha black surface many times on the screen. But when I test it, it only blocks the game until the loop is finished. I suspect a problem with the alpha of black_surface. I've seen some questions on forums about fade in pygame, but none of them concerned fade directly in functions. Here is the code: def fade_to

How to fix Arabic/Persian text and font in pygame?

我是研究僧i 提交于 2021-02-10 12:44:54
问题 I have this piece of code right here: import pygame pygame.display.init() pygame.font.init() win = pygame.display.set_mode((100, 100)) font = pygame.font.Font('./arial.ttf', 10) text = font.render('سلام', True, (255, 255, 255)) win.fill((0, 0, 0)) win.blit(text, (0, 0)) pygame.display.update() for i in range(5): pygame.event.clear() pygame.time.delay(1000) pygame.quit() What I expect: سلام What I get: س‌ل‎ا‌م How to fix it? (I don't care if I need to use another library to fix it, But I must

How to fix Arabic/Persian text and font in pygame?

被刻印的时光 ゝ 提交于 2021-02-10 12:44:46
问题 I have this piece of code right here: import pygame pygame.display.init() pygame.font.init() win = pygame.display.set_mode((100, 100)) font = pygame.font.Font('./arial.ttf', 10) text = font.render('سلام', True, (255, 255, 255)) win.fill((0, 0, 0)) win.blit(text, (0, 0)) pygame.display.update() for i in range(5): pygame.event.clear() pygame.time.delay(1000) pygame.quit() What I expect: سلام What I get: س‌ل‎ا‌م How to fix it? (I don't care if I need to use another library to fix it, But I must

How to fix Arabic/Persian text and font in pygame?

一个人想着一个人 提交于 2021-02-10 12:44:31
问题 I have this piece of code right here: import pygame pygame.display.init() pygame.font.init() win = pygame.display.set_mode((100, 100)) font = pygame.font.Font('./arial.ttf', 10) text = font.render('سلام', True, (255, 255, 255)) win.fill((0, 0, 0)) win.blit(text, (0, 0)) pygame.display.update() for i in range(5): pygame.event.clear() pygame.time.delay(1000) pygame.quit() What I expect: سلام What I get: س‌ل‎ا‌م How to fix it? (I don't care if I need to use another library to fix it, But I must