Questions tagged [pygame-tick]
39 questions
22
votes
4 answers
pygame clock.tick() vs framerate in game main loop
Every pygame has a game loop that looks like this:
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.display.flip()
print("tick " +…

ERJAN
- 23,696
- 23
- 72
- 146
5
votes
1 answer
How do I stop more than 1 bullet firing at once?
import pygame
pygame.init()
red = 255,0,0
blue = 0,0,255
black = 0,0,0
screenWidth = 800
screenHeight = 600
gameDisplay = pygame.display.set_mode((screenWidth,screenHeight)) ## screen width and height
pygame.display.set_caption('JUST SOME…

Daniel Gallo
- 89
- 6
4
votes
2 answers
Pygame - Is it possible to change the background image in relation to time?
I'm using pygame in order to create a sort of animation. What I have in mind is to have a series of background images change in relation to the time that has passed once I initiate the game. I came up with this code to do so:
while True:
…

Celina.
- 45
- 3
2
votes
2 answers
Pygame Resetting Timer between Clicks
I'm trying to do a small school project it's very simple and basically, all you do is click on randomly appearing donuts on the screen each click gives a point and everything is ok up until there, I tried to do a timer that will reset when you click…

Irkl1_
- 71
- 2
- 8
2
votes
1 answer
PYGAME : Why does calling a function inside the game loop inside Game loop make my game lag?
I am making a simple game where enemies move around on the screen and we need to shoot them.I wanted to modularize my code so I wanted to replace the game loop logic with a function.But as soon as I do that, there's a drop in fps. Does calling a…

Savannah Madison
- 575
- 3
- 8
- 17
2
votes
1 answer
Trying to change image of moving character in every 0.25 seconds PyGame
So i am trying to 'animate' my character in pygame by changing between 2 pictures when he walks. I tried to use the code that was mentioned here: In PyGame, how to move an image every 3 seconds without using the sleep function? but it didn't turn…

Einliterflasche
- 473
- 6
- 18
2
votes
1 answer
Framerate affect the speed of the game
I am practicing on pygame and I was wondering how can we do so that the framerate does not affect the speed of execution of the game
I would like FPS to not be locked and the game to always run at the same speed.
Until now I used the…

Tangax
- 43
- 5
2
votes
2 answers
Improve performance while executing pygame?
My pygame is running way too slow. Without using class oop it was running perfectly but now using oop its very slow.
I have tested putting that separate class file in main file also but the result was same.
import pygame
from snake import…

sajan poudel
- 23
- 3
1
vote
1 answer
stopping pygame animation on the last frame, using temporary variable
I have this function which triggers players death animation:
def draw_player_death_animation(self):
self.is_player_image = False
death_duration = 400
animation_time = pg.time.get_ticks() % (3 \* death_duration)
frame_index =…

Petras Anskaitis
- 19
- 3
1
vote
2 answers
Pygame clock tick stuttering
This is an issue that has been bugging me for a few weeks now. Whenever I have a pygame clock variable, so for example: clock = pygame.time.clock and I limit the fps using: clock.tick(fps) the game will occasionally stutter. I have a simple example…

NotAHackusator
- 13
- 4
1
vote
1 answer
Second surface doesn't appear on screen until I freeze the game
I'm trying out Pygame and started with a classic, creating the Snake game, the issue is that I try to blit the 'apple' on the board but the apple doesn't appear up until I crash in the walls this is when I set fps = 0 and I freeze the game. I've…

Uponn
- 199
- 2
- 3
- 15
1
vote
1 answer
pygame.display.update causing flickering or not showing anything
In my game I am trying to make it so when you walk into a object, it displays an image.
I'm pretty sure that pygame.display.update() is being called every frame because otherwise the game would be perfectly still.
However when I draw my new rect…

William Redding
- 23
- 2
- 4
1
vote
1 answer
pygame tetris fever_mode adding timer
i = 1 ## fever_interval = 3
if score > i * 100:
pygame.time.set_timer(pygame.USEREVENT, 5)
mino = randint(1, 1)
next_mino = randint(1, 1)
next_fever = (i + fever_interval) * fever_score # 피버모드 점수 표시
…
user15716685
1
vote
1 answer
Issues with pygame.time.get_ticks()
I have a game where I need an enemy to spawn after every 1350 milliseconds in a path. And the enemies only start coming after I click on the start button.
Time interval code:
sendEnemy = 0
def enemy_object_creation(sprite_list, health):
global…

PradMaster
- 83
- 10
1
vote
1 answer
How can I randomly make holes in snake?
I have snake that is turning and drawing trajectory behind him but I don't know how to make holes like random pauses while he's drawing. I tried it and it's not random but problem is that it's very fast pause. It's like teleporting move.
Here is my…

David d
- 37
- 5