so im programming a maze game for my game design class and when the player touches a portal the wasd keys are supposed to invert tbh i have no idea how tf im supposed to do this and any help would be appreciated
![Twitter](/assets/twitter-4e19209ef84344ee0c433f4c7bad8d49.png)
![Twitter.hover](/assets/twitter.hover-1fb19a5bafc50deace8f88eaec867845.png)
import greenfoot.*; public class main extends Actor { int speed = 2; int dir = 1; public void act() { move(); invert(); } private void move() { int dx = 0, dy = 0; if (Greenfoot.isKeyDown("a")) dx--; if (Greenfoot.isKeyDown("d")) dx++; if (Greenfoot.isKeyDown("w")) dy--; if (Greenfoot.isKeyDown("s")) dy++; setLocation(getX()+speed*dx*dir, getY()+speed*dy*dir); } private void invert() { if (isTouching(funnyinvert.class)) { removeTouching(funnyinvert.class); dir = -dir; } } }