Question

New to python and I am just trying to test out some stuff. From some research I think I need a list to store all the vector points

mlist1 = [
[7, 12],
[22, 31],
[4, 17]]

everything is good I test it out as a print to see.

print (mlist1);

but now I would like to use each element as a vector for a blit. So my code looked liked this

for number in mlist1:
    s=pygame.display.set_mode((600, 600));
    newInt = mlist1[number];
    s.blit(array_surface, newInt);

(got an error: TypeError: list indices must be integers, not list)

I understand that blit needs an int, but is there any other function available or anything else I can do to achieve my goal? I am open to any and all suggestions(even if that means doing something different than what I am currently doing, I merely am doing this all from scratch with very little experience with python or vectors in this sense), thank you in advance.

EDIT:

Another point I would like to make is that I am trying to make a NavGraph so I need nodes, so this is essentially what will be nodes so if that affects anyone's answer/comments, just wanted to put that out there.

EDIT 2:

To clarify my question more I wanted to explain that I am essentially trying to pass a vector into a blit, but I need an integer. I am wondering if there is another function or something that I can use to basically pass the vector in instead of a integer and still have it draw in the window

Was it helpful?

Solution

I'm not sure blit is what you want. This draws circles at your co-ordinates. I suggest looking through the pygame tutorials some more.

import pygame

mlist1 = [
    (7, 12),
    (22, 31),
    (4, 17)]

s = pygame.display.set_mode((600, 600))

for point in mlist1:
    pygame.draw.circle(s, (255, 0, 0), point, 5)

pygame.display.flip()

OTHER TIPS

Is this what you're looking for?

s = pygame.display.set_mode((600, 600));
for point in mlist1:
    s.blit(array_surface, point);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top