00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 package org.classroomgaming.cgp;
00021
00022 import java.awt.*;
00023 import java.util.*;
00024
00025 public class GameWorld extends GameObject {
00026
00027 private LinkedHashMap<String, Entity> objects;
00028 private static final GameWorld mgr = new GameWorld();
00029
00030
00031
00035 public GameWorld() {
00036
00037 objects = new LinkedHashMap<String, Entity>();
00038 }
00039
00040 public void ponder(float t) {
00041 for (Iterator it = objects.values().iterator(); it.hasNext();) {
00042 Entity o = (Entity) it.next();
00043 o.ponder(t);
00044 }
00045 }
00046
00047 public Entity getObjectByName(String name) {
00048 Object o = objects.get(name);
00049 return (Entity) o;
00050 }
00051
00052 public boolean createObject(String name, Spawner t, float x, float y) {
00053 if (objects.containsKey(name)) {
00054 return false;
00055 }
00056 Entity obj = t.create(name);
00057 obj.setX(x);
00058 obj.setY(y);
00059 objects.put(name, obj);
00060 return true;
00061 }
00062
00063 public void render(Graphics g) {
00064 super.render(g);
00065 for (Iterator it = objects.values().iterator(); it.hasNext();) {
00066 Entity o = (Entity) it.next();
00067 o.render(g);
00068 }
00069 }
00070 }
00071
00072