Skip to content
Advertisement

Tag: pygame

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

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

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

Advertisement