Haha, I guess pioupiou is similar to flappy bird? (which is actually based on an old game called helicopter from more than 10 years ago) It was fun, I think I got about 17 points.
With regard to the A* file, there are a few problems:
- It seems that your bounding box select only works if you select from left to right and top to bottom, i.e. from the top left corner to the bottom right. If I try to start the box from any other position it wonāt select the objects.
When writing a bounding box code I use the point when click is first activated until the point when it is released:
if left_mouse.positive:
if not own['start_selection']:
own['start_selection'] = mouse_position
else:
draw_selection_box(own['camera'],own['start_selection'],mouse_position)
### draws the visual box only
else:
if own['start_selection']:
start = own['start_selection']
end = mouse_position
select_agents(own['camera'],start,end)
### passes the start and end point to the selector function
own['start_selection'] = None
### resets the start point ready for the next select operation
and then I sort the start and end points to get an x_limit and a y_limit:
x_limit = sorted([start[0],end[0]])
y_limit = sorted([start[1],end[1]])
I then check of any selectable objects are inside those limits:
if screen_location[0] > x_limit[0] and screen_location[0] < x_limit[1]:
if screen_location[1] > y_limit[0] and screen_location[1] < y_limit[1]:
selected = True
Because of sorting the x_limit and y_limit it doesnāt matter what order my selection points are in when fed to the selector function.
- When I try your file I sometimes get an error about:
line 1272 in move, list assignment index is out of range.
Which freezes the simulation after than. I donāt know whatās causing that.
- I think your destination array may be too big. If you have 25 players, you donāt need a 25x25 box, but a box with 25 destinations, which would be a 5x5 box, or the square root of len(players). It might be good to increase that number to 6x6 because some locations may be lost because of being invalid. Also remember that if a player doesnāt get assigned a valid destination (because of the valid_destinations_list being shorter than the selected_player_list) you need some code to tell the player what to do. Maybe just be inactive.
- One final point is about how you orientate your players and move them. I usually use a target vector, from the player to their current destination:
target_vector = agent['route'][0]).to_3d() - agent.worldPosition.copy()
### to_3d() transforms a 2d (x,y) vector in to a 3d (x,y,z) vector
### using a .copy() of a vector which is owned by a game object such as .worldPosition is good practice,
### in case you accidentally alter the original vector, which would cause the original object to move.
then I use the very helpful .to_track_quat() function to get something I can use for worldOrientation:
target_rotation = target_vector.to_track_quat("Y", "Z")
agent.worldOrientation = target_rotation
You can use the slerp function too for gradual alignment:
target_rotation = target_vector.to_track_quat("Y", "Z")
agent_rotation = agent.worldOrientation.to_quaternion()
slow_rotation = target_rotation.slerp(agent_rotation,0.9)
agent.worldOrientation = slow_rotation
### this is the same as using the track_to actuator, but doesn't need an object
And for movement I usually move an object along its local y axis:
local_movement_vector = agent.getAxisVect([0.0, 1.0, 0.0])
local_movement_vector.length = agent['speed']
agent.worldPosition += local_movement_vector
I hope some of that is useful to you, Iām working on similar code right now, and thatās the way I do things, but Iām not saying that that is THE ONLY way to do things. Just try different methods and see which is best for you.