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