I havent done a lot in Greenfoot just some basics of the language, but i am trying to make a tank game and all the classes i make end up to be square, they have transparency but are still part of the class. If i fix this i wont need to go to color sensing but worst case scenario i will be forced to use flat colors for sensing when the bullet reaches the ground.
That is the code i made up for the tanks to see if they are touching ground i have an Import java.awt.Color; for the static colors. Im not sure if its because im trying to sense a color on a transparent part of my tank, or because it will only use colors from the image of my tank. My big question is; Is there a way to use the overall game layer for sensing a color instead of just using the tank image.
1 2 3 4 5 6 7 8 | public void ColorGravity( int x , int y) { GreenfootImage image = getImage(); if (image.getColorAt( 16 , 18 ) == Color.WHITE) { setLocation(x, y + 2 ); } } |