First of all, this is the scenario I am working on: http://www.greenfoot.org/scenarios/9083
Secondly, if you don't want to download the source for yourself, here is what I have in the player class:
I marked out where I need help. Help please?
import greenfoot.*;
import java.awt.Color;
public class Player extends Connector
{
boolean fall;
boolean ready;
double vspeed;
double gravity=0.2;
double exactX,exactY;
public void act()
{
detection();
gravity();
}
public void detection()
{
if(getOneIntersectingObject(TopPlatform.class)!=null){
ready=true;
vspeed=0;
}
if(getOneIntersectingObject(TopPlatform.class)==null){
ready=false;
}
}
public void gravity()
{
if(Greenfoot.isKeyDown("a"))
{
setLocation(getexactX()-2,getexactY());
}
if(Greenfoot.isKeyDown("d"))
{
setLocation(getexactX()+2,getexactY());
}
if(ready==true&&Greenfoot.isKeyDown("w"))
{
vspeed=-6;
ready=false;
fall=true;
}
if(fall==true)
{
vspeed += gravity; // add gravity to speed
setLocation(getexactX(), getexactY()+vspeed);
}
Actor tp=getOneObjectAtOffset(0,0,TopPlatform.class);
//I need help from here
if(tp.getImage().getColorAt(getX()-getImage().getWidth()/2,getY()-getImage().getHeight()/2).equals(new Color(0,0,0,50))){
fall=false;
}
}
public void setLocation(int x, int y) {
exactX = x;
exactY = y;
super.setLocation(x, y);
}
public void setLocation(double x, double y) {
exactX = x;
exactY = y;
super.setLocation((int) x, (int) y);
}
public double getexactX() {
return exactX;
}
public double getexactY() {
return exactY;
}
}
