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
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; } } }