Ask coding questions

← Back to all posts
Move Sprite Every Second
p_loo (4)

I would like to create a boss entity that changes its position every few seconds (not smoothly, more like teleportation). I am using a Class to create my boss sprite, but I do not know how to make it change its position randomly every few sections. I tried using functions such as pygame.time.set_timer(), but I couldn't get it to work. The game isn't complete yet, so some things (such as the health bar) aren't completely functional yet. I wanted to complete the functions of the characters first. Here's the link to my if anyone can help, thanks in advance:

p_loo (4)
mwilki7 (1078)

Use your clock to get it to teleport some time in the future

boss.nextTeleport = clock + 100
if boss.nextTeleport < clock:
    randomize position here