Skip to main content
15 votes
Accepted

How do you determine what order to process chained events/interactions?

I don't think I'd put all of these effects into a single container at all, because as you show, any one container behaviour is unlikely to fit every use case you care about in your game. Instead, I'd ...
DMGregory's user avatar
  • 139k
11 votes
Accepted

How do you create a perfect maze with walls that are as thick as the other tiles?

If I understand you correctly, you want to create a densely packed maze like this, where each wall is the same thickness as each corridor: But you say the maze algorithms you've found only deal with ...
DMGregory's user avatar
  • 139k
11 votes
Accepted

Efficient Algorithm for the boundary of a set of tiles

Finding an algorithm is usually best done with a data structure that makes the algorithm easy. In this case, your territory. The territory should be an unordered (O(1) hash) set of borders and ...
Yakk's user avatar
  • 371
9 votes

Efficient Algorithm for the boundary of a set of tiles

If you need to find edges of holes in the middle of your territory too, then your linear in the area of the territory bound is the best we can do. Any tile on the interior could potentially be a hole ...
DMGregory's user avatar
  • 139k
7 votes
Accepted

Making dialogue different with each playthrough

There's a great GDC Talk by Elan Ruskin of Valve on what they call "AI-Driven Dialogue through Fuzzy Pattern Matching" or "Rule Databases for Contextual Dialogue and Game Logic" - it's the system that ...
DMGregory's user avatar
  • 139k
7 votes

How do I know the data has arrived at server without requesting every frame of the game?

REST is not the right paradigm for bidirectional communication, because with REST you can not send data which wasn't specifically requested. Hammering the server with repeated requests is not a good ...
Philipp's user avatar
  • 122k
7 votes

Efficient Algorithm for the boundary of a set of tiles

Notice: Whether or not a tile is on the boundary only depends on it and its neighbors. Because of that: It is easy to run this query lazily. For instance: You do not need to search for the boundary ...
Theraot's user avatar
  • 28k
4 votes

Programming with Python in a recent version of Minecraft

There are a wide variety of ways to interact with Minecraft programatically, including an official Javascript "add-on" API to the "bedrock" version of Minecraft, APIs for Minecraft ...
nealmcb's user avatar
  • 191
4 votes

Too slow for cycle in Pygame

Your problem here is that this does not work for CPU, it should be done using GPU, probably you can access it in pygame. It's the work of pixel shader and it works on very low level, with thousands of ...
Candid Moon _Max_'s user avatar
4 votes

How can I add biomes to my generated world?

A common technique for generating random worlds with large biomes is to use stock noise algorithms like perlin noise or simplex noise. Such algorithms generate noise patterns which generate a kind of "...
Philipp's user avatar
  • 122k
4 votes
Accepted

Efficiently find all points within a circle

About this algorithm: You don't have to check whether every object is inside the circle. If a node square is completely inside or outside the circle, you can use all objects in it directly without ...
Mangata's user avatar
  • 2,781
3 votes
Accepted

Three levels deep composition (player<-character<-spell), with preset character+skill sets

This looks like a job for the Flyweight Pattern! (Closely related to the Type Object pattern) Here you separate the concept of a character archetype from the instance of the character itself. You ...
DMGregory's user avatar
  • 139k
3 votes

Can OpenAL be used with Python?

PyOpenAL (released Dec 17, 2019): https://pypi.org/project/PyOpenAL/ pip install PyOpenAL You can use original OpenAL API but PyOpenAL has helpful wrapper functions....
8Observer8's user avatar
3 votes

Locking the frame rate in pygame?

clock.tick() only sets the loops at intervals of milliseconds, so at 60 fps, it will make each game loop at 16 milliseconds, not 16.6666 (which is what you need) ...
William Hou's user avatar
3 votes
Accepted

What is the difference between Pygames, Pyglet and Kivy and how each helps python game development?

The difference between the three frameworks/engines is the abstraction level. Pyglet is low level compared to the other two and is based on SDL, a popular C++ multimedia library. You'll have to use ...
Bálint's user avatar
  • 15.1k
3 votes
Accepted

How to compile a Python/Kivy game to an exe for Steam?

In the end, I found the answer hidden within their docs: Kivy > Programming Guide > Create a package for Windows You then need to set console=True to ...
mast3rd3mon's user avatar
3 votes

Separate objects for hitbox and sprite?

Instead of making your player object inherit from the sprite class you could use member variables for the sprite and rect. Your player class can then stand alone, and have separate sprite and rect ...
Jay's user avatar
  • 820
3 votes
Accepted

Need help with simple octree implementation

When you do newCentre = self.centre then that doesn't create a new array, but it uses the same object instead. If you modify ...
Bálint's user avatar
  • 15.1k
3 votes
Accepted

How do I port a game which uses print-output to pygame font rendering with the least amount of work?

This sounds like a pretty classic abstraction problem, general to all programming and not just games. I'll provide some explanation in terms of a text game though to suit your question. Absolutely ...
Sean Middleditch's user avatar
3 votes
Accepted

Perlin Noise generation always returning zero

A quick recap of how Perlin noise works: It starts by finding the cell your sample point lands in within an integer lattice. From that it determines the integer points that define the corners of that ...
DMGregory's user avatar
  • 139k
3 votes
Accepted

Generating different maps using Perlin Noise with a seed

Looking in the code, the library provides noise.randomize() which states: Randomize the permutation table used by the noise functions. This makes them ...
Pikalek's user avatar
  • 13.3k
3 votes
Accepted

How can I publish a Python game on itch.io as html?

Since mid-2022, pygame has partial support for WebAssembly as upcoming python3.11 and allows for running the same pygame code on desktops and mobile/web. To publish your game on itch.io as some people ...
Pmp P.'s user avatar
  • 156
3 votes

How do I store a branching board game path in python

Use an array of board space objects whose members include an array of other board space objects that it connects to. Then build a model of the board out of them. In pseudocode: ...
Almo's user avatar
  • 6,708
3 votes

How to properly set up a lives system for a side-scroller in pygame

The player loses many lives because you don't tell your game to ignore collisions after the first frame there is a collision. Since there is a collision detected each frame, another life will be ...
Vaillancourt's user avatar
  • 16.4k
3 votes
Accepted

Python GLFW and PyOpenGL: How to update a VBO from a thread while rendering at the same time

If you want to be able to read and write buffers while they're being used, you can use "persistently-mapped buffers". Be aware that by using them, you will become responsible for handling ...
the_Demongod's user avatar
3 votes
Accepted

Efficient way to check collisions for many objects

Looping through the bullet array and the collider array is brute force way of doing it and will cost (at worst) Bullet * Collider amount of checks which can be very ...
user3797758's user avatar
  • 3,651
3 votes
Accepted

Creating a nav mesh

TLDR: Which option to use depends on the need. Grid-based maps use navmesh will have additional workload, but the effect is better in most cases. Navmesh is essentially an optimization of a grid-based ...
Mangata's user avatar
  • 2,781
2 votes

RPG movement holding down button

I believe that this is what you were looking for: ...
Ethan McRae's user avatar
2 votes

Python float 32bit to half float 16bit

For some reason none of the other answers worked for me. So I tried to convert the C solution given here. I used the ctypes module to emulate C unions and types. I ...
Toun's user avatar
  • 458

Only top scored, non community-wiki answers of a minimum length are eligible