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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 "...
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 ...
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 ...
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 ...
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 ...
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....
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) ...
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 ...
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 ...
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 ...
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 ...
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♦
- 6,738
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 ...
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 ...
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 ...
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 ...
2
votes
2
votes
Accepted
Reflect Code Changes in a Current Run
This answer will be short because I'm on my phone.
I haven't watched the video from your link, but a way you could accomplish something like this this for your code's parameters is:
isolate all ...
2
votes
How can I resize pixel art in Pyglet without making it blurry?
Modern pyglet lets you set the default texture filtering by modifying a couple class attributes on Texture. Pyglet docs even explicitly mention "retro style ...
2
votes
Simple 2D games - what is faster to render - images or drawing?
Blitting is always faster on todays machines. One reason is that you do not need any other calculations except adding indexes. Even for a Polygon you need multiple calculations per line instead of a ...
2
votes
Simple 2D games - what is faster to render - images or drawing?
When in doubt, measure it. Programmers can make educated guesses, but they are just that: guesses. If you really want to know what's faster in your case on your target platform, create a benchmark. ...
2
votes
Accepted
Trouble creating a "Game Log" for a text-based RPG
So there's a couple steps to this:
You need a list to handle the log messages.
You need a function to print events to the list. How you do this is up to you, but it needs to be a function you can ...
2
votes
maya script editor: how to keep python code after execute
I find the best way is script editor > file > save script, i save script to test.py, script editor will create "test.py" tab, run code in this tab will not clear code after code is executed
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
python × 635pygame × 344
collision-detection × 61
2d × 33
opengl × 29
sprites × 26
c++ × 22
pyglet × 19
optimization × 18
physics × 17
3d × 16
mathematics × 16
unity × 15
scripting × 14
animation × 13
architecture × 13
movement × 13
c# × 12
procedural-generation × 12
vector × 11
image × 11
tilemap × 10
rotation × 9
algorithm × 9
graphics × 9