forked from sybrenstuvel/Python-RVO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrender.py
More file actions
executable file
·71 lines (56 loc) · 2.02 KB
/
Copy pathrender.py
File metadata and controls
executable file
·71 lines (56 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python
import pygame
import sys
# Inicializar Pygame
pygame.init()
clock = pygame.time.Clock()
# Definir el tamaño de la pantalla
WIDTH, HEIGHT = 800, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Renderer")
# Definir colores
WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
BLACK = (0, 0, 0)
# Función para generar agentes
def draw_agent(x, y, color):
radio = 20
pygame.draw.circle(screen, BLACK, (x, y), radio+3) # Agente de radio r+3
pygame.draw.circle(screen, color, (x, y), radio) # Agente de radio r
# Abrir el archivo en modo lectura
with open('steps.txt', 'r') as archivo:
# Leer todas las líneas del archivo
lineas = archivo.readlines()
# Bucle principal del juego
def main():
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
for linea in lineas:
# Limpiar pantalla
screen.fill(WHITE)
# Divide la línea en columnas (suponiendo que están separadas por espacios)
columnas = linea.split()
# Procesa cada columna
print("step: " + columnas[0])
print("time: " + columnas[1])
for i in range (2, len(columnas), 2):
print("x: " + columnas[i] + " y: " + columnas[i+1])
draw_agent(float(columnas[i])*100 + WIDTH/2, float(columnas[i+1])*100 + HEIGHT/2, RED)
# pass
# # Dibujar pelota en la posición dada por el usuario
# for i in range(num_agents):
# x_input = input("Ingrese la posición x de la pelota: ")
# y_input = input("Ingrese la posición y de la pelota: ")
# draw_ball(float(x_input), float(y_input), RED)
# pass
# Actualizar la pantalla
pygame.display.flip()
clock.tick(5)
# Ejecutar el juego
if __name__ == "__main__":
main()