I am having trouble with a simple game. I have a game made with Blocks. The blocks are made as
Block(double x1Lc, double y1Lc, double w, double h, Color c)
They are then added to an ArrayList. The 0 block in the ArrayList is the player block. The other blocks are enemies or food. The enemies are blue and the food is red. If the character block touches an enemy then you lose the game. If the character block touches food then the food block is removed from the game.
With my code now. If you touch any block then you lose the game. What do I need to do to check if the blocks color is blue or red and then respond accordingly.
Here is my code for the for and if that works now but, ends if you touch any block.
// player loses if any two Blocks touch: for( int k=1; k<list.size(); k++ ) {// see if Block 0 touches any other Block: {// if Block 0 hits Block k, player loses: if( list.get(0).hits( list.get(k) ) ) state = "lose"; } }