DungeonGenerator | Procedural Dungeon Generation with Python and Pygame
kandi X-RAY | DungeonGenerator Summary
kandi X-RAY | DungeonGenerator Summary
Procedural Dungeon Generation with Python and Pygame. I wrote this after reading an article on "Procedural Dungeon Generation Algorithm". To be honest, I'm a sucker for graph paper dungeons and the word 'algorithm' so it was impossible for me to avoid implementing the dungeon generator described in the article. This code is very dependent on the excellent pygame framework. The Generate module will put up a window and draw each phase of the algorithm as described in the article with it's animated gifs. The StateMachine module was something I reused from my pacman implementation to help keep everything from happening at once. Dungeon is the interesting part, describing a Dungeon class that manages Room objects. The biggest diversion between the article and my implementation is my failure to implement a Delauny triangulation to build a guarunteed connected graph. My graph uses a closest neighbor function that mostly generates connected graphs but sometimes results in two islands. A lesser diversion is the hallway construction where I admit I got lazy. My only defense is it looks like a more "Dwarven" dungeon to my eye, so I kept it. I hope this provides someone some amusement, I enjoyed writing it.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Generate a random dungeon
- Connect rooms to rooms
- Center the rectangle in a rectangle
- Adds a random room
- Check if two rooms collide
- Repulse another point
- Check if two rooms collide
- Process state action
- Dispatch the pressed key
- Dispatch all registered events
- Snap a rectangle to a grid
- Check the state of the game
- Dispatch events
- Convert a screen coordinate to a grid
- Dispatch the game
- Called when entering main room
- Renders the main room
DungeonGenerator Key Features
DungeonGenerator Examples and Code Snippets
Community Discussions
Trending Discussions on DungeonGenerator
QUESTION
I'm attempting to generate random dungeons using prefabs.
I have it working to where it will pick a random doorway from a list of doorways and spawn a new room. I then have a script on the bounding box to update the room script for when it intersects another room.
The issue that I am currently having is that I'm not entirely sure on how to wait or delay to check and see if the onTriggerEvent
has been called.
I'm currently checking to see if there was a collision, and setting a boolean
variable to true when that happens otherwise it's false. This always results with the variable being false even though there is collision occurring.
Edit:
This is currently how i'm checking to see if a room is valid:
DungeonGenerator.cs:
...ANSWER
Answered 2021-Sep-20 at 18:25You can use OnTriggerStay()
if I understand correctly, as it returns true if there is something in the trigger and false otherwise. If you are using 2d, use OnTriggerStay2D()
. To use it, just define it as a function like you would normally, with an argument of Collider other
, with Collider being the type, and other being the other collider.. Then, you can check details about the collider(for example you can check if it's the player) and then do stuff to the other collider(and by extension, the entire object) and the object the script is attached to. Here is an example, but it may require tweaking to perfectly fit what you want to do.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install DungeonGenerator
You can use DungeonGenerator like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page