1

I followed this tutorial on ElectronicsForu on how to create a game in Python and attempted this code on drawing errors. The number 640 kept getting an invalid syntax for some reason.

for bullet in arrows:
    index = 0
    velx = math.cos (bullet [0]) * 10
    vely = math.sin (bullet [0]) * 10
    bullet [1] += velx
    bullet [2] += vely
if bullet [1] 640 or bullet [2] 480:
    arrows.pop (index)
    index += 1
for projectile in arrows:
    arrow1 = pygame.transform.
    rotate (arrow, 360-projectile [0] * 57.29)
    screen.blit (arrow1, (projectile [1], projectile [2]))
Simi
  • 13
  • 3

1 Answers1

1

If statement requires comparisons. Such as ==, <, > or combination of them. You do not compare bullet[1] with 640 or bullet[2] with 480.

if bullet[1] 640 or bullet[2] 480:  # no comparison

Based on your purpose, add comparison, like:

if bullet[1] == 640 or bullet[2] == 480:
Sercan
  • 2,081
  • 2
  • 10
  • 23
  • Now I wonder if there's a particular format that I'm supposed to use because I'm getting an error that says there's inconsistent use of space. I couldn't even find the problem. – Simi Jul 23 '20 at 21:02
  • Indentation is important in Python, you can find some similar problems here in SO, and those post can help you, such as [“inconsistent use of tabs and spaces in indentation”](https://stackoverflow.com/questions/5685406/inconsistent-use-of-tabs-and-spaces-in-indentation) or [Inconsistent use of tabs and spaces in indentation](https://stackoverflow.com/questions/12989171/inconsistent-use-of-tabs-and-spaces-in-indentation) – Sercan Jul 24 '20 at 08:01