def update(): ball.update(player, cpu) player.update(ball) cpu.update(ball)
last_shot = time.time() new_ball = launcher.shoot() balls.append(new_ball) success = False ball_hist_coords = [] times = [] if keys[pygame.K_z]: break ph.fill_screen(screen, params.background_color) for ball_num in range(len(balls)): ball = balls[0] ready = ball.update() ball.draw(screen) if ready and not success: #ph.draw_circle(screen, (255,255,255), ph.world_coord_to_pixel_coord([ball.x_peak, ball.y_peak]), ball.radius) peak1 = ball.x_peak peak2 = ball.y_peak T_temp = np.array([[1, 0, 0, 0], [0, 1, 0, peak1], [0, 0, 1, peak2], [0, 0, 0, 1]]) thetas, success = robot.inverse_kinematics(T_temp, robot.thetas) if success: success_iter = 0 curr_thetas = np.array(robot.thetas)
def _balls_update(self): for ball in self.balls: ball.update() if self._check_collision(self.agent, ball): self.run = False return
gravitational_acceleration, 1, 1, 0.8, 0.2)) moving = [] for i in balls: moving.append(True) previous_time = time.time() while any(moving): current_time = time.time() delta_time = current_time - previous_time for i, ball in enumerate(balls): if moving[i]: ball.update(delta_time, room) moving[i] = ball.moving previous_time = current_time figure = matplotlib.pyplot.figure() plot = figure.add_subplot(111, projection="3d") for ball in balls: ball.convert_path() plot.plot(ball.x_path, ball.z_path, ball.y_path) plot.set_xlim(room.origin.x, room.limit.x) plot.set_ylim(room.origin.y, room.limit.y) plot.set_zlim(room.origin.z, room.limit.z)
def simulatePhysics(): #update object positions player1.update() player2.update() ball.update()