Added FPS tracker and 'player' motion
This commit is contained in:
58
main.py
58
main.py
@@ -34,6 +34,8 @@ def draw_point(point):
|
|||||||
x_1 = x_1/norm
|
x_1 = x_1/norm
|
||||||
x_2 = x_2/norm
|
x_2 = x_2/norm
|
||||||
#Transform it into the Poincare Space
|
#Transform it into the Poincare Space
|
||||||
|
if x_0 == -1:
|
||||||
|
return
|
||||||
u = x_1/(1+x_0)
|
u = x_1/(1+x_0)
|
||||||
v = x_2/(1+x_0)
|
v = x_2/(1+x_0)
|
||||||
|
|
||||||
@@ -43,7 +45,7 @@ def draw_line(line):
|
|||||||
delta = line.e3
|
delta = line.e3
|
||||||
if abs(delta) < ERROR:
|
if abs(delta) < ERROR:
|
||||||
# The geodesic is a line through the origin.
|
# The geodesic is a line through the origin.
|
||||||
theta = math.atan2(line.e1, line.e2)
|
theta = math.atan2(line.e1, -line.e2)
|
||||||
start_x = int(CENTER_X-DISK_RADIUS*math.cos(theta))
|
start_x = int(CENTER_X-DISK_RADIUS*math.cos(theta))
|
||||||
start_y = int(CENTER_Y-DISK_RADIUS*math.sin(theta))
|
start_y = int(CENTER_Y-DISK_RADIUS*math.sin(theta))
|
||||||
end_x = int(CENTER_X+DISK_RADIUS*math.cos(theta))
|
end_x = int(CENTER_X+DISK_RADIUS*math.cos(theta))
|
||||||
@@ -72,20 +74,19 @@ def simulation(t):
|
|||||||
x_motor = tx_generator.exp()
|
x_motor = tx_generator.exp()
|
||||||
y_motor = ty_generator.exp()
|
y_motor = ty_generator.exp()
|
||||||
|
|
||||||
generator = math.sin(t)*tx_generator + math.sin(math.sqrt(2)*t)*ty_generator + math.sin(math.sqrt(3)*t)*origin
|
#generator = math.sin(t)*tx_generator + math.sin(math.sqrt(2)*t)*ty_generator + math.sin(math.sqrt(3)*t)*origin
|
||||||
m = generator.exp()
|
y_tick = motor*y_axis*motor.reverse()
|
||||||
y_tick = m*y_axis*m.reverse()
|
x_tick = motor*x_axis*motor.reverse()
|
||||||
x_tick = m*x_axis*m.reverse()
|
|
||||||
lines.append(y_tick)
|
lines.append(y_tick)
|
||||||
lines.append(x_tick)
|
lines.append(x_tick)
|
||||||
points.append(y_tick^x_tick)
|
points.append(y_tick^x_tick)
|
||||||
|
|
||||||
for i in range(13):
|
for i in range(9):
|
||||||
for j in range(13):
|
for j in range(9):
|
||||||
motor_x = ((i-6)*tx_generator/10).exp()
|
motor_x = ((i-4)*tx_generator/10).exp()
|
||||||
motor_y = ((j-6)*ty_generator/10).exp()
|
motor_y = ((j-4)*ty_generator/10).exp()
|
||||||
y_tick = m * motor_x * y_axis * motor_x.reverse() * m.reverse()
|
y_tick = motor * motor_x * y_axis * motor_x.reverse() * motor.reverse()
|
||||||
x_tick = m * motor_y * x_axis * motor_y.reverse() * m.reverse()
|
x_tick = motor * motor_y * x_axis * motor_y.reverse() * motor.reverse()
|
||||||
lines.append(y_tick)
|
lines.append(y_tick)
|
||||||
lines.append(x_tick)
|
lines.append(x_tick)
|
||||||
points.append(y_tick^x_tick)
|
points.append(y_tick^x_tick)
|
||||||
@@ -114,15 +115,48 @@ BLUE = (0, 0, 255)
|
|||||||
|
|
||||||
# Game loop
|
# Game loop
|
||||||
running = True
|
running = True
|
||||||
|
clock = pygame.time.Clock()
|
||||||
|
font = pygame.font.SysFont("Arial", 18)
|
||||||
t = 0
|
t = 0
|
||||||
|
|
||||||
lines.append(x_axis)
|
lines.append(x_axis)
|
||||||
lines.append(y_axis)
|
lines.append(y_axis)
|
||||||
|
|
||||||
|
pos = 0*tx_generator + 0*ty_generator + 0*origin
|
||||||
|
motor = 1*e
|
||||||
|
tx_motor = (tx_generator/100).exp()
|
||||||
|
ty_motor = (ty_generator/100).exp()
|
||||||
while running:
|
while running:
|
||||||
t += 0.0002
|
t += 0.001
|
||||||
|
|
||||||
|
keys = pygame.key.get_pressed()
|
||||||
|
|
||||||
|
#point_gen = pos.e13*e13 + pos.e23*e23
|
||||||
|
#motor = point_gen.exp()
|
||||||
|
point = motor * origin * motor.reverse()
|
||||||
|
point_motor = (point/100).exp()
|
||||||
|
|
||||||
|
if keys[pygame.K_a]:
|
||||||
|
motor = tx_motor * motor
|
||||||
|
if keys[pygame.K_d]:
|
||||||
|
motor = tx_motor.reverse() * motor
|
||||||
|
if keys[pygame.K_w]:
|
||||||
|
motor = ty_motor * motor
|
||||||
|
if keys[pygame.K_s]:
|
||||||
|
motor = ty_motor.reverse() * motor
|
||||||
|
if keys[pygame.K_q]:
|
||||||
|
motor = point_motor*motor
|
||||||
|
if keys[pygame.K_e]:
|
||||||
|
motor = point_motor.reverse()*motor
|
||||||
|
|
||||||
# Clear the screen
|
# Clear the screen
|
||||||
screen.fill(WHITE)
|
screen.fill(WHITE)
|
||||||
|
|
||||||
|
clock.tick()
|
||||||
|
fps = clock.get_fps()
|
||||||
|
fps_text = font.render(f"FPS: {int(fps)}", True, (0, 0, 0))
|
||||||
|
screen.blit(fps_text, (10, 10))
|
||||||
|
|
||||||
#Poincare Disk Boundary
|
#Poincare Disk Boundary
|
||||||
pygame.draw.circle(screen, BLACK, (CENTER_X, CENTER_Y), DISK_RADIUS, 1)
|
pygame.draw.circle(screen, BLACK, (CENTER_X, CENTER_Y), DISK_RADIUS, 1)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user