Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Classes reduced #1

Merged
merged 1 commit into from
Dec 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Classes reduced
malee31 committed Nov 22, 2019
commit f4f5813977c08e1ab988247033d21d18097463cc
20 changes: 5 additions & 15 deletions Asteroid.pde
Original file line number Diff line number Diff line change
@@ -12,8 +12,7 @@ public class Asteroid extends Floater
//yCorners=new int[]{20,1,2,2,1,1,2,2,15,15,2,2,-10,-10,-11,-11,-10,-10,-9,-11,-16,-16,-10,-9,-11,-11,-9,-10,-16,-16,-11,-9,-10,-10,-11,-11,-10,-10,2,2,15,15,2,2,1,1,2,2,1,20};
yCorners=new int[]{-10,-9,-9,-5,-4,-4,-3,-3,-1,1,3,3,4,4,5,9,9,10,10,9,9,5,4,3,1,-1,-3,-4,-5,-9,-9,-10};
xCorners=new int[]{8,8,1,1,3,7,7,4,5,5,4,7,7,3,1,1,8,8,-8,-8,-1,-1,-3,-4,-5,-5,-4,-3,-1,-1,-8,-8};
//corners=50;
corners=32;
corners=Math.min(xCorners.length, yCorners.length);
myColor=color(255,255,255);
if(topSide==0)
{
@@ -74,21 +73,12 @@ public class Asteroid extends Floater
}
public boolean cloDet(int box, int boy)
{
if(dist(box, boy, this.getX(), this.getY())<=20)
{
return true;
}else{
return false;
}
//ALERT! You can use operator overiding for this and bomDet()
return dist(box, boy, (float)myCenterX, (float)myCenterY)<=20;
}
public boolean bomDet(int box, int boy, int sphe)
{
//if(dist(box, boy, this.getX(), this.getY())>sphe+5||dist(box, boy, this.getX(), this.getY())<sphe-5)
if(dist(box, boy, this.getX(), this.getY())<=sphe)
{
return true;
}else{
return false;
}
}
return dist(box, boy, (float)myCenterX, (float)myCenterY)<=sphe;
}
}
63 changes: 19 additions & 44 deletions AsteroidsGame.pde
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//your variable declarations here
Spaceship ship;
Leftwing lWing;
Rightwing rWing;
Leftbackwing lbWing;
Rightbackwing rbWing;
Colorant lWing;
Colorant rWing;
Colorant lbWing;
Colorant rbWing;
Missile miss;
PImage img, end1, end2, end3, end4, end5, end6, end7, boxTar, xOut;
PImage end8, end9, tieBoom, boomwait, telewait, timewait,spinwait,misstar,misswait;
@@ -21,6 +21,7 @@ int rectX, rectY;
int circleX, circleY;
int triX, triY;
int tarX, tarY, missEndX, missEndY;
//rect & tri unused
color rectColor, circleColor, triColor;
color rectHighlight, circleHighlight, triHighlight;
boolean rectOver=false;
@@ -51,50 +52,24 @@ PImage[] dio=new PImage[25];
public void setup()
{
ship=new Spaceship();
lWing=new Leftwing();
rWing=new Rightwing();
lbWing=new Leftbackwing();
rbWing=new Rightbackwing();
lWing=new Colorant(new int[]{-18,-4,0,16,20,8,6,4,-4,-6,-14}, new int[]{-5,-5,-4,-4,-6,-10,-10,-6,-6,-7,-7}, color(255,0,0));
rWing=new Colorant(new int[]{-18,-4,0,16,20,8,6,4,-4,-6,-14}, new int[]{5,5,4,4,6,10,10,6,6,7,7}, color(255, 0, 0));
lbWing=new Colorant(new int[]{0,-3,-11,-14,-12,-2}, new int[]{-16,-12,-12,-16,-18,-18}, color(255, 0, 0));
rbWing=new Colorant(new int[]{0,-3,-11,-14,-12,-2}, new int[]{16,12,12,16,18,18}, color(255, 0, 0));
miss=new Missile();
size(1000, 1000);
frameRate(60);
background(0,0,0);
noStroke();
img=loadImage("flashtele.png");
endBoom[0]=loadImage("explofr1.gif");
endBoom[1]=loadImage("explofr2.gif");
endBoom[2]=loadImage("explofr3.gif");
endBoom[3]=loadImage("explofr4.gif");
endBoom[4]=loadImage("explofr5.gif");
endBoom[5]=loadImage("explofr6.gif");
endBoom[6]=loadImage("explofr7.gif");
endBoom[7]=loadImage("explofr8.gif");
endBoom[8]=loadImage("explofr9.gif");
dio[0]=loadImage("zawarudo1.gif");
dio[1]=loadImage("zawarudo2.gif");
dio[2]=loadImage("zawarudo3.gif");
dio[3]=loadImage("zawarudo4.gif");
dio[4]=loadImage("zawarudo5.gif");
dio[5]=loadImage("zawarudo6.gif");
dio[6]=loadImage("zawarudo7.gif");
dio[7]=loadImage("zawarudo8.gif");
dio[8]=loadImage("zawarudo9.gif");
dio[9]=loadImage("zawarudo10.gif");
dio[10]=loadImage("zawarudo11.gif");
dio[11]=loadImage("zawarudo12.gif");
dio[12]=loadImage("zawarudo13.gif");
dio[13]=loadImage("zawarudo14.gif");
dio[14]=loadImage("zawarudo15.gif");
dio[15]=loadImage("zawarudo16.gif");
dio[16]=loadImage("zawarudo17.gif");
dio[17]=loadImage("zawarudo18.gif");
dio[18]=loadImage("zawarudo19.gif");
dio[19]=loadImage("zawarudo20.gif");
dio[20]=loadImage("zawarudo21.gif");
dio[21]=loadImage("zawarudo22.gif");
dio[22]=loadImage("zawarudo23.gif");
dio[23]=loadImage("zawarudo24.gif");
dio[24]=loadImage("zawarudo25.gif");
for(int boom=1; boom<=endBoom.length; boom++)
{
endBoom[boom-1]=loadImage("explofr"+boom+".gif");
}
for(int worldWide=1; worldWide<=dio.length; worldWide++)
{
dio[worldWide-1]=loadImage("zawarudo"+worldWide+".gif");
}
misstar=loadImage("missTar.png");
tieBoom=loadImage("explosion.png");
boomwait=loadImage("boomwait.png");
@@ -869,8 +844,8 @@ void tarLock()
}
void shipSpeed()
{
int a=(int)ship.speed;
ship.speed=0;
int a=ship.getSpeed();
ship.setSpeed(0);
stopShip();
shipAccel(a);
}
31 changes: 31 additions & 0 deletions Colorant.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
class Colorant extends Floater
{
public Colorant(int[] xCoord, int[] yCoord, color coloring)
{
xCorners=xCoord;
yCorners=yCoord;
corners=Math.min(xCorners.length, yCorners.length);
myColor=coloring;
myCenterX=500;
myCenterY=500;
myDirectionX=0;
myDirectionY=0;
myPointDirection=0;
}
public void setX(int x){myCenterX=x;}
public int getX(){return (int)myCenterX;}
public void setY(int y){myCenterY=y;}
public int getY(){return (int)myCenterY;}
public void setDirectionX(double x){myDirectionX=x;}
public double getDirectionX(){return myDirectionX;}
public void setDirectionY(double y){myDirectionY=y;}
public double getDirectionY(){return myDirectionY;}
public void setPointDirection(int degrees){myPointDirection=degrees;}
public double getPointDirection(){return myPointDirection;}
public void move()
{
myCenterX=ship.getX();
myCenterY=ship.getY();
myPointDirection=ship.getPointDirection();
}
}
15 changes: 0 additions & 15 deletions Leftbackwing.pde

This file was deleted.

15 changes: 0 additions & 15 deletions Leftwing.pde

This file was deleted.

15 changes: 0 additions & 15 deletions Rightbackwing.pde

This file was deleted.

15 changes: 0 additions & 15 deletions Rightwing.pde

This file was deleted.

33 changes: 15 additions & 18 deletions Spaceship.pde
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
class Spaceship extends Floater
{
int tagX=0;
int tagY=0;
int bombX=0;
int bombY=0;
int colCon=0;
int speed;
private int tagX, tagY, bombX, bombY, colCon, speed;
public Spaceship()
{
//xCorners=new int[]{-1,-2,-2,-6,-6,-14,-14,-15,-15,-16,-16,-17,-17,-16,-16,-15,-15,-14,-14,-5,-5,-3,-3,-2,-2,2,2,3,3,5,5,14,14,15,15,16,16,17,17,16,16,15,15,14,14,6,6,2,2,1};
//yCorners=new int[]{20,1,2,2,1,1,2,2,15,15,2,2,-10,-10,-11,-11,-10,-10,-9,-11,-16,-16,-10,-9,-11,-11,-9,-10,-16,-16,-11,-9,-10,-10,-11,-11,-10,-10,2,2,15,15,2,2,1,1,2,2,1,20};
yCorners=new int[]{-2,-4,-4,-2,-5,-5,-4,-4,-3,-3,-2,-2,-3,-3,-4,-4,-6,-10,-10,-11,-11,-12,-12,-11,-11,-10,-10,-14,-18,-18,-10,-6,-6,-2,-2,2,2,6,6,10,18,18,14,10,10,11,11,12,12,11,11,10,10,6,4,4,3,3,2,2,3,3,4,4,5,5,2,4,4,2};
xCorners=new int[]{0,-4,-14,-16,-14,-4,0,2,2,1,1,19,19,3,3,16,20,8,6,6,8,8,2,2,5,5,2,2,-2,-12,-20,-18,-22,-22,-18,-18,-22,-22,-18,-20,-12,-2,2,2,5,5,2,2,8,8,6,6,8,20,16,3,3,19,19,1,1,2,2,0,-4,-14,-16,-14,-4,0};
//corners=50;
corners=70;
corners=Math.min(xCorners.length, yCorners.length);
myColor=color(211,211,211);
myCenterX=500;
myCenterY=500;
myDirectionX=0;
myDirectionY=0;
myPointDirection=0;
//Ported inits
tagX=0;
tagY=0;
bombX=0;
bombY=0;
colCon=0;
}
public void setX(int x){myCenterX=x;}
public int getX(){return (int)myCenterX;}
@@ -39,28 +39,25 @@ class Spaceship extends Floater
public int getBombX(){return (int)bombX;}
public void setBombY(int y){bombY=y;}
public int getBombY(){return (int)bombY;}
public void setSpeed(int y){speed=y;}
public int getSpeed(){return (int)speed;}

public void show()
{
stroke(211,211,211);
noStroke();
fill(211,211,211);
//tag drawn
rect(tagX-10, tagY-5, 20, 10);
//bomb drawn
ellipse(bombX, bombY, 20, 10);
super.show();
}
public boolean distDet(int asx, int asy)
{
if(dist(asx, asy, this.getX(), this.getY())<=14)
{
return true;
}else{
return false;
}
return dist(asx, asy, (float)myCenterX, (float)myCenterY)<=14;
}
public void accelerate(int x)
{
//double dRadians=myPointDirection*(Math.PI/180);
//myDirectionX+=(x)*Math.cos(dRadians);
//myDirectionY+=(x) * Math.sin(dRadians);
speed+=x;
super.accelerate(x);
}