Why can't I see my moved(by vector) rect?

Viewed 38

In this 2048 game I'm making I am moving my tiles(rects) to a new slot when I press movement keys. When I press a movement key it says the correct position in console when it prints it but I can't see it on the screen. Here is the spot most likely to have the error. (I am also trying to make the movement smooth)

rect = tiles[str(k)]
    for i in range(distance):
    print(i)
    rect.x += x
    rect.y += y
    print(rect.x, rect.y)
    pygame.display.update()

If you think it has something to do with other code or you want to look at it:

#IN MAIN LOOP
#WASD
        if event.type == pygame.KEYDOWN:
            if play == 1:
                if event.key == pygame.K_w:
                    y = -10
                    v = -4
                elif event.key == pygame.K_a:
                    x = -10
                    v = -1
                elif event.key == pygame.K_s:
                    y = 10
                    v = 4
                elif event.key == pygame.K_d:
                    x = 10
                    v = 1
                #ARROWS
                elif event.key == pygame.K_UP:
                    y = -10
                    v = -4
                elif event.key == pygame.K_LEFT:
                    x = -10
                    v = -1
                elif event.key == pygame.K_DOWN:
                    y = 10
                    v = 4
                elif event.key == pygame.K_RIGHT:
                    x = 10
                    v = 1
                else:
                    continue
                for k in range(1,17):
                    if str(k) in tiles.keys():
                        print(k)
                        """COMPRESS"""
                        #Find "k's row"
                        #x
                        if x != 0:
                            if k in range(1,5):
                                row_range = range(1,5)
                            elif k in range(5,9):
                                row_range = range(5,9)
                            elif k in range(9,13):
                                row_range = range(9,13)
                            else:
                                row_range = range(13,17)
                            print(row_range)
                            #Move as far as can go in direction
                            if k+(v*3) in row_range and used_tiles[str(k+v*3)] == False:
                                m = 3
                            elif k+(v*2) in row_range and used_tiles[str(k+v*2)] == False:
                                m = 2
                            elif k+v in row_range and used_tiles[str(k+v)] == False:
                                m = 1
                            else:
                                m = 0
                        #y
                        else:
                            if k+v*3 in range(1,17) and used_tiles[str(k+v*3)] == False:
                                m = 3
                            elif k+v*2 in range(1,17) and used_tiles[str(k+v*2)] == False:
                                m = 2
                            elif k+v in range(1,17) and used_tiles[str(k+v)] == False:
                                m = 1
                            else:
                                m = 0
                        print(m,"!")
                        if m != 0:
                            distance = 13*m
                            v = v*m
                            coordsX = (tile_slots[str(k+v)])[0]
                            coordsY = (tile_slots[str(k+v)])[1]
                            #Move rect
                            rect = tiles[str(k)]
                            #rect.move_ip(coordsX, coordsY)
                            for i in range(distance):
                                print(i)
                                rect.x += x
                                rect.y += y
                                print(rect.x, rect.y)
                                pygame.display.update()
                            """COMBINE"""
                            if used_tiles_n[str(int(k+v/m))] == used_tiles_n[str(k)]:
                                used_tiles_n[str(k+v)] = int(used_tiles_n[str(k)])*2
                            else:
                                used_tiles_n[str(k+v)] = used_tiles_n[str(k)]
                            #Draw text
                            if int(used_tiles_n[str(k)]) > 4:
                                text = font4.render(str(used_tiles_n[str(k+v)]), True, tile_text_c["above4_c"])
                            else:
                                text = font4.render(str(used_tiles_n[str(k)]), True, tile_text_c["2and4_c"])
                            game_board_s.blit(text, (coordsX+38, coordsY+26))
                            #Re-set dicts
                            tiles[str(k+v)] = rect
                            used_tiles[str(k+v)] = True
                    #Update
                    screen.blit(game_board_s,(49, 200))
                pygame.display.flip() 
0 Answers
Related