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

2022/5/16

jump n run please help

jerno jerno

2022/5/16

#
I am coding a jump n run for school which i have to hand in in about two weeks. I want to add a feature for walls so that they can move around from one edge to another. Any suggestion for code? Background should move aswell. This is the code for the background i created so far, but greenfoot stops if run is pressed.
public void act() {     Robby2 Test= new Robby2 ();
    while(Test.amLeben== true){
    Greenfoot.delay(1);
        imageCount -= 5; 
    drawBackgroundImage();
       randomSpawn();

    }}public void drawBackgroundImage() {
    if (imageCount < -bgImage.getWidth()) {
        imageCount += bgImage.getWidth();
    }
    int temp = imageCount;
    getBackground().drawImage(bgImage, temp, 0);
    getBackground().drawImage(bgImage, temp + bgImage.getWidth(), 0);
}
danpost danpost

2022/5/16

#
Need codes for Robby2 constructor and for randonSpawn method.
You need to login to post a reply.