I am making a small game, and I want to make another window separate from my main one.
I have the main game in the main window, and I want to open a new window and make a little animation when the user does something.
In the code example below, when the user presses "a", I want him to open a new window and blit there.
Here I installed two windows: (I know that this does not work, its what I ask, how to do it)
SCREEN_X = 400 SCREEN_Y = 400 BSCREEN_X = 240 BSCREEN_Y = 160 BATTLE_SCENE = pygame.display.set_mode((BSCREEN_X, BSCREEN_Y)) SCREEN = pygame.display.set_mode((SCREEN_X, SCREEN_Y))
and then the program:
def run_ani (): #Do animation, blitting to BATTLE_SCENE return def main_game(): ending=False while ending==False: clock.tick(30) for event in pygame.event.get(): if event.type == pygame.QUIT: ending=True if event.type == KEYDOWN: # key down or up? if event.key == K_ESCAPE: ending=True # Time to leave print("Stopped Early by user") elif event.key == K_a: run_ani() #Normal screen motion, blitting to SCREEN if ending: pygame.quit() return
For now, he does the main screen, then when A is pressed, he stops drawing the main screen animation, but still draws other animations on the main screen and draws in the upper left corner.
I'm sure this is because I set BATTLE_SCENE
smaller than the main screen, so when blitting to BATTLE_SCENE
, it is close to the area I created (240x160) in the upper corner of the main screen.
However, I want BATTLE_SCENE
be a separate window, so when I press 'a' it pops up, does its job, then closes, or at least leaves the main screen.
How to do it? Is it possible?