This site requires JavaScript, please enable it in your browser!
Greenfoot back
mahmudi61
mahmudi61 wrote ...

2014/3/31

Hi möchte ein fussball spiel programmieren

mahmudi61 mahmudi61

2014/3/31

#
das spiel soll so ungefähr genau so wie kickende Köpfe funktionieren nur ich weiß nicht wie ich das hinkriege das der ball geschossen wird
Game/maniac Game/maniac

2014/4/1

#
könnte Ihnen mehr Informationen geben Sie bitte
mahmudi61 mahmudi61

2014/4/1

#
ja ich möchte gerne das mein charackter den ball kicken kann es so Funktionieren http://www.spielaffe.de/Spiel/Kickende_Koepfe möchte genau das spiel programmieren
mahmudi61 mahmudi61

2014/4/1

#
public class ball extends Actor { /** * Act - do whatever the ball wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { { boy1HitIt(); } public void boy1HitIt() { Actor boy1; player=getOneObjectAtOffset(0,0,boy1.class); if (boy1 !=null) { setLocation(getX()-4, getY()); } } } und das ist der spieler was fehlt mir??????? public class boy1 extends Actor { /** * Act - do whatever the boy1 wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ private int speed = 2; //movement speed private int vSpeed = 2; //vertical speed private int acceleration = 2; //gravity effect while falling private int jumpStrength = -8; public void act() { checkKeys(); checkFall(); jump(); } public void checkKeys() { if( Greenfoot.isKeyDown("a")) { move(-5); } if(Greenfoot.isKeyDown("d")) { move(5); } if(Greenfoot.isKeyDown("w")) { jump(); } } public void jump() { if (Greenfoot.isKeyDown("w")) { vSpeed = jumpStrength; checkFall(); } } public void checkFall() { setLocation(getX(), getY()+vSpeed); vSpeed = vSpeed + acceleration; } }
You need to login to post a reply.