Answers for "hovering screen"

0

hovering screen

screen=pygame.display.set_mode((WINDOWWIDTH,WINDOWHEIGHT),32)

Map=pygame.image.load(os.path.join('Image','MAP.png')).convert_alpha()

startX,startY=0,0                   # starting coordinates for Map

while 1:
    screen.fill(white)
    screen.blit(Map,(startX,startY))

    for event in pygame.event.get():
        if event.type == MOUSEMOTION :
            mousepos=pygame.mouse.get_pos()

    if WINDOWHEIGHT-mousepos[1]<50:     # if  y-position of mouse is 50 pixel far from lower edge ..
        startY -= 5                     # ..move Map by 5 px
    if mousepos [1]<50:
        startY += 5
    if mousepos [0]<50 :
        startX += 5
    if WINDOWWIDTH - mousepos[0]<50:
        startX -= 5

    pygame.display.flip()
Posted by: Guest on February-25-2022

Code answers related to "hovering screen"

Browse Popular Code Answers by Language