Trick or Treat
Challenge:
A user on Ghost Town created a game that he claims no one can beat. Check out the game and find the flag hidden inside. Submit the flag as:
flag{flag-goes-here}
.Download file
SHA1: 610430cb737a2a8478a9b9c53535e58010f14a91
Password:d34df4c3
Solution:
The gameplay consisted of Grim Reapers dropping from the top of the screen and the player had to move their player to avoid colliding with the Reaper. The Reaper's movement speed increased after each successful dodge, making it increasingly difficult to dodge fast enough, thus ending the game.
After spending time reviewing the code we identified where the collision detection was performed int the get_intersect()
function and simply replaced it with a pass
:
def get_intersect(x1, x2, w1, w2, y1, y2, h1):
if y1 < (y2 + h1):
if x1 > x2 and x1 < (x2 + w2) or (x1 + w1) > x2 and (x1 + w1) < (x2 + w2):
#do_coll()
pass
We could then re-run the game and let it accumulate the "dodged" score. Once the score reaches 100 the flag was printed to the terminal:
$ python3 game.py
pygame 2.0.2 (SDL 2.0.16, Python 3.9.7)
Hello from the pygame community. https://www.pygame.org/contribute.html
flag{
flag{CaNT_ch34t_d34th}
Leave a comment