I've been trying to work on some maze generation things for my adventurey type dungeon crawler game but as soon as I added the code for the generation, whenever I compiled it doesn't show the world, if I try to share it it says no world class was found. Well there is a world class (I think), one of my classes extends world. I moved all of my maze gen code into its own class and it didn't do anything, I probably deleted some vital line of code or something but I'm not really sure what. I'm running greenfoot 2.1.2 and there are 5 classes: Maze(The world), Swoosh, Knight, MazeGen, and Object. Thank you for reading!
Here is the entire world class.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Maze here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Maze extends World
{
private int room_Num = 0;
public static int world =
{ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//0: Ungenroom
{ 1, 2, 1, 0, 1, 0, 1, 0, 1, 0, 1},//1: Level 1 Room
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//2: Level 2 Room
{ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1},//3: Level 3 Room
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//4: Level 4 Room
{ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1},//5: Level 5 Room
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//6
{ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1},//7: Key Room
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//8: Treasure Room
{ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1},//9: Stair Room
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, };//10
public Knight player = new Knight();
/**
* Constructor for objects of class Town.
*
*/
public Maze()
{
// Create a new world with 640x640 cells with a cell size of 1x1 pixels.
super(640, 640, 1);
addObject(player, 312, 312);
MazeGen gen = new MazeGen();
loadRoom();
}
public void act()
{
knight_Tracker();
}
public void knight_Tracker()
{
if (player.get_X() == 0)
{
change_Rooms_Left();
}
if (player.get_X() == 639)
{
change_Rooms_Right();
}
if (player.get_Y() == 0)
{
change_Rooms_Up();
}
if (player.get_Y() == 639)
{
change_Rooms_Down();
}
}
public void change_Rooms_Down()
{
int x = get_X_Location();
int y = get_Y_Location();
int a = player.get_X();
world = room_Num;
y = y + 2;
room_Num = world;
world = 2;
removeObject(player);
addObject(player, a, 1);
loadRoom();
}
public void change_Rooms_Up()
{
int x = get_X_Location();
int y = get_Y_Location();
int a = player.get_X();
world = room_Num;
y = y - 2;
room_Num = world;
world = 2;
removeObject(player);
addObject(player, a, 638);
loadRoom();
}
public void change_Rooms_Left()
{
int x = get_X_Location();
int y = get_Y_Location();
int a = player.get_Y();
world = room_Num;
x = x - 2;
room_Num = world;
world = 2;
removeObject(player);
addObject(player, 638, a);
loadRoom();
}
public void change_Rooms_Right()
{
int x = get_X_Location();
int y = get_Y_Location();
world = room_Num;
x = x + 2;
room_Num = world;
world = 2;
removeObject(player);
addObject(player, 1, 320);
loadRoom();
}
public int get_Y_Location()
{
int y_Location = 0;
for (int x = 0; x<=10; x++)
{
for (int y = 0; y<=10; y++)
{
if(world == 2)
{
y_Location = y;
}
}
}
return y_Location;
}
public int get_X_Location()
{
int x_Location = 0;
for (int x = 0; x<=10; x++)
{
for (int y = 0; y<=10; y++)
{
if(world == 2)
{
x_Location = x;
}
}
}
return x_Location;
}
public void loadRoom()
{
int x = get_X_Location();
int y = get_Y_Location();
removeObjects(getObjects(Object.class));
x++;
if (world == 1)
{
RIGHT();
}
else
{
doorRIGHT();
}
x--;
x--;
if (world == 1)
{
LEFT();
}
else
{
doorLEFT();
}
x++;
y--;
if (world == 1)
{
UP();
}
else
{
doorUP();
}
y++;
y++;
if (world == 1)
{
DOWN();
}
else
{
doorDOWN();
}
y--;
if (room_Num == 7)
{
keyRoom();
}
if (room_Num == 8)
{
treasureRoom();
}
}
public void treasureRoom()
{
}
public void keyRoom()
{
}
public void doorUP()
{
for (int a = 0; a != 2; a++)
{
addObject(new Object(), 126*a+63, 0);
}
for (int a = 3; a != 5; a++)
{
addObject(new Object(), 126*a+63, 0);
}
}
public void doorLEFT()
{
for (int a = 0; a != 3; a++)
{
addObject(new Object(), 0, 96*a);
}
for (int a = 4; a != 7; a++)
{
addObject(new Object(), 0, 96*a);
}
}
public void doorDOWN()
{
for (int a = 0; a != 2; a++)
{
addObject(new Object(), 126*a+63, 640);
}
for (int a = 3; a != 6; a++)
{
addObject(new Object(), 126*a+63, 640);
}
}
public void doorRIGHT()
{
for (int a = 0; a != 3; a++)
{
addObject(new Object(), 640, 96*a);
}
for (int a = 4; a != 7; a++)
{
addObject(new Object(), 640, 96*a);
}
}
public void UP()
{
for (int a = 0; a != 6; a++)
{
addObject(new Object(), 126*a+63, 0);
}
}
public void DOWN()
{
for (int a = 0; a != 6; a++)
{
addObject(new Object(), 126*a+63, 640);
}
}
public void LEFT()
{
for (int a = 0; a != 6; a++)
{
addObject(new Object(), 0, 126*a+63);
}
}
public void RIGHT()
{
for (int a = 0; a != 6; a++)
{
addObject(new Object(), 640, 126*a+63);
}
}
}

