How to get automatic stuff per second in my game [duplicate] - python

This question already has answers here:
Spawning multiple instances of the same object concurrently in python
(1 answer)
Is there a way to have different tick rates for differents parts of my code in pygame?
(1 answer)
Closed 9 months ago.
I am making a game in python using pygame in which you click a candy and you get candies. This game is similar to the famous game 'Cookie Clicker'. I've got the clicking part done but I have no idea how to do the auto candies per second. If anybody knows how to do this, please tell me.

Related

timer in python code but like a montlyh subscription [duplicate]

This question already has answers here:
set a Python program to expire after a certain number of days
(1 answer)
Simple license protection for Python app
(1 answer)
Closed 10 months ago.
I'm a new coder.
That's why I have a program that I want to ask, but I need to create a timer and the program should not open when the timer is finished, how can I do this? Can you help me with this?
What should I try in this program and make a similar monthly subscription?
import time
time.sleep(5)
5 being the seconds waiting

Use python to open right click menu [duplicate]

This question already has answers here:
tips on Adding/creating a drop down selection box in pygame
(1 answer)
trying creating dropdown menu pygame, but got stuck
(1 answer)
Closed 5 months ago.
So i'm making a GUI with pygame, with some game elements that I need pygame to do.
But I need to make a context menu on right click.
It doesn't have to be in pygame, it could be a command in the os or sys modules. I just need a way to open one of these menus, and I can activate it on right click.
Sorry if my question is not clear, I really don't know how to explain it.

Pygame keeps crashing [duplicate]

This question already has answers here:
Pygame unresponsive display
(1 answer)
Pygame window not responding after a few seconds
(3 answers)
Closed 2 years ago.
I just made a pygame when you click the screen it changes the color to a random color stored in a variable called backgroundColor. At the beginning of the while loop it does display.fill(backgroundColor) .
I started clicking the screen really fast. But after about 8,000 cycles the screen turns white and stops doing anything. Does anyone know why the game crashes after so many color changes.

How to use sounds and channels on pygame? [duplicate]

This question already has answers here:
how to play wav file in python?
(5 answers)
How can I play an mp3 with pygame?
(7 answers)
Closed 2 years ago.
I'm trying to add to my game background music with sound effects and I understood that the best way to do it is with channels and sounds, so I tried it but when I play a sound sound_name.play() or play it with a channel channel_name.play(sound_name) it does nothing, and when I add a delay it beeps.
Does anyone know how to figure it out or has a better way to play some sound on my game (when one sound doesn't stop or reset the other sound)?
Thank you :)

How do I clear the output screen in python? [duplicate]

This question already has answers here:
Clear terminal in Python [duplicate]
(27 answers)
Closed 4 years ago.
I am making a text based rpg in python 3 and the output window gets very cluttered cluttered. I was wondering if there was a way to clear the screen automatically from time to time.
import os
os.system('cls')
You can use os.system('clear') if you are on linux.

Categories

Resources