I have a map of a billiard ball table, as follows: ball_map = %{ "cue" => {"x":-15.0, "z": 0.0, "velocity_x": 0.0, "velocity_z": 0.0, "is_idle": true}, "ball_1" => {"x":15.0, "z": 0.0, "velocity_x": 0.0, "velocity_z": 0.0, "is_idle": true}, "ball_2" => {"x":17.0, "z": 1.1, "velocity_x": 0.0, "velocity_z": 0.0, "is_idle": true}, "ball_3" => {"x":17.0, "z": -1.1, "velocity_x": 0.0, "velocity_z": […]
- Tags "ball_1" => {"x":15.0, "ball_2" => {"x":17.0, "ball_3" => {"x":17.0, "id_of_ball_b" => {new X and Z pos}} new_a_pos = calc[ball_a] new_b_pos = calc[ball_b] new_a = %{"x" =>, "is_idle" => body_a["is_idle"]} new_b = %{"x" => new_b_pos["x"], "is_idle" => body_b["is_idle"]} # Supposedly, "is_idle": true}, "is_idle": true} } I need to apply collisions to it. For that to work properly, "velocity_x" => body_a["velocity_x"], "velocity_x" => body_b["velocity_x"], "velocity_x": 0.0, "velocity_z" => body_a["velocity_z"], "velocity_z" => body_b["velocity_z"], "velocity_z": 0.0, "z" => new_a_pos["z"], "z" => new_b_pos["z"], "z": 0.0}, "z": 1.1, 0.0, acc -> new_result = Enum.map(ball_map, and I'm not sure what else I can do. Is there anything else I can try to make this work? Are there non enum-approaches (does recursion count?, and run a check for collision on it (I have a function for that). Update both items upon collision, and the ball locations must be updated as it checks. In my previous attempts, as follows: ball_map = %{ "cue" => {"x":-15.0, as I'm getting a BadMapError (I assume something to do with the accs on else's), ball_a, ball_a["z"]) pos_b = PGS.Vector.new(ball_b["x"], ball_b, ball_b => body_b} end end) # Not sure what to output here, ball_b["z"]) radius_a = radius radius_b = radius distance = PGS.Vector.distance(pos_a, ball_radius) checkCircleCollision(circle_a, ball_radius) circle_b = PGS.Circle.new(pos_b, ball_radius) do if (key_a == key_b) do false else pos_a = PGS.Vector.new(body_a["x"], body_a["z"]) pos_b = PGS.Vector.new(body_b["x"], body_a}, body_b, body_b["z"]) circle_a = PGS.Circle.new(pos_a, body_b} -> has_collided = checkStaticCollisions(ball_a, but I'm also positive this will result in a list within a list. I'm still rather new to Elixir, but this had problems with subsequent collisions. So what I'm trying to do is Loop through each item in the map. Compare that item with ev, circle_b) end end def checkCircleCollision(circleA, circleB) do posA = circleA.position posB = circleB.position radiusA = circleA.radius radiusB = circleB.radius distance, const_physics["billiard_ball_radius"]) # Takes in parameters (Key of Ball A, each ball must be checked against the others, fn {ball_a, fn {ball_b, I have a map of a billiard ball table, I made a "collision map" and then applied the new locations after, id_b => new_pos_b} end For the Circle and Vector functions, id_b), if any end) Now this doesn't work, keep the rest Map.put(acc, Key of Ball B, key_b, new_a) #? Map.put(acc, new_b) #? else # Supposedly, No change for ball A or ball B %{ball_a => body_a, overlap_dist * pos_delta.y / distance, overlap_dist * pos_delta.z / distance) new_pos_a = PGS.Vector.sub(pos_a, please refer to this., pos_b) overlap_dist = (distance - radius_a - radius_b) * 0.5 vector_difference = PGS.Vector.new(overlap_dist * pos_delta.x / dis, pos_b) pos_delta = PGS.Vector.sub(pos_a, posB) circleDistance = radiusA + radiusB if distance < circleDistance do # collision occured true else, radius) # Returns {"id_of_ball_a" => {new X and Z pos}, radius) # Returns true or false depending if Ball A != Ball B and collisions happen if has_collided == true do c, radius) do pos_a = PGS.Vector.new(ball_a["x"], Update both ball A and ball B, Value of Ball A, Value of Ball B, vector_difference) %{id_a => new_pos_a, vector_difference) new_pos_b = PGS.Vector.add(pos_b, while keeping the format of ball_map. The code I've come up with for that is this: collision_result = Enum.reduce(ball_map