Illegal Start of Expression Please Help

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

nichellek

Thread Starter
Joined
Jan 2, 2011
Messages
4
Hi, I keep getting this illegal start of expression error, and I cannot figure out where to fix it.
Any help would be greatly appreciated. It is the line "public void keyReleased(KeyEvent k) {}"


/********************************************************
*key listener events
******************************************************/
public void keyReleased(KeyEvent k){}
public void keyTyped(KeyEvent k){}
public void keyPressed(KeyEvent k){

int keyCode = k.getKeyCode();

switch (keyCode)
{
case KeyEvent.VK_LEFT:
//left arrow rotates ship left 5 degrees
ship.incFaceAngle(-5);
if (ship.getFaceAngle() > 0) ship.setFaceAngle(360-5);
break;

case KeyEvent.VK_RIGHT:
//right arrow rotates ship right 5 degrees
ship.incFaceAngle(5);
if (ship.getFaceAngle() > 360) ship.setFaceAngle(5);
break;

case keyEvent.VK_UP:
//up arrow adds thrust to ship (1/10 normal speed)
ship.setMoveAngle(ship.getFaceAngle() -90);
ship.incVelX(calcAngleMoveX(ship.getMoveAngle())*0.1);
ship.incVelY(calcAngleMoveY(ship.getMoveAngle())*0.1);
break;

//Ctrl, Enter, or Space can be used to fire weapon
case KeyEvent.VK_CONTROL:
case KeyEvent.VK_ENTER:
case KeyEvent.VK_SPACE:
//fire a bullet
currentBullet++;
if (currentBullet > BULLETS -1) currentBullet = 0;
bullet[currentBullet].setAlive(true);

//point bullet in same direction ship is facing
bullet[currentBullet].setX(ship.getX());
bullet[currentBullet].setY(ship.getY());
bullet[currentBullet].setMoveAngle(ship.getFaceAngle()-90);

//fire bullet at angle of the ship
double angle = bullet[currentBullet].getMoveAngle();
double svx = ship.getVelX();
double svy = ship.getVelY();
bullet[currentBullet].setVelX(svx + calcAngleMoveX(angle)*2);
bullet[currentBullet].setVelY(svy + calcAngleMoveY(angle)*2);
break;
}
}

Thanks in advance!
 
Joined
May 26, 2005
Messages
75
Probably a novice question on my part, but what programming language is this?
 

nichellek

Thread Starter
Joined
Jan 2, 2011
Messages
4
java, this is a section of a larger class, but it is the only compiler error I am getting.
 
Joined
May 26, 2005
Messages
75
I am guessing it doesn't like how to started the 'switch' function. I am guessing it is popping up because of incorrect syntax.
 
Joined
May 26, 2005
Messages
75
Honestly it has been a few years since I worked in java, so I would need to look it up in order to be correct.

I am just guessing that is what it has a problem with.
 
Joined
Sep 25, 2007
Messages
290
If it's reporting that error on the keyReleased() line, then most likely the issue is somewhere before that line, not after it.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top