pygame quit( sys exit( if event key =k_left or event key =ord(' ') moveleft false if event key =k_right or event key =ord(' ') moveright false if event key =k_up or event key =ord(' ') moveup false if event key =k_down or event key =ord(' ') movedown false if event key =ord(' ') player top random randint( windowheight player height player left random randint( windowwidth player width if event key =ord(' ') if musicplaying pygame mixer music stop( else pygame mixer music play(- musicplaying not musicplaying if event type =mousebuttonup foods append(pygame rect(event pos[ event pos[ ) foodcounter + if foodcounter >newfood add new food foodcounter foods append(pygame rect(random randint( windowwidth )random randint( windowheight ) ) draw the black background onto the surface windowsurface fill(black move the player if movedown and player bottom windowheight player top +movespeed if moveup and player top player top -movespeed if moveleft and player left player left -movespeed if moveright and player right windowwidth player right +movespeed