I have the following python/pygame code:
import sys, pygame
from array import *
pygame.init()
height = 600
width = 800
Setup Display Window
DISPLAYSURFACE = pygame.display.set_mode((width, height))
pygame.display.set_caption('Graphics Assignment Part 1')
open file
file = open('F:\\school\\Graphics\\PIXA.DAT', 'r')
read file into a list and close it
vlist = file.readlines()
#close file
file.close
#remove last value from list
del vlist[-1]
store values from vlist into points but change J to JUMP bit and split ints with ,
points = [list(map(int,v.split())) if v.strip().lower() != "j" else "JUMP" for v in vlist]
Setup loops to split vlist
into 3 lists of x,y,z coordinate lists
Xs,Ys,Zs= zip(*points)
unique_Xs = []
[unique_Xs.append(val) for val in Xs if val != "J"]
unique_Ys = []
[unique_Ys.append(val) for val in Ys if val != "U"]
unique_Zs = []
[unique_Zs.append(val) for val in Zs if val != "M"]
draw = list(zip(unique_Xs,unique_Ys))
Draw the list of points on the Screen as a series of lines
drawing = pygame.draw.lines(DISPLAYSURFACE,(0,255,172),False, draw, 1)
Update the Display and quit pygame
pygame.display.update()
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
I am reading in a list of coordinates and storing them into a list of x,y,z coordinates to draw a set of lines in pygame.
I can draw the image however the whole thing does not show up on the screen because the points are in the range of -2000 to 2000.
How can i change my coordinate range in my python window to display my whole image in my 800x600 display window