Hey,
Been trying this for a while now and I'm not getting anywhere. Trying to get some platforms that start without collision to check for collision when a switch is flipped. This down below is my current sad attempt for the problem:
Some help getting in the right direction would be appreciated! :)
private void checkCollisions()
{
onGround = false;
Class platform = Platform.class;
Class greenplatform = GreenPlatform.class;
Class redplatform = RedPlatform.class;
if(platformState == 0) {
platformArray[0] = platform;
platformArray[1] = null;
platformArray[2] = null; }
if(platformState == 1) {
platformArray[0] = platform;
platformArray[1] = greenplatform;
platformArray[2] = null; }
if(platformState == 2) {
platformArray[0] = platform;
platformArray[1] = null;
platformArray[2] = redplatform; }
if(platformState == 3) {
platformArray[0] = platform;
platformArray[1] = greenplatform;
platformArray[2] = redplatform; }
for (Class platforms : platformArray)
{
while(getOneObjectAtOffset(0, getImage().getHeight()/2-1, platforms)!=null)
{
setLocation(getX(), getY()-1);
onGround=true;
Y_SPEED=0;
}
while(getOneObjectAtOffset(0, -getImage().getHeight()/2, platforms)!=null)
{
setLocation(getX(), getY()+1);
Y_SPEED = 0;
}
while(getOneObjectAtOffset(getImage().getWidth()/2, 0, platforms)!=null)
{
setLocation(getX()-1, getY());
X_SPEED = 0;
}
while(getOneObjectAtOffset(-getImage().getWidth()/2, 0, platforms)!=null)
{
setLocation(getX()+1, getY());
X_SPEED = 0;
}
}
}
