I'm fairly new to programming but i'm getting a handle on it. My problem is that im getting a NullPointerException error and have no idea why. Any help would be greatly appreciated! Thnks!
I'm doing a frogger kind of game. The Rectangles would be the cars moving.
Here's my code:
1st Tab:
Rectangle[] rectangle;
Frog frog;
void setup() {
size(600, 400);
Rectangle[] rectangle = new Rectangle[8];
for (int i = 1; i < 8; i++)
{
for (int k = 45; k < 150; k = k+15)
{
int _centerX = (int) random(0, width);
int _centerY = ((i-1)*15)+k;
int _cHeight = 2*GAP;
int _cWidth = (int) random(40, 100);
rectangle[i] = new Rectangle(_centerX, _centerY, _cWidth, _cHeight);
}
}
for (int i=0; i < rectangle.length; i++)
{
rectangle[i].display();
}
}
2nd Tab:
class Rectangle {
int cWidth, cHeight;
int centerX, centerY;
float speed;
int shade;
color col;
Rectangle(int _centerX, int _centerY, int _cWidth, int _cHeight )
{
centerX = _centerX;
centerY = _centerY;
cWidth = _cWidth;
cHeight = _cHeight;
col = color(random(255), random(255), random(255));
I'm trying to program a short game and i'm a little lost at what im going to do. I'm a bit new at processing and any help towards this game would be greatly appreciated!!!
The final output of the game is also included. Any insight as to how im going to do this would really help right now as i'm a little desperate. As far as i know i'm supposed to use Control