Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 1101

Python is a dynamically and strongly typed programming language that encourages readability.

4 votes
Accepted

Pygame window becomes unresponsive when I click it

Traceback (most recent call last): File "C:\Users\Kylotan\Desktop\test_pg.py", line 31, in <module> if event.type==pg.event.QUIT: AttributeError: 'module' object has no attribute 'QUIT' I adde …
Kylotan's user avatar
  • 24.4k
0 votes
Accepted

How to handle multiple game sessions where players turn can timeout, using Python and Socket...

This isn't so much of a Python issue as a Django issue - there are many ways in Python (and indeed most languages) of watching for a time to pass, but the problem is how you act upon it. …
Kylotan's user avatar
  • 24.4k
1 vote
Accepted

Trying to make a python map editor

The general process here is simply something like this: for row_number in rows: for column_number in columns: value = data[column,row] if value == 1: obj = ObjectType1() elif valu …
Kylotan's user avatar
  • 24.4k
1 vote
Accepted

Pygame circular cropping/masks

Generally speaking it isn't possible to do real-time per-pixel masking with software renderers if performance is a concern. So you need to do the processing offline. I don't understand the task you a …
Kylotan's user avatar
  • 24.4k
0 votes

How to detect whether or not a tile is occupied?

If your tiles are rectangular, and if you make your tiles a 2D structure rather than a 1D structure then you can deduce the boundaries in world coordinates from the tile's position in 'tile coordinate …
Kylotan's user avatar
  • 24.4k
2 votes
Accepted

Embedding Pygame to C++

When you embed Python into C++, you just have to set up the code to call the Python functions in C++. … The Python libraries that you use, such as Pygame, have no effect on the C++ binding code you need to use. …
Kylotan's user avatar
  • 24.4k
4 votes
Accepted

How do I detect multiple sprite collisions when there are >10 sprites?

There is no 'proper' way, just different approaches that vary from simple-but-slow to complex-but-fast. You can stick with that method, if your car list is small enough. However, there is a bug in yo …
Kylotan's user avatar
  • 24.4k
2 votes
Accepted

How to implement rectangle selection?

For a rectangular selection, it would be a lot like your existing code. def mouseDown(self, button, pos): self.selection_rectangle_start = self.coord_convert(pos) def mouseMotion(self, pos): …
Kylotan's user avatar
  • 24.4k
4 votes

Loading data for an RPG

Load everything at the start. Don't complicate your program by splitting data between memory and disk unless you have to (eg. when there is too much to hold in memory at once). The important thing is …
Kylotan's user avatar
  • 24.4k
1 vote

Searching a map fewer times

Swap the map for a hash_map or an unordered_map (whatever your compiler supports).
Kylotan's user avatar
  • 24.4k
4 votes

How do I sync entity ids with the server and client?

You're using Python, so you should use a dict for this, mapping unique values to each item, letting you remove items without affecting the positions of others. …
Kylotan's user avatar
  • 24.4k
2 votes

Multithreading for a mixed-genre game in Python?

In addition to what Adam has already said in his answer (and especially the second paragraph), it's worth noting that Python does not scale well with threads at all, because there is a global lock shared … across all Python threads so that only one can run at a time, except under certain conditions. …
Kylotan's user avatar
  • 24.4k
1 vote

Pygame set_colorkey transparency issues

Interesting. My guess is that the Convert call is changing the image into a form that does not have the 255,0,255 colour in it any more. You may need to read a pixel from the converted image which you …
Kylotan's user avatar
  • 24.4k
1 vote
Accepted

Pygame's rotation methods have crippling issues, but is it me or Python's pygame?

In Python, that usually means pyglet, but you can roll your own using pyopengl. …
Kylotan's user avatar
  • 24.4k
3 votes
Accepted

Pygame 2D Scrolling Map

You accomplish the scrolling by moving the camera, and calculating the screen position for a tile based on the current camera position. You can skip drawing of any tiles that are not on screen. def d …
Kylotan's user avatar
  • 24.4k