I don't know what's going on and I can't find anyone else with the same issue. Here is my code:
import pygame
import math
import random
import os
SWIDTH = 800
SHEIGHT = 600
vec = pygame.math.Vector2
FRI = 0.3
ACC = 1
this is the error
File "C:\Users\USERNAME\Desktop\games\GAME.py", line 137, in update
self.loc += self.vel + 1 + self.aird
TypeError: unsupported operand type(s) for +: 'pygame.math.Vector2' and 'int'
self.vel
is a pygame.math.Vector2
. You cannot add an integral number to the object.
You can sum up 2 vectors:
self.loc += self.vel
Or you can add a value (scalar) to the components of a vector:
self.loc.x += self.vel.x + 1
self.loc.y += self.vel.y + 1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.