Questions tagged [pygame-clock]

This tag is for questions about clocks and timing in pygame.

The tag is related to . Timing is supported by the pygame.time module.

74 questions
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
2 answers

Pygame moving object /image repeat itself

I'am building a simple game using pygame ,the function of this game is to control an image and make it move up/down left/right but i got this problem, the image repeats itself when moving down or aside import pygame pygame.init() display_width =…
1
vote
1 answer

Pausing time.time flow

I making a game with Python and Pygame, and I'm using time.time to time the users going through levels. However, I also have a pause menu. How can I make so when the pause menu is open, time.time won't continue?
Will6316
  • 71
  • 7
1
vote
1 answer

pygame: how do I get my game to actually run at 60fps?

In my main loop I have: clock.tick_busy_loop(60) pygame.display.set_caption("fps: " + str(clock.get_fps())) However, the readout says the game is reading at 62.5fps. I then tried to input clock.tick_busy_loop(57.5), which gave me a readout of…
Null Salad
  • 765
  • 2
  • 16
  • 31
1
vote
0 answers

Latency in reading from keyboard input in Pygame

I am trying to measure the time between a certain event displayed on the screen and until user responses with a input key in pygame. I hope to make the measurement as accurate as possible. What is the expected/worst case latency in pygame? And,…
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…
0
votes
2 answers

Where should pygame.time.Clock().tick() be called in the script

According to this statement, pygame.time.Clock().tick() should be called at the end of the main loop. However, I couldn't see any differences on my screen display regardless where I executed that method within the loop. Could someone please give…
Nemo
  • 1,124
  • 2
  • 16
  • 39
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…
0
votes
0 answers

PyGame display flickers between frames on RPi CM4 only

I have the following code, which is a simplified from a project I'm working on. I thought the issue was the same as Why is the PyGame animation is flickering, but with the simplified code below, I've confirmed that I'm only calling…
ZPears
  • 51
  • 7
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…
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
0 answers

Pygame function not returning values

So I am trying to make a game that operates using pygame, and I think there is an issue with display updating. Normally buttons work, but I think I am not formatting this correctly. Here is the relevant code: while run: …
Schmetris
  • 1
  • 2
0
votes
2 answers

Pygame error: "module 'pygame' has no attribute 'get_ticks'"

I am learnining pygame and I got error "module 'pygame' has no attribute 'get_ticks'". What do i have to do? My code was: start_ticks = p.get_ticks()
0
votes
1 answer

Timer doesnt go lower?

I'm creating a Snake game. When I lower the cooldown of the Timer I want the snake to move faster. It's actually working, but only if I change the number of the game speed before starting the project. If I start the project and change the timer in…
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