how can i code in pygame and move image selectivelly?
<p>i'm making a game by using pygame, and also tring to learn this. but i'm facing a little hickup.<br>
how do i selectively move an image in pygame ?<br>
i let the display be 800x600 and the point is all start at y 511<br>
x at 62, 124. size of the image is 21x21  </p>

<pre><code>Tower1 = pygame.image.load('assets/Tower1.png')
Tower2 = pygame.image.load('assets/Tower2.png')
</code></pre>

<p>if i hit a box it will move the image in the box along with the mouse, and other
image doesn't move</p>

<p>form <a href="https://stackoverflow.com/questions/9812873/pygame-drag-background-image">Pygame drag background image</a></p>

<p>i can get moving image, but i can't make it move one by one.</p>

<pre><code>while not gameExit:

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            #gameExit = True
            pygame.quit()
            quit()

        if event.type == pygame.MOUSEMOTION:
            #event.buttons returns (0,0,0) &lt;=&gt; (left, mid, right)
            print (event)
            if event.buttons[LeftButton]:
                rel = event.rel
                pos = event.pos
                #print (rel)
                #print (pos)
                if (rangeHitPoint(62,511,(21,21),pos)):
                    #moveImage()





            if event.buttons[RightButton]:
                pass


def rangeHitPoint(x,y,imgeSize,Musepos):
    (w,h) = imgeSize
    (musex, mousey) = Musepos
    if x &lt; musex and y &lt; mousey:
        if (x+w) &gt; musex and (y+h) &gt; mousey:
            return True
    else:
        return False

def moveImage(image,pos):
    imgPos = pygame.Rect(pos, (0, 0))
    LeftButton = 0
    gameExit = False
    while not gameExit:
        for e in pygame.event.get():
            if e.type == pygame.QUIT:
                #gameExit = True
                pygame.quit()
                quit()
            if e.type == pygame.MOUSEMOTION:
                if e.buttons[LeftButton]:
                    # clicked and moving
                    rel = e.rel
                    imgPos.x += rel[0]
                    imgPos.y += rel[1]
        gameDisplay.blit(image, imgPos)
        pygame.display.flip()
        pygame.time.delay(60)
        gameExit = True


def displayImage(image,x,y):        
    gameDisplay.blit(image,(x,y))
    pygame.display.update()
</code></pre>