I am programming a small game for my school assignment, the game is a simple 2D game with monsters, items and bullets. Basically you run around and tries to collect all the item coins, the monsters tries to prevent you and you can shoot them down with the bullets that you collect. Very simple.
The question is, i have added the monsters, items, walls, player and bullets to a static class named LiveObjects, these objects can i then access from any place in the code. Is it a bad practice? Whats the alternative? (It's not multithreaded)
LiveObjects.cs
internal static class LiveObjects
{
public static List<Item> items = new List<Item>(); // List with all the items
public static List<Monster> monsters = new List<Monster>(); // List with all present monsters
public static List<Wall> walls = new List<Wall>(); // List with the walls
public static List<Bullet> bullets = new List<Bullet>(); // List with the bullets
public static Player player = new Player(0, 0); // The player object
}
I use a lot of different classes to manipulate the data inside the LiveObjects and then to avoid passing an entire List, i can just call it directly inside any method.