i am trying to make "stars" and i am starting off simple, i made a variable "a", and if its less than 255 it adds 1 to "a", if its greater than 255 it takes away 1. but obviosuly as soon as it takea 1 away it will add 1, again and be stuf at 255. i am not sure how i can workaround this... without an array though.
int[] starx = new int[50];
int[] stary = new int[50];
int a = 0;
void setup()//open setup
{
smooth();
size(500,500);
//set x, y values
for (int i = 0; i <50; i++)
{
starx[i] = int(random(500));
stary[i] = int(random(500));
}
}//end setup
//
void draw()//open draw
{
smooth();
background(0);
//check the alpha value
if (a < 255)
{
a += 1;
}
if(a<255) ///<<<<<@@@@@@ if it goes below it will add 1 again
{
a -= 1;
}
//draws all the circles
for (int i = 0; i <50; i++)
{
fill(255, a);
ellipse(starx[i],stary[i], 5, 5);
}
so i have to do a project, which is to make a simple galaga/ space invaders clone, i managed to get the thing working using just the main class(1 tab <<<noob =/) but now i would like to break it off into classes and i am having some issues with moving the ship(a triangle), every time the movment key the ship keeps moving in that direction instead of moving in steps.
here is the main class
//SIZE
int width = 400;
int height = width;
//SHIP CENTER COORDINATES + OBEJECT
int shipCenterX = 200;
int shipCenterY = 380;
ship shipA;
//INITIALIZE GAME
void setup()
{
size(width, height);
shipA = new ship(shipCenterX, shipCenterY, width, height);