I am trying to make a tic-tac-toe game, and I currently have a 3×3 tiled board grid to represent the game. When a user clicks a square, the program sets board[x][y] to 1. board = [[[0, 0, 0], [0, 0, 0], [0, 0, 0]] Unfortunately, whenever I click a tile, it seems to ignore whatever x value I put; every
Tag: pygame
Why don’t three R, G and B circles blend correctly?
I am trying to represent the RGB color model using python + pygame. I wanted to get the following: So then, I wrote the following code: But instead of getting the RGB color model, I got this, with colors incorrectly blended: Does anybody know what it could be? Thanks! Answer This should work: You want to add the colors at
Elastic collision simulation
I’m trying to simulate elastic collision using the One-dimensional Newtonian equation (https://en.wikipedia.org/wiki/Elastic_collision) with pygame. The thing is that even if I transcribed the solved equation to change the velocity of the 2 bodies, it is not working (or probably there is something wrong with the code). Here it is the code: Since the 2 masses are equal, after the collision
Pygame collision checking lists of hit boxes against each other only checks the last box in the list
I am coding a game in pygame and my entity objects have attribute lists of hit boxes. All the hit boxes are pygame.rect objects and when i have them drawn on the screen all of them show up but for some reason the objects only act like they collide if the last hit box in their list collides with the
install pygame module for python2.7
I already installed pygame for Python3 (on windows) But now I want to run a source code written with Python2.7 It gives this error when I run the code : ImportError: No module named pygame how can i use pygame for python2.7?(how can i fix it?) thanks Answer I solved my problem by using pip for different versions of Python
How can i get the number of an image of a certain sprite in pygame
I randomly share pictures of houses on the screen. Then I drive a car across the screen.When the car hits a house, the image of that house should be replaced with a modified copy of that house. I distribute the images with the following function I check the collision car with house …. How do I then get the house
How to keep running a nested While in python
I have a pygame. in it there are a few nested while loops, running all of them one time accomplish one round, how do I keep rounds going and going, never stop? Repeat{I have a pygame. in it there are a few nested while loops, running all of them one time accomplish one round, how do I keep rounds going
Python Snake Game snake does not follow
I am creating Snake game in pygame using Sprite logic how do i chain the movement of the snake? another question on this has been answered here but i cant apply it to my code: see here the minimal example above works. try it first and you will see my issue :) the snake grows on collision with the red
Pygame Erases Previous Drawing
When I run the draw 3 nodes function, only the final node and link is drawn when I want all 3 nodes and links to be drawn. I did some testing and I believe it draws all of the nodes, but when it moves on to the next node it erases the previous one. I’m not 100% sure if my
How could I stop or delay a Pygame timer, which is linked to an User event?
I’m new to python, but I’m trying to learn it by myself for a university course. Therefore I have to program a pygame window that represents a drone fly zone (The drone should fly automated like a search helicopter in a given area and on the window a visual representation of what happens should be displayed…). How an older version