Ship fly through the gate (asteroids game)

hi, guys, I’m trying to make a small game look like asteroids game but I this time I just need my ship to fly through the gate ( make from 2 direct that the ship can fly in) if it hit the gate the ship should stop at where it hit and when ship touch the area inside the gate it will start at a new point with the new gate
this is my code

float ship_Pos_X=250, 
  ship_Pos_Y=250, 
  angle_of_the_Ship=0, 
  d1=55, 
  d2=30, 
  angle_of_wing=0.7;
float x=0, 
  y=0, 
  x1=0, 
  y1=0, 
  x3=0, 
  y3=0;
float ship_Pos_X1=ship_Pos_X, 
  ship_Pos_Y1=ship_Pos_Y, 
  angle_both_first=0, 
  angle_both_second=0;
boolean turningleft=false, 
  turningright=false, 
  go_ahead=false;
color demension=color(random(255), random(255), random(255));
void setup()
{
  size(1000, 1000);
}
void draw()
{
  newDimension();
  calcPoints();
  drawSHIP();

  Move_Ship();
}

void calcPoints()
{

  x =cos(angle_of_the_Ship)*d1;
  y =sin(angle_of_the_Ship)*d1;
  angle_both_first=angle_of_the_Ship+angle_of_wing;
  angle_both_second=angle_of_the_Ship-angle_of_wing;
  x1=cos(angle_both_first)*d2;
  y1=sin(angle_both_first)*d2;
  x3=cos(angle_both_second)*d2;
  y3=sin(angle_both_second)*d2;
}

void drawSHIP()
{
  fill(#FF4A08);
  quad(ship_Pos_X1, ship_Pos_Y1, ship_Pos_X1-x1, ship_Pos_Y1-y1, ship_Pos_X1+x, ship_Pos_Y1+y, ship_Pos_X1-x3, ship_Pos_Y1-y3);
  if (key=='d'||key=='l'&& turningleft==true) {
    angle_of_the_Ship+=0.01;
  }
  if (key=='a'||key=='j'&& turningright==true) {
    angle_of_the_Ship-=0.01;
  }
  if (key=='s' ||key=='k'&&go_ahead==true) {
  }
}


void Move_Ship()

{

  ship_Pos_X1=ship_Pos_X1+cos(angle_of_the_Ship)*2;
  ship_Pos_Y1=ship_Pos_Y1+sin(angle_of_the_Ship)*2;
 if (ship_Pos_X1 < 0){
      ship_Pos_X1 = width;
    }
    if (ship_Pos_Y1 < 0) {
      ship_Pos_Y1 = height;
    }
    if (ship_Pos_X1 > width) {
      ship_Pos_X1 = 0;
    }
    if (ship_Pos_Y1 > height){
      ship_Pos_Y1 = 0;
    ship_Pos_Y1=-ship_Pos_Y;
  }
}

void newDimension()
{
  background(demension);
}

void keyPressed()
{
  if (key=='d'||key=='l') {
    turningleft=true;
  }
  if (key=='a'||key=='j') {   
    turningright=true;
  }
}

Edit your post. Select your code. Hit the FORMAT THIS LIKE CODE button, which looks like this: </>

You - and others too - have been asking questions about this asteroid ship code for like three days. So you have been here long enough to get this right. I am sick of having to fix the single quotes every time I try to run this.

Why didn’t you mention the gates before? Also, you have not attempted to put in any gates yourself! Please attempt to do your work before asking us to do it.

If this is for an assignment, please also post the whole, exact text of what you are trying to do.

3 Likes

Hi Thomas, this is jens from germany. Your are doing an awesome job here in explaining and helping! I have sent you a facebook-request. Cheers, Jens

@nhghi Please follow this link that gives tips on asking questions. - Guidelines—Tips on Asking Questions And, make sure to break your problem into smaller steps. - http://happycoding.io/tutorials/how-to/program Programming is a trial and error process. Which part of your code do you think needs to be adjusted in order to get the ship to stop?