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

2012/11/21

need help, pls!

dolli4M dolli4M

2012/11/21

#
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class level1 here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class level0 extends World
{
    private int[] level = {  
            0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 
            0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, //1

            0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 
            0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, //2

            0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 
            0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, //3

            0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0,
            0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, //4

            0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 
            0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, //5

            0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 
            0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, //6

            0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 
            0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, //7

            0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 
            0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, //8

            0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 
            0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, //9

            0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 
            0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, //10

            0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 
            0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, //11

            0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 
            2,0, 2,0, 2,0, 2,0, 2,0, 2,0, 2,0, 2,0, 2,0, 2,0, 2,0, 2,0, 2,0, 2,0, 2,0, 2,0, //12
        };
    private static final int CELL_SIZE = 25;
    private static int zellenGroesse = 1;
    final int levelNumber = 1;
    final int levelBreite = 800;
    final int levelHöhe = 600;
    final public int time = 2100;
    int i = 0;

    public level0( )
    {    
        super(800, 600, 1); 
        generateLevel();
        addObject ( new StickmanD(1, 100), 0+50, 200 );

        setPaintOrder(
            FPS.class,
            LifeRating.class,   
            StickmanD.class,  
            stickman.class,
            Bot.class, 
            LittleBrick.class,
            Brick.class, 
            BackgroundStuff.class,
            Wolke.class, 
            Sun.class, 
            DayTime.class 
        );
        this.setBackground("Backgounds/Outside Taal.jpg");
        generateLevel();
        Greenfoot.setSpeed(47);

        prepare();
        
        
    }


    public void generateLevel()
    {
            for (int y = CELL_SIZE/2; y < 24*CELL_SIZE; y += CELL_SIZE) {
                for (int x = CELL_SIZE/2; x < 32*CELL_SIZE; x += CELL_SIZE) {
                    if(!(level[i]==0)&&level[i] % 2 == 0) {
                        addObject( new Brick(), x+13, y-12 );
                    }
                    if(!(level[i]==0)&&level[i] % 3 == 0) {
                        addObject ( new stickman(), x, y );
                    }
                    if(!(level[i]==0)&&level[i] % 5 == 0) {
                        addObject ( new StickmanD(levelNumber,100), x, y );
                    }
                    if(!(level[i]==0)&&level[i] % 7 == 0) {
                        addObject ( new LittleBrick(), x, y );
                    }
                    if(!(level[i]==0)&&level[i] % 11 == 0){
                        addObject ( new Bot(), x, y );
                    }
                    if(!(level[i]==0)&&level[i] % 13 == 0){
                        addObject ( new Man(), x, y );
                    }
                    if(!(level[i]==0)&&level[i] % 31 ==0) {
                        addObject ( new Haus(), x, y-30 );
                    }
                    if(!(level[i]==0)&&level[i] % 37 ==0) {
                        addObject ( new Baum(), x, y-25 );
                    }
                    if(!(level[i]==0)&&level[i] % 41 ==0) {
                        addObject ( new strassenLampe(true), x, y- 30);
                    }
                    if(!(level[i]==0)&&level[i] % 43 ==0) {
                        addObject ( new strassenLampe(false), x, y- 30);
                    }
                    if(!(level[i]==0)&&level[i] % 47 ==0) {
                        addObject ( new Baum2(), x, y-25 );
                    }
                    i++;
                }
            }
    }
    //----------------------------------------------------------------------------

}
dolli4M dolli4M

2012/11/21

#
it throws a array out of Bounds exception..:( : java.lang.ArrayIndexOutOfBoundsException: 768 at level0.generateLevel(level0.java:86) at level0.<init>(level0.java:76)
davmac davmac

2012/11/21

#
Your code and the stack trace don't match up. The exception happens on line 86 of your level0 class, but that doesn't correspond to any statement. Please re-post your code or the stack trace, whichever is wrong!
dolli4M dolli4M

2012/11/21

#
oh sry the stack was an older one, thx at all but i fixed the problem (:
You need to login to post a reply.