I want to make a multiplayer game with two bees that fly and want to shoot each other with some kind of bullet.
They both should be able to move in 8 directions (N, S, E, W, NE, SE, NW, SW). Bullets should fly in the direction that bee was while shooting.
One shooting the other adds 1 on it's score.
How to make them shoot on the button pressed and how to make game to be playable in two players?
Also, i have problem with this code i made, when a bee flies in directions which needs two button pressed (left-up, right-up, left-down or right-down) it sometimes flips the opposite of that side and continues flying like that.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | public class bee extends Actor { public void act() { int speed = 6 ; if (Greenfoot.isKeyDown( "up" )){ setLocation(getX(), getY() - speed); setRotation( 270 ); } if (Greenfoot.isKeyDown( "down" )){ setLocation(getX(), getY() + speed); setRotation( 90 ); } if (Greenfoot.isKeyDown( "left" )){ setLocation(getX() - speed, getY()); setRotation( 180 ); } if (Greenfoot.isKeyDown( "right" )){ setLocation(getX() + speed, getY()); setRotation( 0 ); } if (Greenfoot.isKeyDown( "up" ) && Greenfoot.isKeyDown( "right" )){ setRotation(- 45 ); } if (Greenfoot.isKeyDown( "up" ) && Greenfoot.isKeyDown( "left" )){ setRotation( 45 ); } if (Greenfoot.isKeyDown( "down" ) && Greenfoot.isKeyDown( "left" )){ setRotation( 135 ); } if (Greenfoot.isKeyDown( "down" ) && Greenfoot.isKeyDown( "right" )){ setRotation( 225 ); } } } |