1 |
|
package KITExcellence; |
2 |
|
|
3 |
|
import java.io.IOException; |
4 |
|
import java.util.Hashtable; |
5 |
|
|
6 |
|
public class SpriteManager { |
7 |
1 |
private Hashtable sprites = new Hashtable(); |
8 |
|
private GameTimer timer; |
9 |
|
|
10 |
1 |
public SpriteManager(GameTimer timer) throws IOException { |
11 |
1 |
this.timer = timer; |
12 |
|
|
13 |
1 |
SpriteData tux = new SpriteData(); |
14 |
1 |
tux.testCreateTux(); |
15 |
1 |
sprites.put("tux", tux); |
16 |
1 |
SpriteData snowball = new SpriteData(); |
17 |
1 |
snowball.testCreateSnowball(); |
18 |
1 |
sprites.put("snowball", snowball); |
19 |
1 |
} |
20 |
|
|
21 |
|
public Sprite createSprite(String name) { |
22 |
1 |
SpriteData data = (SpriteData) sprites.get(name); |
23 |
1 |
if (data == null) |
24 |
0 |
throw new RuntimeException("Sprite " + name + " not found"); |
25 |
|
|
26 |
1 |
return new Sprite(data, timer); |
27 |
|
} |
28 |
|
} |