Я использую pygame с python для разработки игр, и я просто ударился о кирпичную стену. Когда одна из моих сущностей пытается переместиться с использованием умножения Vector2, я получаю «Fatal Python error: (pygame parachute) Segmentation Fault».
Непосредственный код ошибки:
# destination and location are Vector2, and the difference is a Vector2
vec_to_destination = self.destination - self.location
distance_to_destination = vec_to_destination.length()
# normalize() returns a Vector2
heading = vec_to_destination.normalize()
# time_passed is a float and speed is an int
travel_distance = min(distance_to_destination, time_passed * self.speed)
# location is a Vector2 as well.
self.location += travel_distance * heading
# The previous line is where the Segmentation fault occurs.
# The equation looks like this with values filled in:
# Vector2(747, 183) += 6.435 * Vector2(-0.882763, 0.469818)
Следующее может быть полезным. Вы можете воспроизвести проблему, которая возникла у меня, набрав в интерпретаторе python следующее (Python 2.7 и pygame 1.9.2pre):
import pygame
from pygame.math import *
v = Vector2(747, 183)
v2 = 6.435 * Vector2(-0.882763, 0.469818)
v += v2
v
Полный код для воспроизведения проблемы можно найти здесь:
ftp.mattwjones.net
имя пользователя: share1
пароль:! share1