title: Im trying to create a space dodge game and I'm having a few issues
body: <p>Basically I'm trying to have it so that when the ship touches the meteor it plays an explode animation. I'm using colour detection for this as when i used <code>player.colliderect(name)</code> it was really inaccurate and began the animation when it was far away from the asteroid. So im using colour detection now in hopes that it'll work better and be more accurate. This is the code i tried making for that (i know its commented out):</p>
  <pre class="lang-py prettyprint-override"><code># pixel_colour = screen.get_at(player.pos) #collision with colour makes ship explode
  #     red = pixel_colour[0]
  #     blue = pixel_colour[1]
  #     green = pixel_colour[2]
  #     if red and green and blue != 0:
  #         print(&quot;oof&quot;)
  #         gameover() 
  </code></pre>
  <p>Here is the <code>gameover()</code> subroutine:</p>
  <pre class="lang-py prettyprint-override"><code>def gameover(): #ship exploding animation
      player.image = 'explode.png'
      clock.schedule_unique(game_over, 0.3)
  def game_over():
      player.image = 'explode1.png'
      clock.schedule_unique(overgame, 0.3)
  def overgame():
      player.image = 'explode2.png'
      vel = 0 #stop the ship from moving (doesnt work)
  </code></pre>
  <p>it says &quot;screen&quot; doesn't have the attribute &quot;get_at&quot; so i tried it with &quot;surface&quot; instead of &quot;screen&quot; and it said that &quot;surface is not defined&quot; I really dont know what to do with it...
  Also i tried to make the player stop being able to move when they get a game over (as seen inside the second bit of code when i make <code>vel</code> 0 it says &quot;vel is not defined&quot; and &quot;vel is used before assignment&quot;) Heres my full code so you know what im doing :D</p>
  <pre class="lang-py prettyprint-override"><code>import pgzrun
  import pygame
  import random
  
  
  
  
  WIDTH = 850
  HEIGHT = 425
  
  #sprites
  
  player = Actor('ship.png')
  player.pos = 100, 56
  foe = Actor('foe.png')
  foe.pos = 200, 112
  foe2 = Actor('foe.png')
  foe2.pos = 200, 112
  title = Actor('title2.png')      #calling sprites and saying their pos
  title.pos = 400, 212
  cont = Actor('cont.png')
  cont.pos = 470, 300
  vel = 5
  
  
  music.play(&quot;temp.mp3&quot;)
  
  #controls
  
  def draw():
      screen.clear()
      screen.fill((0, 0, 0))
      foe.draw()
      foe2.draw()
      player.draw()
      title.draw()
      cont.draw()
  
  
  def update():
      keys = pygame.key.get_pressed()
      x, y = player.pos #controls
      x += (keys[pygame.K_d] - keys[pygame.K_a]) * vel
      y += (keys[pygame.K_s] - keys[pygame.K_w]) * vel
      player.pos = x, y
      
      if player.left &gt; WIDTH: #if player hits right side of screen it takes the player to the other side of the screen
          player.right = 0
          
          
  #     pixel_colour = screen.get_at(player.pos) #collision with colour makes ship explode
  #     red = pixel_colour[0]
  #     blue = pixel_colour[1]
  #     green = pixel_colour[2]
  #     if red and green and blue != 0:
  #         print(&quot;oof&quot;)
  #         gameover()
           
  def foeupdate():
      moveamount = 0
      while moveamount &lt;= 5:
          fx, fy = foe.pos #making asteroid appear in random places.
          fx = random.randint(0, 850)
          fy = random.randint(0, 425)
          duration = random.randint(0, 5)
          animate(foe, pos = (fx, fy), duration)
          moveamount =+ 1
      #foe.pos = fx, fy
  
  def otherimage():           #animation of ship
      player.image = 'ship.png'
      clock.schedule_unique(imagey, 0.3)
  def imagey():
      
      player.image = 'ship1.png'
      clock.schedule_unique(otherimage, 0.3)
      
      
  
  
  def gameover(): #ship exploding animation
      player.image = 'explode.png'
      clock.schedule_unique(game_over, 0.3)
  def game_over():
      player.image = 'explode1.png'
      clock.schedule_unique(overgame, 0.3)
  def overgame():
      player.image = 'explode2.png'
      vel = 0 #stop the ship from moving (doesnt work)
  
  imagey()
  foeupdate()
  
  pgzrun.go()
  </code></pre>
  <p>also i have experimented with wrapping (as you can see on the line that goes <code>if player.left &gt; WIDTH:     player.right = 0</code>) i would like this to be the same with the other sides as well. But im trying to work this out at the moment so if you don't talk about this then its fine because im sure i can figure it out haha :D</p>
  <p>so the code is working perfectly fine but i would like to get these things working as its the core of the game. Thanks if you can help :D</p>