title: Pygame TelePorting White Square how To Fix?
body: <p>I made a teleporting square where it teleports my player to another position if they touch it.</p>
  
  <p>THE <strong><em>Problem is my screen when I scroll somewhere else it doesn't teleport me where I want it <a href="https://gyazo.com/ddbb507690686c2efafe636ed08ba283" rel="nofollow noreferrer">EXAMPLE-Video</a></em></strong>. I can teleport to the position I want if I am at the scrolling position, but if I scroll somewhere else and try to teleport it wont teleport me there.</p>
  
  <p>My Teleporting Script</p>
  
  <pre><code>
  if playerman.rect.colliderect(teleport.rect):
        for enemy in enemies:
             if playerman.rect.centerx:
                   playerman.x = 50
                   playerman.y = 150
  
  </code></pre>
  
  <p>Full Code</p>
  
  <pre><code># import module
  import pygame
  pygame.init()
  
  # window
  window = pygame.display.set_mode((500,500))
  pygame.display.set_caption("YELOLL")
  
  # draw the player
  class player:
      def __init__(self,x,y,height,width,color):
          self.x = x
          self.y = y
          self.height = height
          self.width = width
          self.isJump = False
          self.JumpCount = 10
          self.fall = 0
          self.speed = 5
          self.color = color
          self.rect = pygame.Rect(x,y,height,width)
      def draw(self):
          self.rect.topleft = (self.x,self.y)
          pygame.draw.rect(window, self.color, self.rect)
  # enemy
  class enemy:
      def __init__(self,x,y,height,width,color):
          self.x = x
          self.y = y
          self.height = height
          self.width = width
          self.color = color
          self.rect = pygame.Rect(x,y,height,width)
      def draw(self):
          self.rect.topleft = (self.x,self.y)
          pygame.draw.rect(window, self.color, self.rect)
  
  
  # coins
  class coin:
      def __init__(self,x,y,height,width,color):
          self.x = x
          self.y = y
          self.height = height
          self.width = width
          self.color = color
          self.rect = pygame.Rect(x,y,height,width)
      def draw(self):
          self.rect.topleft = (self.x,self.y)
          pygame.draw.rect(window, self.color, self.rect)
  
  font = pygame.font.Font('freesansbold.ttf', 32)
  score = 0
  text = font.render('Score = ' + str(score), True, (255,255,255))
  textRect = text.get_rect()
  textRect.center = (100, 40)
  # FPS
  FPS  = 60
  clock = pygame.time.Clock()
  
  # colors
  Green = (0,255,2)
  white = (255,255,255)
  Yellow = (248,255,0)
  Blue = (0,255,201)
  
  # define player and enemy
  playerman = player(50,390,30,30, Blue)
  enemy1 = enemy(180,390,150,10, Green)
  enemy2 = enemy(300,290,150,10, Green)
  enemy3 = enemy(70,250,150,10, Green)
  enemy4 = enemy(-10000,490,150000,50, white)
  teleport = enemy(390,390,40,80, white)
  
  enemies = [enemy1,enemy2,enemy3,enemy4]
  
  # define coins
  coin1 = coin(230,370,20,20, Yellow)
  coin2 = coin(350,270,20,20, Yellow)
  coin3 = coin(150,230,20,20, Yellow)
  coin4 = coin(250,450,20,20, Yellow)
  
  Coins_list = [coin1,coin2,coin3,coin4,teleport]
  
  
  # main loop
  runninggame = True
  while runninggame:
      for event in pygame.event.get():
          if event.type == pygame.QUIT:
              runninggame = False
      clock.tick(FPS)
      window.fill((0,0,0))
      teleport.draw()
      window.blit(text,textRect)
      playerman.draw()
      for enemy in enemies:
          enemy.draw()
      for coin in Coins_list:
          coin.draw()
  
  
  
      if playerman.y &lt; 250:
          playerman.y += 1
          for enemy in enemies:
              enemy.y += playerman.speed
          for coin in Coins_list:
              coin.y += playerman.speed
      if playerman.y &gt; 450:
          playerman.y -= playerman.fall
          for enemy in enemies:
              enemy.y -= playerman.fall
          for coin in Coins_list:
              coin.y -= playerman.fall
  
      keys = pygame.key.get_pressed()
  
  
  
      if keys[pygame.K_LEFT]:
          playerman.x -= playerman.speed
          if playerman.x &lt; 100:
              playerman.x += playerman.speed
              for enemy in enemies:
                  enemy.x += playerman.speed
              for coin in Coins_list:
                  coin.x += playerman.speed
  
  
  
  
      if keys[pygame.K_RIGHT]:
          playerman.x += playerman.speed
          if playerman.x &gt; 450:
              playerman.x -= playerman.speed
              for enemy in enemies:
                  enemy.x -= playerman.speed
              for coin in Coins_list:
                  coin.x -= playerman.speed
  
  
  
  
  
  
      if not playerman.isJump:
          playerman.y += playerman.fall
          playerman.fall += 1
          collide = False
          for enemy in enemies:
              if playerman.rect.colliderect(enemy.rect):
                  collide = True
                  playerman.y = enemy.rect.top - playerman.height + 1
                  if playerman.rect.right &gt; enemy.rect.left and playerman.rect.left &lt; enemy.rect.left - playerman.width:
                      playerman.x = enemy.rect.left - player.width
                  if playerman.rect.left &lt; enemy.rect.right and playerman.rect.right &gt; enemy.rect.right + playerman.width:
                      playerman.x = enemy.rect.right
                  break
              for i in range(len(Coins_list)-1,-1,-1):
                  if playerman.rect.colliderect(Coins_list[i].rect):
                      del Coins_list[i]
                      score += 1
                      text = font.render('Score = ' + str(score), True,  (255,255,255))
                      textRect = text.get_rect()
                      textRect.center = (100,40)
  
              if playerman.rect.colliderect(teleport.rect):
                  for enemy in enemies:
                      if playerman.rect.centerx:
                          playerman.x = 50
                          playerman.y = 150
  
          if playerman.rect.bottom &gt;= 500:
              collide = True
              playerman.isJump = False
              playerman.JumpCount = 10
              playerman.y = 500 - playerman.height
  
  
          if collide:
              if keys[pygame.K_SPACE]:
                  playerman.isJump = True
              playerman.fall = 0
      else:
          if playerman.JumpCount &gt; 0:
              playerman.y -= (playerman.JumpCount*abs(playerman.JumpCount))*0.4
              playerman.JumpCount -= 1
          else:
              playerman.isJump = False
              playerman.JumpCount = 10
  
  
      pygame.display.update()
  pygame.quit()
  </code></pre>