My Contributions to Galactic Wing

What is Galactic Wing?

Galactic Wing is a Top Down Shooter that puts you in command of your very own fleet of weaponized space shuttles. You destroy asteroids and gold comets in order to earn gold. This gold can be spent in the hangar where you can upgrade all the ships in your fleet. The game comes with two game modes, Chaos Mode and Story/Campaign Mode. Chaos mode is where you simply have your fleet of ships with a constantle increasing number of asteroids in your vicinity; fight to survive. Campaign mode is where you have a combination of timed obstacle courses (still UC) and battles following a level type system. Its pretty much the best game processing has ever seen.

How I contributed to Galactic Wing

Galactic Wing was already in the making way before I was inducted into the project, so most of the core code was already there, however a hangar was yet to be constructed and there were no signs of any artwork. So my contribution to Galactic Wing was to create all the artwork for the game and to construct a hangar where the user could go to to buy new upgrades for his fleet.

What problems did I run into?

In order to not have variables for each and every ship(which would have been 40 variables in total), I decided to use class for the ships. this wasn’t really a problem, there were just some growing pains when trying to figure outt he weird way you have to use classes in processing

This is the code for the Ships class including the supporting method for the first hangar.

class Ships {
  boolean shipbought = false;//pretty self explainitory
  String shipname;
  int shipdamage;
  int shiparmor;
  int shipspeed;
  int engineerXmin;
  int engineerXmax;
  int shipprice;
  int Gold;
  Ships (String name, int damage, int armor, int speed,int Xmin,int Xmax,int price,int gold)
  {
    Gold = gold;
    shipprice = price;
    shipspeed = speed;
    shipdamage = damage;
    shiparmor = armor;
    shipname = name;
    engineerXmin = Xmin;
    engineerXmax = Xmax;
  }
  void displayh1() {
    if ((backgroundnum == 1)&&(engineerX > engineerXmin)&&(engineerX < engineerXmax))
    {//The following 70 lines of code are dedicated to displaying info about the ship, weather you can buy the ship(or if you've already bought the ship), and the price of the ship.
/*1*/ rectMode(CORNER);
      stroke(100);
      strokeWeight(15);
      fill(120,120,120,127);
      tint(255,127);
      rect(100,20,1000,520,40);
      tint(255,255);
      textFont(InfoTextHeader);
      textAlign(LEFT,CENTER);
      fill(0,0,200);
      text(""+ shipname +"",210,50);
      textFont(InfoTextTest);
      rectMode(CORNER);
      strokeWeight(3);
      fill(150);
      rect(210,200,803,15);
      rect(210,300,803,15);
      rect(210,400,803,15);
      noStroke();
      if(shipdamage < 33) {
      fill(red);
      rectMode(LEFT);
      }
      else if(shipdamage <66) {
        fill(yellow);
      }
      else if(shipdamage <=100) {
        fill(green);
      }
      rectMode(CORNER);
      //offset in the x and y by 2 to compensate for the stroke on the outlined boxes
      rect(212,202,float(shipdamage)/100*800,12);
      text("Damage: "+ shipdamage +"",250,150);
      if(shiparmor < 33) {
        fill(red);
      }
      else if (shiparmor <66) {
        fill(yellow);
      }
      else if(shiparmor <=100) {
        fill(green);
      }
      rect(212,302,float(shiparmor)/100*800,12);
      text("Armor: "+ shiparmor +"",250,250);
      if(shipspeed < 33){ 
        fill(red);
      }
      else if(shipspeed <66) {
        fill(yellow);
      }
      else if(shipspeed = shipprice) {
            Gold = Gold - shipprice;
            shipbought = true;
            s2.Gold = s1.Gold;//These 5 lines of code solves a problem where you would have your money instantly replenished to the default value whenever you bought a ship.
            s3.Gold = s1.Gold;
            s4.Gold = s1.Gold;
            s5.Gold = s1.Gold;
            s1.Gold = Money;
            println(""+ Money +"");
          }
          if((Gold <= shipprice)&&(shipbought == false)) {
            fill(50);
            rectMode(LEFT);
            rect(445,485,800,530);
            fill(200,0,0);
            text("INSUFFICIENT FUNDS",450,500);
          }
        }
      }
    }
  }

 

Another problem was trying to use a totally public variable to draw your gold value from. This was issue because you had to pass a variable through the class, which would then be translated to another variable that would actually be used in the proceeding code. So, in order to fix that issue I created a variable called money that would be public and another variable called gold which would be seen only inside the 3 classes for each hangar. So at the end of the frame the class would make their money count equal to each other across the board first. Then outside the class I would call the variable for gold of the hangar the gold was spent in  (ex. “Ships.gold” or “sx.Gold” for each individual ship, where x is the ship number) and would make that equal to money so that upon the next variable passing, the Money variable would be updated to the value each hangar’s gold value was last seen at. It seems simple now but at the time I just couldn’t figure it out.

I have since found a few much simpler ways of doing this.

 

Another problem that I had was having the background display the correct image. This issue arose when I had multiple parameters inside the draw() sequence that led to different backgrounds than the one I wanted being displayed, or if the program came to the correct background to be displayed, it would instead just display a black image. Processing didn’t seem to like that, so instead what I did was I made a main variable called background that was an empty PImage. This would be set using the parameters talked about before only this time I would would do this process outside of the draw(). So inside the draw() i had only one background command but the image variable passed through that background command would be the thing to change change.

So this isn’t the real code, but it looked something like this:

PImage background;
PImage hangar1;
PImage hangar2;

void setup() {
size(1280,720);
hangar1 = image(*image directory*);
hangar2 = image(*image directory*);

void draw() {
checkhangar();
background(background);

void checkhangar() {
if(guy is in hangar 1) {
  background = hangar1;
  }
if(guy is in hangar 2) {
  background = hangar2;
  }
}

I’m not really sure why the first method that was malfunctioning wasn’t working, but either way that’s how I fixed the issue.

Pixel art in Photoshop

Making the ships for Galactic Wing was one of the most fun things I’ve done in Photoshop because it was both gratifying and informative. It was informative because in order to mae the ships small enough while still making them look sharp, I needed to learn how to make pixel art.

Each ship in galactic wing had to be 50 x 50 in order to work with collision so I made a template in 50 x 50 in order to go through the whole process.

 

 

 

 

 

 

 

 

 

 

 

 

 

Whence we create a ship in the 50×50 state we need to scale it so we can display it in the hangar while keeping is crisp and not blurry beyond recognition.

So we go to Image > Image Size, then we will put in the desired resolution. Then in the drop down box in the bottom of the window we will select the option “Nearest Neighbor (preserve hard edges)” then press OK.

Leave a Reply

Your email address will not be published. Required fields are marked *