def Parabola(x: float) -> float: y = multiplier * pow((x - origin_x), 2) + origin_y return y pass ######### #Objetive - # smoothen out the parabola # begin with lowest x, compute y, x+deltaX, compute y, compute distance, if more than threshold than x+0.5deltax # if less than threshold then x+0.25deltax min_distance = 4 # we expect 2 points to be not any more further than this x_current = 0 y_current = Parabola(x_current) point_last = Point(x_current, y_current) delta_x = 1 lst_points.append(point_last) while (x_current <= img_width): y_current = Parabola(x_current) distance = math.sqrt((point_last.X - x_current)**2 + (point_last.Y - y_current)**2) if (distance > min_distance): #select this point pt = Point(x_current, y_current) lst_points.append(pt) x_current = x_current + 1 point_last = pt else: #too close , move on to the next point x_current = x_current + 1
import pygame from grid_display.Tile import Tile from grid_display.camera import Camera from common.Point import Point window = pygame.display.set_mode((600, 600)) tiles = [ Tile(Point(60 + i * 50, 60 + j * 50), Point(50, 50), color=(255, 0, 255) if (i + j * j) % 2 == 0 else (0, 255, 0)) for i in range(8) for j in range(8) ] c = Camera((600, 600)) while True: for event in pygame.event.get(): window.fill((0, 0, 0)) if event.type == pygame.QUIT: exit() if event.type == pygame.KEYDOWN: move = Point(0, 0) if event.key == pygame.K_LEFT: move = move + Point(1, 0) if event.key == pygame.K_RIGHT: move = move + Point(-1, 0) c.move(move) for t in tiles: t.draw(window, c) pygame.display.flip()