Move Sprite Every Second
p_loo (0)

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 repl.it if anyone can help, thanks in advance: https://repl.it/@p_loo/SwampGame-Ask

You are viewing a single comment. View All
mwilki7 (284)

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

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