Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>the best way to do something like that (that supports multiple levels) is thinking that "bif" is the variable of the map. So after input check the location of the hero (x, y) and if it's the value you want then change the map to the next level. Here is the code:</p> <pre><code>while True: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() if event.type==KEYDOWN: if event.key==K_a: movex=-1 elif event.key==K_d: movex=+1 elif event.key==K_w: movey=-1 elif event.key==K_s: movey=+1 if event.type==KEYUP: if event.key==K_a: movex=0 elif event.key==K_d: movex=0 elif event.key==K_w: movey=0 elif event.key==K_s: movey=0 x+=movex y+=movey #If you want hero to be on specific location - 100 and 50 are examples if x == 100 and y == 50: bif = pygame.image.load("nextMap.png") #If you want hero to be on a specific area if x &gt;= 100 and x &lt; 150 and y &gt;= 50 and y &lt; 100: bif = pygame.image.load("nextMap.png") #If you plan on making multiple levels you can try something like this if x == 100 and y == 50: stage += 1 big = loadStage(stage) #Where stage is the number of the currentLevel #and loadStage() is a method that according to the stage returns the currect stage #If you want you can also reset the x and y values to 0 or the starting position you want screen.fill((r,0,0)) screen.blit(bif,(0,0)) screen.blit(player,(x,y)) pygame.display.flip() </code></pre> <p>in case it helps you I'll write the "loadStage" as well</p> <pre><code>def loadStage(stageNumber): if stageNumber == 1: return pygame.image.load("map1.png") if stageNumber == 2: return pygame.image.load("map2.png") #Make it as long as you want </code></pre> <p>sorry I worked with python some years ago I might have some mistakes (probably with the language's rules) but I know how the logic works, I hope I explained everything clearly if not ask me!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload