Questions tagged [pygame-tick]
39 questions
1
vote
1 answer
How to create timers in pygame efficiently?
I want to spawn an enemy every (some number) seconds, say 5.
I could do:
start_time = pygame.time.get_ticks()
if pygame.time.get_ticks() - start_time >= (some number):
spawn_enemy()
But there's one problem with that: when I change the FPS…

LMCuber
- 113
- 1
- 11
1
vote
2 answers
I made velocity changing to make dash but want to add here some dash-lenght limit
so I made my character(player) to change its velocity faster if I press 'L shift' while pressing 'left key' or 'right key' at the same time.
The problem is, I wanna make this 'dash' to stop when it reached to the limit I set. I want my character not…

In Summ
- 13
- 4
1
vote
1 answer
Facing lag in pygame while using pygame.time.delay()
I'm building a Hangman game as my first Pygame project. Once the game ends, I want the screen to pause for a second and then display a result message for a few seconds, before exiting the game. I have the following function for that:
def…

videzign
- 11
- 3
1
vote
1 answer
How to provide set of predefined instructions in pygame
I am new to pygame and not a regular coder. I am trying to wright a pygame code which accepts set of instructions from a text box and then move the image accordingly. eg: When you execute the code the pygame window will open with a textbox & primary…

vivs
- 113
- 1
- 1
- 8
1
vote
1 answer
Pygame snake velocity too high when the fps above 15
I am having a hard time figuring the physics of speed in this snake game I made using pygame.
The issue is that as soon as I set the fps to be above 15, the snake's speed increases as well.
I know that this has to do with milliseconds etc which I…

Kevin
- 364
- 1
- 2
- 13
1
vote
1 answer
How to rotate Element around pivot point in pygame?
I am trying to rotate an element (in my case font) in pygame around a pivot point my code is as follows:
import pygame, time
pygame.init()
display_width = 800
display_height = 800
window =…

Rob
- 43
- 3
1
vote
1 answer
Pygame suddenly lagging after adding a bit of code, but why?
I have a game I made with Pygame and I added a "small" update to where a sprite changes to another sprite for 80ms when pressing space, this makes the whole game lag (not just when pressing space but all the time). Can anyone help? :)
Here is SOME…

NorwegianNoob
- 87
- 9
1
vote
0 answers
drawing loop inside update loop (per second)
My code simplified:
Clock.tick(UPS): #updates per second
game.update()
for frame in range(FPU) #frames per update
game.draw(frame)
What it should do is that every second there should be a number of updates equal to UPS value. After…

Brambor
- 604
- 1
- 8
- 25
1
vote
1 answer
Pygame - Run event for 3 seconds only once
I am fairly new to PyGame and I am creating a space shooter game. Part of this game are powerups and when a specific powerup is picked up by the player, I want the player not to be able to shoot for 3 seconds. Shooting is done by mouse click.
I can…

Adrian Daniel Culea
- 181
- 5
- 13
0
votes
2 answers
My pygame timer keeps resetting after I hit a target in my aim game
I am trying to make an aim game where a target pops up and once the player clicks on it, the target vanishes and a new one appears in a random location, I want it so that there is a 10 second timer but it keeps going back to 10 each time a target is…

Mstead06
- 1
0
votes
1 answer
How do I reset pygame.time.Clock()?
I made a sudoku game for my introduction to computer programming class and I want to expand it over Winter break by adding some new features. The first of which I want to be a clock. I found some code on here that helped me implement a clock system…

WilsonGoins
- 11
0
votes
1 answer
How to periodically spawn objects in Pygame
elif x1 == foodx2 and y1 == foody2:
foodx2 = round(random.randrange(0, dis_width - snake_block) / 10.0) * 10.0
foody2 = round(random.randrange(0, dis_height - snake_block) / 10.0) * 10.0
Length_of_snake += 2
this is the code…

Albedo
- 1
- 2
0
votes
1 answer
Score system based on a timer doesn't work in Pygame
So, me and a few friends are working on a Python Project for school and we want to implement a score system in which the score gets bigger every few seconds. We have already searched the web for possible solutions, but we couldn't find anything that…

Sciux
- 1
0
votes
1 answer
Is there any relation between fps and how fast a surfaces moves on the screen?
Here is an example code:
import pygame
import sys
pygame.init()
screen = pygame.display.set_mode((1000, 500))
clock = pygame.time.Clock()
square = pygame.Surface((350, 350))
square.fill((0, 0, 0))
x_pos = 1000
while True:
screen.fill((255,…

just a random person
- 17
- 5
0
votes
1 answer
Pygame low frame rate but waiting on input instantly
I want to create simple game in python with pygame. There are some buttons, but it doesnt respond sometimes. I want to have low frame rate because its simple game but also i want to have buttons waiting on click like always. is it posible?
Its like…

MildyS
- 15
- 5