A new example project: Projectile Attack#294
Closed
Conversation
aabd090 to
5bf9e20
Compare
Member
|
Thanks @LuHaotian-UCL . There is a couple significant issues so I am going to close this PR and ask you resubmit Issues:
|
Author
|
@tpike3 I sincerely apologize for these serious mistakes. As I am still new to Mesa, I have taken more time to deepen my understanding of the framework and have revised the example I plan to contribute accordingly in a new pr #310 :
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A simple 2D projectile attack game built on the Mesa agent-based modeling framework, with a lightweight tkinter GUI. The project demonstrates how physical processes (gravity, wind, obstacles) and agent interactions can be integrated into an interactive simulation.
Motive
This project was created to explore how Mesa can be used beyond purely analytical simulations, extending into interactive and visual experiments. The project serves as a minimal but complete example of combining agent-based modeling, basic physics, and user-driven control in a single, self-contained application. It also provides an accessible reference for contributors interested in building educational or demonstrative simulations with Mesa.
Implementation
The implementation is organized into three core modules:
agents.pyDefines the main agents (
Tank,Shell,Target, andCloud) and their behaviors, including projectile motion, gravity, wind effects, collision detection, and explosion logic.model.pyImplements the Mesa model, grid, and scheduler. It manages global game rules such as wall placement, wind blocking, shell lifecycle, target movement, and automatic round resets.
run.pyProvides a
tkinter-based GUI for interacting with the simulation. Users can adjust firing angle, power, wind strength, wall position and height, and toggle target movement, while also handling rendering and the main simulation loop.Usage Examples
Start the game with directly running:
run.pyAdditional Notes
Adjust the angle and power sliders to control the projectile trajectory.
Enable wind to observe lateral drift and experiment with wall wind-blocking.
Toggle target movement to introduce additional challenge.
Press Fire to launch a shell when no projectile is active, and observe collision and explosion feedback.