On 2021-03-09 20:03, Quentin Bock wrote:
Error 1:
Space Invaders.py:90: SyntaxWarning: "is" with a literal. Did you mean "=="?
if bullet_state is "fire":
Error 2:
line 66, in <module>
if event.key == pygame.K_SPACE:
AttributeError: 'Event' object has no attribute 'key'
Code:
import pygame
import random
# Space Invaders!
[snip]
I see 2 problems:
1. You define "fire_bullet" to take 0 arguments, but then try to call it
with 2 arguments.
2. What attributes an event has depends on the type of event. For
example, KEYDOWN events have a "key" attribute, but most other types of
event don't. Your code tries to look at the "key" attribute even when
it's not a KEYDOWN event because of the amount of indentation.
--
https://mail.python.org/mailman/listinfo/python-list