Skip to content

Tag: pygame

Python AttributeError When Attribute is Set

I am creating a snake clone using pygame and I am running into a strange problem. I have a class called snake_tile that inherits from the pygame rectangle class with one additional attribute, the direction the tile is moving: I pass in a tuple as the direction when initializing the snake_tile object: Which will serve as the offset when I

Cannot Change Individual Elements in an Array

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

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

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