pygame

What all things happens inside pygame when I press a key? When to use pygame.event==KEYDOWN

风流意气都作罢 提交于 2020-11-25 03:44:33
问题 I have been trying to code a small 2D game using python. checkp_list[0]=head_pos pressed_key= pygame.key.get_pressed() if pressed_key[pygame.K_ESCAPE]: running=False if pressed_key[pygame.K_UP]: if dir_ not in ["up", "down"]: dir_= "up" checkp_no= checkp_no+1 #head_pos_next=head_move(head_pos, dir_) checkp_list.insert(checkp_no,head_pos) log_file_obj.write("chekp_list {}, checkp_no {} after append dir {}\n".format(checkp_list,checkp_no,dir_)) if pressed_key[pygame.K_DOWN]: if dir_ not in ["up

Changing colour of a surface without overwriting transparency [duplicate]

牧云@^-^@ 提交于 2020-11-25 03:43:49
问题 This question already has answers here : Is it possible to change sprite colours in Pygame? (1 answer) Trying to make sections of sprite change colour, but whole sprite changes instead (1 answer) Closed 17 days ago . I want to change the colour of a rect dynamically during runtime. Currently set_colour is filling all of the pixels of the surface with a single colour value. This works, but an issue arises when a method like set_outline is called, which modifies the transparency of the surface.

How to allow the user to type only under certain conditions in pygame? [duplicate]

落爺英雄遲暮 提交于 2020-11-25 03:41:38
问题 This question already has answers here : How to create a text input box with pygame? (4 answers) Closed 25 days ago . When you click the textbox I want the user to be able to type letters by setting self.active to True. When you click off the text box I want the player to lose that ability by setting self.active to False. However when I click the text box, self.active becomes true for a split second before becoming False again. How do I fix this? from pygame import * init() screen = display

How to draw a moving circle in Pygame with a small angle at a low speed and blinking?

二次信任 提交于 2020-11-25 03:31:31
问题 The code below moves two balls on the screen. The first one is moved with an angle of 10 degree at a low speed with a good drawing quality. The second ball is moved with an angle of 1 degree and in order for the angle to be respected, the speed must be much higher and the drawing is unsatisfactory with a lot of blinking. Is there a way to slow down the drawing of the second ball and avoid the excessive blinking ? import pygame, sys, math from pygame.locals import * pygame.init() DISPLAYSURF =

How to draw a moving circle in Pygame with a small angle at a low speed and blinking?

怎甘沉沦 提交于 2020-11-25 03:30:25
问题 The code below moves two balls on the screen. The first one is moved with an angle of 10 degree at a low speed with a good drawing quality. The second ball is moved with an angle of 1 degree and in order for the angle to be respected, the speed must be much higher and the drawing is unsatisfactory with a lot of blinking. Is there a way to slow down the drawing of the second ball and avoid the excessive blinking ? import pygame, sys, math from pygame.locals import * pygame.init() DISPLAYSURF =

Still Having Problems With Rotating Cannon's Properly Towards The Player Pygame

夙愿已清 提交于 2020-11-25 02:46:55
问题 few people have helped me with this problem before but the rotation is still messed up my Cannons wont rotate towards the player good they are all out of place I really need help with this problem its my first time trying to make something rotate towards a player I am trying to make my cannon mouth rotate towards player, but the rotation is messed up and up I don't know how to fix it. class enemyshoot: def __init__(self,x,y,height,width,color): # [...............] self.look_at_pos = (x,y) def

Still Having Problems With Rotating Cannon's Properly Towards The Player Pygame

自古美人都是妖i 提交于 2020-11-25 02:46:49
问题 few people have helped me with this problem before but the rotation is still messed up my Cannons wont rotate towards the player good they are all out of place I really need help with this problem its my first time trying to make something rotate towards a player I am trying to make my cannon mouth rotate towards player, but the rotation is messed up and up I don't know how to fix it. class enemyshoot: def __init__(self,x,y,height,width,color): # [...............] self.look_at_pos = (x,y) def

Still Having Problems With Rotating Cannon's Properly Towards The Player Pygame

只谈情不闲聊 提交于 2020-11-25 02:46:33
问题 few people have helped me with this problem before but the rotation is still messed up my Cannons wont rotate towards the player good they are all out of place I really need help with this problem its my first time trying to make something rotate towards a player I am trying to make my cannon mouth rotate towards player, but the rotation is messed up and up I don't know how to fix it. class enemyshoot: def __init__(self,x,y,height,width,color): # [...............] self.look_at_pos = (x,y) def

Still Having Problems With Rotating Cannon's Properly Towards The Player Pygame

会有一股神秘感。 提交于 2020-11-25 02:46:19
问题 few people have helped me with this problem before but the rotation is still messed up my Cannons wont rotate towards the player good they are all out of place I really need help with this problem its my first time trying to make something rotate towards a player I am trying to make my cannon mouth rotate towards player, but the rotation is messed up and up I don't know how to fix it. class enemyshoot: def __init__(self,x,y,height,width,color): # [...............] self.look_at_pos = (x,y) def

Still Having Problems With Rotating Cannon's Properly Towards The Player Pygame

纵饮孤独 提交于 2020-11-25 02:45:55
问题 few people have helped me with this problem before but the rotation is still messed up my Cannons wont rotate towards the player good they are all out of place I really need help with this problem its my first time trying to make something rotate towards a player I am trying to make my cannon mouth rotate towards player, but the rotation is messed up and up I don't know how to fix it. class enemyshoot: def __init__(self,x,y,height,width,color): # [...............] self.look_at_pos = (x,y) def