Pygame event issues
import pygame
import sys
from pygame import AUDIODEVICEADDED, KEYDOWN
class Character:
def __init__(self, image, position):
self.image = image
self.rectangle = self.image.get_rect()
self.rectangle_center = position
def draw(self, screen):
screen.blit(self.image, self.rectangle)
def process_events(self, event):
if event.type == pygame.K_w:
print("YAY")
pygame.init()
width, height = 640, 480
screen = pygame.display.set_mode((width, height))
clock = pygame.time.Clock()
ball = pygame.image.load("GolfBall.png").convert_alpha()
ball = pygame.transform.smoothscale(ball, (150,150))
Bruce = Character(ball, (320, 240))
keep_playing = True
move_log = []
while keep_playing:
for event in pygame.event.get():
if event.type == pygame.QUIT or event.type == pygame.MOUSEBUTTONDOWN:
keep_playing = False
Bruce.process_events(event)
Bruce.process_events(move_log)
screen.fill((0,0,0))
Bruce.draw(screen)
# screen.blit(ball,ball_rect)
pygame.display.update()
clock.tick(60)
pygame.quit()
sys.exit
Hello, I'm trying to write some code where the method process_events within my Character Class handles the movement. As is, I receive an error when I run the code that says 'list' object has no attribute 'type'. Alternatively if I set up a for loop before my if statement, I get this error: 'pygame.event.Event' object is not iterable. These error statements seem to be disagreeing.