Created
January 19, 2013 02:09
-
-
Save jorgenpt/4570243 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Component { | |
public void update(int delta); | |
public void render(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
class Entity { | |
private List<Component> components = new ArrayList<Component>(); | |
public void addComponent(Component c) { | |
components.add(c); | |
} | |
public void update(int delta) { | |
for (Component c : components) { | |
c.update(); | |
} | |
} | |
public void render() { | |
for (Component c : components) { | |
c.render(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment