lewashby 56 Junior Poster
background_image_filename = 'sushiplate.jpg'
sprite_image_filename = 'fugu.png'

# imports
import pygame
from pygame.locals import *
from sys import exit
from gameobjects import Vectory2

pygame.init()

screen = pygame.display.set_mode((640, 480), 0, 32)

background = pygame.image.load(background_image_filename).convert()
sprite = pygame.image.load(sprite_image_filename).convert_alpha()

clock = pygame.time.Clock()

position = Vectory2(100.0, 100.0)
speed = 250.
heading = Vectory2

while True:
    
    for event in pygame.event.get():
        if event.type == QUIT:
            exit()
        if event.type == MOUSEBUTTONDOWN:
            destinatoin = Vectory2(*event.pos) - Vectory2(*sprite.get_size()) / 2
            heading = Vectory2.from_points(position, destinatoin)
            heading.normalize()
            
    screen.blit(background, (0, 0))
    screen.blit(sprite, position)
    
    time_passed = clock.tick()
    time_passed_seconds = time_passed / 1000.0
    
    distance_moved = time_passed_seconds = speed
    position += heading * distance_moved
    
    pygame.display.update()

In the code above I'M getting this error but don't know what's wrong. I've typed it just how it shows it in my book.

TypeError: invalid destination position for blit
File "/home/developer/Projects/Beginning Game Development/Chapter 4/ch5-last.py", line 34, in <module>
screen.blit(sprite, position)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.