# How to do other sides

i cant figure out how to use this code in other directions.

this line of code checks if something on its west side is in range and then it presses z. this works but i cant seem to figure out how to do it for its northwest side, its north side, its northeast side, its east side, its southeast side, its south side and its south west side.

`if ((targetx < (gx + 20)) && (x > (gx - 20)) && (targety < (gy + 20)) && (targetx > (gy - 20)))`

for context, here is the rest of the code:

``````int x=1;
int y=0;

int gxbeta=0;
int gybeta=0;
int gx;
int gy;

int targetx=0;
int targety=0;
int i;
int h;

float dice=0;
color z=color(76,140,90);

color red= color(180,78,84);

color damage= color(255,247,19);

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;

Robot robot;

void setup(){
size(20,20);
//Let's get a Robot...
try {
robot = new Robot();
} catch (AWTException e) {
e.printStackTrace();
exit();
}}

void draw(){
//g indrukken

//Zoek de kleur met de nieuwe get
y++;
if(y==height){
y=0;
}
if(y==0){
x=x+1;
}
color colorFromget= get(gxbeta,gybeta);
color colorFromGet = get(x,y);
if(colorFromGet == red){targetx=x;
targety=y;}
if(z==colorFromget){gx=gxbeta; gy=gybeta;}

//Kijk of hij in range van een kant is en schiet

if ((targetx < (gx + 20)) && (x > (gx - 20)) && (targety < (gy + 20)) && (targetx > (gy - 20)))

//Etc

//Check of je damage krijgt en loop een random kant op als dat zo is en laat dan de key los
dice=random(i,h);

{robot.keyPress(KeyEvent.VK_W);
robot.keyRelease(KeyEvent.VK_W);

{robot.keyPress(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_A);

robot.keyPress(KeyEvent.VK_S);
robot.keyRelease(KeyEvent.VK_S);

robot.keyPress(KeyEvent.VK_D);
robot.keyRelease(KeyEvent.VK_D);

}}}
``````