https://docs.godotengine.org/en/stable/tutorials/physics/physics_introduction.html
Also https://www.youtube.com/watch?v=x5e0EMLaz1Y
The first thing you need to do is set up collisions. The bare minimum is using the same collision shape for solids (level) and enemies/powerups
Once the game is detecting collisions, that's where you apply the logic, in this case, inside the signal function, usually _on_Area2D_body_entered(body)
.
func _on_Area2D_body_entered(body):
if body == enemy:
mario_shrink()
elsif body == mushroom:
mario_grow()
If you're having trouble figuring the logic, I highly recommend taking some math logic and/or programming logic studies.
For this particular case, you can either have two collision shapes, one for big and one for small Mario, or have one shape and have it grow OR shrink depending on powerup or if he's crouching.
If the touch detected an enemy, first you check if Mario is big. If he is, shrink him. If he's already small, kill him. If the touch detected the mushroom, you check if Mario is already big: if he's not big, make him grow and either modify the collision shape OR deactivate small shape and activate big shape, otherwise just give 1000 points.
Similarly, for checking if Mario jumped on an enemy, you can compare both objects' Y position and assume that if Mario's Y position is 8 pixels lower than the enemy's, the enemy dies, otherwise Mario gets hit. Note that a lower Y position means the object is further up.