Hello. I am fairly new to Greenfoot so pardon my noob-ish knowledge.
Basically all I want is to make an array of objects. These objects will be side by side and will be used for my game's floor that I have already coded to prevent the user from falling through. Each object is a square and basically depending on the level, the pattern I would like the floor to be will be different.
For example if: = 1 block.
I would like it to form .
Instead of manually placing the coordinates of each object I would like an array that I can eventually configure to space it out.
This is roughly the same code I'm using to make my "array" which is providing me with Null Pointer Exception Errors.
Thank you.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) public class Screen extends World { /** * Constructor for objects of class Screen. * */ public Screen() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(600, 400, 1); block[] blockArray = new block[5]; for (int i = 0; i< 5; i++) { addObject(blockArray[i],(287+(5*i)), 488); } } }