Points moving on graph

Show off your games, demos and other (playable) creations.
Post Reply
User avatar
darkfrei
Party member
Posts: 1262
Joined: Sat Feb 08, 2020 11:09 pm

Points moving on graph

Post by darkfrei »

Small concept how to make the points that moving on the graph.
Animation (118).gif
Animation (118).gif (577 KiB) Viewed 2359 times
Attachments
points-on-graph-2-02.love
(5.88 KiB) Downloaded 60 times
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
dusoft
Party member
Posts: 792
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: Points moving on graph

Post by dusoft »

What are we looking at? Is it based on pathfinding between two points?
User avatar
darkfrei
Party member
Posts: 1262
Joined: Sat Feb 08, 2020 11:09 pm

Re: Points moving on graph

Post by darkfrei »

dusoft wrote: Sun Apr 06, 2025 9:20 pm What are we looking at? Is it based on pathfinding between two points?
Yes.
1. There is the graph - the diagram with nodes and edges. Each edge can have multiple points, so the edge can be curved and total length. Also the edges have just only one direction.
2. From nodes to nodes can be find the shortest path.
3. Points are moving along the paths.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
dusoft
Party member
Posts: 792
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: Points moving on graph

Post by dusoft »

Nice. Did you use some common algorithm such as A*? Sorry, I didn't go through your code, just checked the demo.
User avatar
darkfrei
Party member
Posts: 1262
Joined: Sat Feb 08, 2020 11:09 pm

Re: Points moving on graph

Post by darkfrei »

dusoft wrote: Mon Apr 07, 2025 5:19 pm Nice. Did you use some common algorithm such as A*? Sorry, I didn't go through your code, just checked the demo.
No, it's the Dijkstra's algorithm, but id can be changed to A*, if we add the distance to the end point as extra weight.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
knorke
Party member
Posts: 276
Joined: Wed Jul 14, 2010 7:06 pm
Contact:

Re: Points moving on graph

Post by knorke »

your demos are super neat.
are you also working on some bigger project to use them?
User avatar
darkfrei
Party member
Posts: 1262
Joined: Sat Feb 08, 2020 11:09 pm

Re: Points moving on graph

Post by darkfrei »

knorke wrote: Mon Apr 14, 2025 2:10 pm your demos are super neat.
are you also working on some bigger project to use them?
Yes, I am makin the game, that needs alot of mechanics, one of them is path following along the graph structure.

https://www.youtube.com/watch?v=GbTO3S_-klM
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
dusoft
Party member
Posts: 792
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: Points moving on graph

Post by dusoft »

darkfrei wrote: Fri Apr 18, 2025 4:53 pm
knorke wrote: Mon Apr 14, 2025 2:10 pm your demos are super neat.
are you also working on some bigger project to use them?
Yes, I am makin the game, that needs alot of mechanics, one of them is path following along the graph structure.

https://www.youtube.com/watch?v=GbTO3S_-klM
Nice, is that a transport-related game?
User avatar
darkfrei
Party member
Posts: 1262
Joined: Sat Feb 08, 2020 11:09 pm

Re: Points moving on graph

Post by darkfrei »

List of Game Ideas

1. Urban Traffic Manager (Traffic Management Simulator)
Genre: Simulator, Puzzle
Description: The player manages a city's transportation system, controlling traffic lights, routes, and road signs to minimize congestion and accidents. The goal is to ensure smooth traffic flow as the number of vehicles increases.

Mechanics:
Routing: Use computePath to dynamically recalculate vehicle routes, avoiding congested roads (as in processNextEdge).
Collisions: Apply behaviour1 (on the same road) and behaviour4 (at intersections) to manage priority at junctions. For example, cars closer to an intersection get priority status.
Speed: Regulate speed using interpolateSpeed to slow vehicles as they approach others within a softRadius.

Visualization: Show interactionLines to highlight vehicles yielding to others (red color for yielding).
Uniqueness: The player can build new roads or modify the graph (adding nextEdges/prevEdges), influencing findShortestPath behavior.

2. Racing with Traffic
Genre: Racing, Arcade
Description: The player races in an open world, overtaking not only opponents but also avoiding city traffic. Victory depends on speed and maneuvering.
Mechanics:
Traffic: Use points.lua to simulate NPC vehicles moving along a road graph. behaviour2 and behaviour3 help NPCs avoid the player and each other at intersections.
Routes: Apply findShortestPath for dynamic NPC routing that adapts to the player's actions (e.g., avoiding roadblocks).
Speed & Collisions: Use interpolateSpeed to slow NPCs when near the player or other vehicles. Player gets penalties for collisions based on hardRadius.

Visualization: Display statuses (priority/yielding) as color indicators above vehicles to help the player anticipate traffic behavior.
Uniqueness: NPCs react to the player's driving behavior (e.g., aggressive driving causes traffic slowdown), using getDistanceSquared for proximity evaluation.

3. Post-Apocalyptic Caravan (Caravan Survival)
Genre: Strategy, Survival
Description: The player leads a caravan of vehicles across the wasteland, delivering resources between settlements. Avoiding bandits, managing internal traffic, and choosing safe paths are key.
Mechanics:
Caravan: Each vehicle is a point moving along road edges. behaviour1 ensures no collisions within the caravan.
Routes: Use findShortestPath to avoid bandit zones (add weights to calculateEdgeTravelTime based on danger).
Enemy Encounters: Extend getNextEdgesWithinRadius to detect bandits ahead and slow the caravan (behaviour2).

Visualization: interactionLines show which vehicles are yielding or under threat.
Uniqueness: Players can sacrifice vehicles to delay enemies or speed up the caravan at risk of collision (ignoring minSpeed).

4. Public Transport Tycoon
Genre: Simulator, Tycoon
Description: The player manages a public transport system (buses, trams, metro), optimizing routes and schedules to maximize profit and citizen satisfaction.
Mechanics:
Transport: Buses and trams are points moving along fixed routes (list of edges).
Collisions: Use behaviour4 to manage priority at nodes (e.g., intersections or stations).
Routes: findShortestPath helps build new routes when expanding the network (e.g., adding stations).
Speed: updateAvgSpeedOnEdges simulates route congestion affecting scheduling.
Uniqueness: The player can modify schedules (via spawnInterval) or add lines by editing the graph.

5. Space Freight Simulator
Genre: Simulator, Strategy
Description: The player manages a fleet of cargo spaceships delivering resources between planets, avoiding asteroids, pirates, and orbital collisions.
Mechanics:
Ships: Each ship is a point moving along orbital edges.
Collisions: Use behaviour3 to avoid ships converging on the same orbit.
Routes: Use findShortestPath with calculateEdgeTravelTime that includes fuel cost.

Visualization: interactionLines act as radar signals warning about nearby ships.
Uniqueness: Players can build new orbital stations by adding nodes and edges to the graph.

6. Emergency Services Dispatch
Genre: Simulator, Strategy
Description: The player manages ambulances, fire trucks, and police cars, dispatching them to calls while avoiding traffic and accidents.
Mechanics:
Vehicles: Each is a point with a target destination (targetNodeId).
Priorities: Extend behaviour1 to give emergency vehicles default priority, making others yield.
Routes: Use computePath to find the fastest route based on edge.avgSpeed.

Visualization: Highlight emergency vehicles in green and show interactionLines for yielding cars.
Uniqueness: Players can activate sirens to increase maxSpeed and slow surrounding traffic.

7. Traffic Rules Education Game
Genre: Educational, Simulator
Description: An educational game to teach traffic rules. The player controls a vehicle or pedestrian, interacting with AI traffic and earns points for rule compliance.
Mechanics:
Traffic: Use points.lua to simulate rule-following vehicles (e.g., stopping at red lights).

Collisions: Use behaviour1–behaviour4 to model interaction with the player, including rule violations (extend getPrevEdgesWithinRadius).

Scoring: Evaluate player actions by comparing them to AI behavior (priority/yielding).
Uniqueness: Interactive scenarios where players react to traffic violations (e.g., car running a red light).

8. Traffic-Based Tower Defense
Genre: Tower Defense, Strategy
Description: The player builds towers along roads to stop waves of enemy vehicles (e.g., smugglers), while avoiding disruption to civilian traffic.
Mechanics:
Routes: Use findShortestPath for enemy paths, blockable by towers (removing edges from the graph).

Visualization: interactionLines show civilians yielding to enemies, visualizing the chaos.
Uniqueness: Towers can slow traffic (edge.avgSpeed), affecting enemy routing.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
dusoft
Party member
Posts: 792
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: Points moving on graph

Post by dusoft »

Very cool!

I was working on something similar along ideas #4 and #1 around 2019 I think I had posted a couple of screenshots here on the forums.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 4 guests