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
  • 134k
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
  • 134k
8 votes

How can I make the player "look" to the mouse direction? (Pygame / 2D)

First you need to calculate the vector pointing from your player to the current mouse position. This can be done by subtracting the player's position with the mouse's position: ...
Ted Klein Bergman's user avatar
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
  • 134k
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
  • 119k
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
  • 26.6k
4 votes

Collision detection with PyGame

The Pygame Rect already comes with a few collision detection functions that may just do what you need: pygame.Rect.contains: ...
Lucas Siqueira's user avatar
4 votes

How to structure code for many unique weapons/spells/powers

Data-Driven Design I submitted something like this question to code review recently. After some suggestions and improvements, the result was a simple code that would allow some relative flexibility ...
Lucas Siqueira's user avatar
4 votes

Add Boo or Python to Unity 5

Unity's primary development language is C#. I am not aware of any way to add a new scripting language to Unity which works just like a native one. But you can call Python from C# using IronPython. ...
Philipp's user avatar
  • 119k
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

How do I sort with both depth and y-axis in OpenGL?

You'll need An orthogonal Projection Matrix. In fixed pipeline openGL: glOrtho(0, screen_width, screen_height, 0, -(1<<16), 1<<16) A wrapper function ...
JBeurer's user avatar
  • 467
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
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,516
3 votes

Rotating hitboxes in PyGame?

Building on Tyyppi_77's answer above, there are a few approaches you can take: 1) Resizing the hit box (as he suggests) - although you can do it much much easier just by using image.get_rect(), which ...
Chris's user avatar
  • 191
3 votes

Pygame time.get_fps() value

Looking at the implementation of clock.tick() and where in that module the FPS value is set (search for _clock->fps =), the documentation seems to be correct ...
Thomas Perl'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

How should I efficiently store faction relationships?

You could keep the factions in a dictionary inside your scenario/map/level instance, using ("groupA", "groupB") tuples as keys to store the relations between groups....
Lucas Siqueira's user avatar
3 votes

PYGAME: When I release two directional keys together the player keep moving

In pygame (and many other frameworks like it), events are received in an event queue. Multiple events can arrive per frame, for example when you press or release two buttons together. You need to ...
congusbongus's user avatar
  • 14.8k
3 votes
Accepted

A python script controlling a Unity game

Ok so first follow this tutorial. Then i wrote some code to try and test it out. C# code. I used the editor example from the tutorial but you can make it run during runtime or what ever: ...
Uri Popov's user avatar
  • 3,007
3 votes
Accepted

2d MMO world generation?

I couldn't tell from your question if your world is top down or side on. But I'm going to assume top down for my answer. If you just want the blocks to be totally random, all you'd need to is go ...
Grady's user avatar
  • 435
3 votes
Accepted

Performance drawing in Pygame

I resolved the issue I was facing severe fps drops using my background image and blocks. Though I changed it so when I loaded them into my program, I used .convert() at the end. The .convert() made a ...
Kyle's user avatar
  • 69
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
  • 134k
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
  • 14.9k
3 votes
Accepted

Python/Kivy game for steam

In the end, i found the answer hidden within their docs https://kivy.org/docs/guide/packaging-windows.html 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
  • 810
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
  • 14.9k
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
  • 134k

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