Source Code Game Greenfoot Balapan

Embed Size (px)

Citation preview

  • 7/25/2019 Source Code Game Greenfoot Balapan

    1/26

    SOURCE CODE GAME GREENFOOT BALAPAN

    Script World rumput :

    import greenfoot.*;

    /**

    * Write a description of class rumput here.

    *

    * @author (your name)

    * @version (a version number or a date)

    */

    public class rumput etends World

    !

    public static "reenfootSound abc;

    /**

    * #onstructor for ob$ects of class rumput.

    *

    */

    public rumput()

    !

    // #reate a ne% %orld %ith &'''' cells %ith a cell sie of piels.

    super(&''+ ''+ );

    set,aint-rder(crash.class+bangunan.class+bangunan.class+bangunan.clas

    s+bangunan.class+lampu.class+pohon.class+mobil.class+mobil.class+0oin.

    class+aspal.class+point.class+tombol.class);

    prepare();

  • 7/25/2019 Source Code Game Greenfoot Balapan

    2/26

    1

    int i2''';

    public void act()

    !

    i33;

    if (i45'22')

    !

    abc 2 ne% "reenfootSound(6a%al.%av6);

    abc.play();

    1

    1

    private void prepare()

    !

    bangunan bangunan 2 ne% bangunan();

    add-b$ect(bangunan+ 78+ 5);

    bangunan bangunan 2 ne% bangunan();

    add-b$ect(bangunan+ 55+ );

    bangunan bangunan 2 ne% bangunan();

    add-b$ect(bangunan+ 8+ 9);

    bangunan bangunan 2 ne% bangunan();

    add-b$ect(bangunan+ 7+ );

    bangunan.setocation(7+ 98);

    bangunan.setocation(85+ 9);

  • 7/25/2019 Source Code Game Greenfoot Balapan

    3/26

    bangunan.setocation(78+ );

    pohon pohon 2 ne% pohon();

    add-b$ect(pohon+ 898+ '&);

    bangunan.setocation(87+ 9);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

  • 7/25/2019 Source Code Game Greenfoot Balapan

    4/26

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    lampu lampu 2 ne% lampu();

    add-b$ect(lampu+ &+ 7);

    bangunan.setocation(7+ );

    lampu.setocation(8+ );

    bangunan.setocation(5+ ');

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

  • 7/25/2019 Source Code Game Greenfoot Balapan

    5/26

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

    pohon.setocation(898+ '&);

  • 7/25/2019 Source Code Game Greenfoot Balapan

    6/26

    remove-b$ect(pohon);

    bangunan.setocation(&7+ 5&);

    bangunan.setocation(8+ 7);

    bangunan.setocation(&7+ ');

    bangunan.setocation(7+ 97);

    remove-b$ect(bangunan);

    bangunan bangunan 2 ne% bangunan();

    add-b$ect(bangunan+ 97+ 8);

    bangunan.setocation('+ );

    bangunan.setocation(8'7+ 78);

    bangunan.setocation(88+ '7);

    bangunan.setocation(9+ '9);

    bangunan.setocation(87+ 57);

    remove-b$ect(bangunan);

    bangunan bangunan 2 ne% bangunan();

    add-b$ect(bangunan+ 89+ 9&);

    remove-b$ect(bangunan);

    pohon pohon 2 ne% pohon();

    pohon pohon 2 ne% pohon();

    add-b$ect(pohon+ 89+ 9);

    lampu.setocation(8+ 5);

    bangunan.setocation(7+ 79);

    pohon.setocation(895+ 9);

    bangunan bangunan 2 ne% bangunan();

    add-b$ect(bangunan+ 9+ 55);

  • 7/25/2019 Source Code Game Greenfoot Balapan

    7/26

    bangunan.setocation(&+ 58);

    bangunan.setocation(85+ &);

    bangunan.setocation(88+ 7);

    bangunan.setocation(8+ &);

    pohon pohon 2 ne% pohon();

    add-b$ect(pohon+ 898+ &);

    lampu.setocation(88+ '');

    bangunan.setocation(&+ 98);

    lampu.setocation(88+ );

    bangunan.setocation(9+ 9&);

    remove-b$ect(bangunan);

    lampu.setocation(89+ 7);

    bangunan.setocation(78+ 77);

    lampu.setocation(87+ 9);

    bangunan bangunan 2 ne% bangunan();

    add-b$ect(bangunan+ 8+ &9);

    remove-b$ect(bangunan);

    bangunan bangunan 2 ne% bangunan();

    add-b$ect(bangunan+ 58+ 5');

    lampu.setocation(&+ 7);

    bangunan.setocation(77+ 5');

    bangunan bangunan 2 ne% bangunan();

    add-b$ect(bangunan+ 8+ 7);

    bangunan bangunan 2 ne% bangunan();

    add-b$ect(bangunan+ 99+ 9);

  • 7/25/2019 Source Code Game Greenfoot Balapan

    8/26

    bangunan.setocation(5+ 5');

    lampu.setocation(&'+ 8&);

    remove-b$ect(bangunan);

    bangunan bangunan 2 ne% bangunan();

    add-b$ect(bangunan+ + ');

    remove-b$ect(bangunan);

    remove-b$ect(bangunan);

    remove-b$ect(bangunan);

    bangunan.setocation(87+ );

    remove-b$ect(pohon);

    pohon.setocation(899+ 7);

    pohon.setocation(899+ 7);

    bangunan.setocation(87+ 9);

    add-b$ect(bangunan+ 9+ ');

    bangunan.setocation(7+ 5);

    lampu.setocation(&'+ 8');

    bangunan.setocation(59+ 78);

    pohon.setocation(899+ 85);

    mobil mobil 2 ne% mobil();

    add-b$ect(mobil+ &&+ &);

    mobil mobil 2 ne% mobil();

    add-b$ect(mobil+ + 8);

    point point 2 ne% point();

    add-b$ect(point+ 8'+ );

  • 7/25/2019 Source Code Game Greenfoot Balapan

    9/26

    1

    1

    Script World menu

    import greenfoot.*;

    /**

    * Write a description of class mainmenu here.

    *

    * @author (your name)

    * @version (a version number or a date)

    */

    public class menu etends World

    !

    public static "reenfootSound titleSound;

    /**

    * #onstructor for ob$ects of class mainmenu.

    *

    */

    public menu()

    !

    super(&''+ ''+ );

    if (this.get#lass().getgnore#ase(6this6))

  • 7/25/2019 Source Code Game Greenfoot Balapan

    10/26

    prepare();

    titleSound 2 ne% "reenfootSound(6bac0ground.mp6);

    titleSound.stop();

    titleSound.set?olume(');

    titleSound.playoop();

    prepare();

    1

    /**

    * ,repare the %orld for the start of the program. hat is: create the initial

    * ob$ects and add them to the %orld.

    */

    private void prepare()

    !

    tombol tombol 2 ne% tombol();

    add-b$ect(tombol+ 88+ 7);

    tombol.setocation(88+ &);

    tombol.setocation(88+ &7);

    tombolstart tombolstart 2 ne% tombolstart();

    add-b$ect(tombolstart+ 8&8+ 78);

    tombolstart.setocation(8&+ &8);

    1

    1

    Script Actor desain pada lampu :

  • 7/25/2019 Source Code Game Greenfoot Balapan

    11/26

    import greenfoot.*;

    /**

    * Write a description of class lampu here.

    *

    * @author (your name)

    * @version (a version number or a date)

    */

    public class lampu etends desain

    !

    /**

    * Act B do %hatever the lampu %ants to do. his method is called

    %henever

    * the CActC or CDunC button gets pressed in the environment.

    */

    public void act()

    !

    setocation(getE()+getF()3);

    if(isAtGdge())!

    setocation(getE()+');

    1

    1

    1

    Script Actor desain pada pohon :

    import greenfoot.*;

  • 7/25/2019 Source Code Game Greenfoot Balapan

    12/26

    /**

    * Write a description of class pohon here.

    *

    * @author (your name)

    * @version (a version number or a date)

    */

    public class pohon etends desain

    !

    /**

    * Act B do %hatever the pohon %ants to do. his method is called

    %henever

    * the CActC or CDunC button gets pressed in the environment.

    */

    public void act()

    !

    setocation(getE()+getF()3);

    if(isAtGdge())!

    setocation(getE()+');

    1

    1

    1

    Script Actor desain pada bangunan :

    import greenfoot.*;

  • 7/25/2019 Source Code Game Greenfoot Balapan

    13/26

    /**

    * Write a description of class bangunan here.

    *

    * @author (your name)

    * @version (a version number or a date)

    */

    public class bangunan etends desain

    !

    /**

    * Act B do %hatever the bangunan %ants to do. his method is called

    %henever

    * the CActC or CDunC button gets pressed in the environment.

    */

    public void act()

    !

    setocation(getE()+getF()3);

    if(isAtGdge())!

    setocation(getE()+');

    1

    1

    1

    Script Actor desain pada bangunan :

    import greenfoot.*;

    /**

  • 7/25/2019 Source Code Game Greenfoot Balapan

    14/26

    * Write a description of class bangunan here.

    *

    * @author (your name)

    * @version (a version number or a date)

    */

    public class bangunan etends desain

    !

    /**

    * Act B do %hatever the bangunan %ants to do. his method is called

    %henever

    * the CActC or CDunC button gets pressed in the environment.

    */

    public void act()

    !

    setocation(getE()+getF()3);

    if(isAtGdge())!

    setocation(getE()+');

    1

    1

    1

    Script Actor desain pada bangunan :

    import greenfoot.*;

    /**

    * Write a description of class bangunan here.

  • 7/25/2019 Source Code Game Greenfoot Balapan

    15/26

    *

    * @author (your name)

    * @version (a version number or a date)

    */

    public class bangunan etends desain

    !

    /**

    * Act B do %hatever the bangunan %ants to do. his method is called

    %henever

    * the CActC or CDunC button gets pressed in the environment.

    */

    public void act()

    !

    setocation(getE()+getF()3);

    if(isAtGdge())!

    setocation(getE()+');

    1

    1

    1

    Script Actor desain pada bangunan :

    import greenfoot.*;

    /**

    * Write a description of class bangunan here.

    *

  • 7/25/2019 Source Code Game Greenfoot Balapan

    16/26

    * @author (your name)

    * @version (a version number or a date)

    */

    public class bangunan etends desain

    !

    /**

    * Act B do %hatever the bangunan %ants to do. his method is called

    %henever

    * the CActC or CDunC button gets pressed in the environment.

    */

    public void act()

    !

    setocation(getE()+getF()3);

    if(isAtGdge())!

    setocation(getE()+');

    1

    1

    1

    Script Actor tombol pada tombolstart :

    import greenfoot.*;

    /**

    * Write a description of class btnstart here.

    *

    * @author (your name)

    * @version (a version number or a date)

  • 7/25/2019 Source Code Game Greenfoot Balapan

    17/26

    */

    public class tombolstart etends tombol

    !

    /**

    * Act B do %hatever the btnstart %ants to do. his method is called

    %henever

    * the CActC or CDunC button gets pressed in the environment.

    */

    public void act()

    !

    // Add your action code here.

    super.act(this.get#lass().get

  • 7/25/2019 Source Code Game Greenfoot Balapan

    18/26

    public class 0oin etends $alanan

    !

    /**

    * Act B do %hatever the 0oin %ants to do. his method is called %henever

    * the CActC or CDunC button gets pressed in the environment.

    */

    World 0oin;

    public void act()

    !

    setocation(getE()+getF()3);

    0oin 2 getWorld();

    if (isAtGdge()) !

    0oin.remove-b$ect(this);

    1

    1

    1

    Script Actor $alanan pada aspal :

    import greenfoot.*;

    /**

    * Write a description of class aspal here.

    *

    * @author (your name)

    * @version (a version number or a date)

    */

  • 7/25/2019 Source Code Game Greenfoot Balapan

    19/26

    public class aspal etends $alanan

    !

    /**

    * Act B do %hatever the aspal %ants to do. his method is called %henever

    * the CActC or CDunC button gets pressed in the environment.

    */

    public void act()

    !

    setocation(getE()+getF()3);

    if(isAtGdge())!

    setocation(getE()+');

    1

    1

    1

    Script Actor $alanan pada point :

    import greenfoot.*;

    import $ava.a%t.#olor;

    import $ava.util.ist;

    /**

    * Write a description of class point here.

    *

    * @author (your name)

    * @version (a version number or a date)

    */

    public class point etends $alanan

  • 7/25/2019 Source Code Game Greenfoot Balapan

    20/26

    !

    /**

    * Act B do %hatever the point %ants to do. his method is called %henever

    * the CActC or CDunC button gets pressed in the environment.

    */

    public void act()

    !

    // Add your action code here.

    1

    1

    Script Actor $alanan pada mobil :

    import greenfoot.*;

    import $ava.a%t.#olor;

    /**

    * Write a description of class mobil here.

    *

    * @author (your name)

    * @version (a version number or a date)

    */

    public class mobil etends $alanan

    !

    /**

    * Act B do %hatever the mobil %ants to do. his method is called

    %henever

  • 7/25/2019 Source Code Game Greenfoot Balapan

    21/26

    * the CActC or CDunC button gets pressed in the environment.

    */

    public static "reenfootSound abc;

    int count2';

    int score2';

    public void act()

    !

    if (count225') !

    getWorld().add-b$ect(ne%

    mobil()+"reenfoot.getDandom

  • 7/25/2019 Source Code Game Greenfoot Balapan

    22/26

    score33;

    String scorestring2663score;

    "reenfoot>mage g 2 ne% "reenfoot>mage(6Score : 63scorestring+ '+

    #olor.red+ null);

    point a 2 (point) getWorld().get-b$ects(point.class).get(');

    a.set>mage(g);

    "reenfoot.playSound(60oin.%av6);

    1

    else !

    if (getE()H2'' II getE()J25') !

    if ("reenfoot.isKeyLo%n(6left6)) !

    move(B);

    abc 2 ne% "reenfootSound(6mobil.mp6);

    abc.play();

    1

    if ("reenfoot.isKeyLo%n(6right6)) !

    move();

    abc 2 ne% "reenfootSound(6mobil.mp6);

    abc.play();

    1

    if ("reenfoot.isKeyLo%n(6up6)) !

    setocation(getE()+getF()B);

    abc 2 ne% "reenfootSound(6mobil.mp6);

    abc.play();

    1

  • 7/25/2019 Source Code Game Greenfoot Balapan

    23/26

    if ("reenfoot.isKeyLo%n(6do%n6)) !

    setocation(getE()+getF()3);

    abc 2 ne% "reenfootSound(6mobil.mp6);

    abc.play();

    1

    1

    else if (getE()J'')!

    if ("reenfoot.isKeyLo%n(6right6)) !

    move();

    1

    if ("reenfoot.isKeyLo%n(6up6)) !

    setocation(getE()+getF()B);

    1

    if ("reenfoot.isKeyLo%n(6do%n6)) !

    setocation(getE()+getF()3);

    1

    1

    else !

    if ("reenfoot.isKeyLo%n(6left6)) !

    move(B);

    1

    if ("reenfoot.isKeyLo%n(6up6)) !

    setocation(getE()+getF()B);

    1

    if ("reenfoot.isKeyLo%n(6do%n6)) !

  • 7/25/2019 Source Code Game Greenfoot Balapan

    24/26

    setocation(getE()+getF()3);

    1

    1

    1

    1

    1

    Script Actor $alanan pada mobil :

    import greenfoot.*;

    /**

    * Write a description of class mobil here.

    *

    * @author (your name)

    * @version (a version number or a date)

    */

    public class mobil etends $alanan

    !

    /**

    * Act B do %hatever the mobil %ants to do. his method is called

    %henever

    * the CActC or CDunC button gets pressed in the environment.

    */

    private int count2';

    World mobil;

  • 7/25/2019 Source Code Game Greenfoot Balapan

    25/26

    public void act()

    !

    setocation(getE()+getF()3);

    mobil 2 getWorld();

    if (isAtGdge()) !

    mobil.remove-b$ect(this);

    1

    1

    1

    Script Actor crash :

    import greenfoot.*;

    /**

    * Write a description of class crash here.

    *

    * @author (your name)

    * @version (a version number or a date)

    */

    public class crash etends Actor

    !

    /**

    * Act B do %hatever the crash %ants to do. his method is called %henever

    * the CActC or CDunC button gets pressed in the environment.

    */

    public void act()

  • 7/25/2019 Source Code Game Greenfoot Balapan

    26/26

    !

    // Add your action code here.

    1

    1