# Tron Light Cycle project I'm making

**URL:** <https://discourse.processing.org/t/tron-light-cycle-project-im-making/25398>\
**Category:** Coding Questions\
**Created:** [November 13, 2020, 12:27pm UTC](https://discourse.processing.org/t/tron-light-cycle-project-im-making/25398 "2020-11-13T12:27:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheGullible1](https://avatars.discourse-cdn.com/v4/letter/t/7bcc69/32.png) [@TheGullible1](https://discourse.processing.org/u/TheGullible1)\
**Post date:** [November 13, 2020, 12:27pm UTC](https://discourse.processing.org/t/tron-light-cycle-project-im-making/25398/1 "2020-11-13T12:27:39Z")

</div>

JAVA\*\*  
so im trying to move my point continuously when a key is pressed it will only move that direction.

```auto
//arrow keys to draw
float x,y;
int speedY = 0;
int speedX = 1;

void setup(){
 size(500,500); 
 background(255,255,255); //background white
 x=150;
 y=150;
 stroke(0,0,0); //pen black
}

void draw(){
  stroke(255,0,0);
  point(x,y); //draw a point at current (x,y) 
  updatepoint();
}

void updatepoint(){
  x = x + speedX;
  y = y - speedY;
  
}
void keyPressed(){
 if(key == CODED)
  {
    if (keyCode == UP && y>=0){ //restrict to screen edge
      y=y-1;
    }
    else if(keyCode == DOWN && y<=500){
          y=y+1;
    }
    else if (keyCode == LEFT && x>=0){
      x=x-1;
    }
    else if (keyCode == RIGHT && x<=500){
      x=x+1;
    }
  }
}

```

i was trying to use speedX and SpeedY but the next mistake happens when instead a continuous trail, it just makes multiple dots.

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [November 13, 2020, 12:38pm UTC](https://discourse.processing.org/t/tron-light-cycle-project-im-making/25398/2 "2020-11-13T12:38:16Z")

</div>

Hey, and welcome to the forum!

Great to have you here!

You need to change **speed**.

In this version though, for example RIGHT key always means east (absolute);  
you could also make it so he can only turn left and right (relative)

Warm regards,

Chrisir

```auto
//arrow keys to steer
float x, y;
int speedY = 0;
int speedX = 1;

void setup() {
  size(500, 500); 
  background(255, 255, 255); //background white
  x=150;
  y=150;
  stroke(0, 0, 0); //pen black
}

void draw() {
  stroke(255, 0, 0);
  point(x, y); //draw a point at current (x,y) 
  updatepoint();
}

void updatepoint() {
  x = x + speedX;
  y = y + speedY;
}

void keyPressed() {
  if (key == CODED)
  {
    if (keyCode == UP && y>=0) { //restrict to screen edge
      speedX=0; 
      speedY=-1;
    } else if (keyCode == DOWN && y<=500) {
      speedX=0; 
      speedY=1;
    } else if (keyCode == LEFT && x>=0) {
      speedX=-1; 
      speedY=0;
    } else if (keyCode == RIGHT && x<=500) {
      speedX=1; 
      speedY=0;
    }
  }
}

```
