Ok, ok, ok let’s back it up a bit here. How far are you? That code in VERY limited and will accomplish nothing. First you want a loop where you constantly define :“flag”
Then you want to move to that flag.
self.moveXY(flag.pos.x,flag.pos.y) or self.move(flag.pos)
But honestly I don’t see the use of flags for this level.
Do that same as above except with items to collect gold.
Then you can be creative and attack attack, projectile dodging etc…