-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssets.pde
56 lines (45 loc) · 1.39 KB
/
Assets.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/** Global file manager. Can load and save files. */
class Assets {
String dataFolder; ///< root folder of the game
AudioRepository audio; ///< global audio repository
ImageRepository img; ///< global image repository
LevelRepository levels; ///< global level repository
GunRepository guns; ///< global gun repository
BulletRepository bullets; ///< global bullet repository
Assets( String fold ) {
dataFolder = fold;
audio = new AudioRepository( this );
img = new ImageRepository( this );
levels = new LevelRepository( this );
guns = new GunRepository( this );
bullets = new BulletRepository( this );
}
/** Returns file by local (from dataFolder) name */
File getFile( final String name ) {
return sketchFile( dataFolder + name );
}
String getAbsolutePath() {
return getFile("").getPath();
}
}
/** Interface for objects` builders */
interface Builder {
/** Builds an object and puts it on the scene @param sc */
Object build( Scene sc );
/** Adds line to object data */
void addLine( String str );
}
class DummyBuilder implements Builder {
Object build( Scene sc ) {
return null;
}
void addLine( String str ) {
}
}
/** Interface for objects` serializers */
interface Serializer {
/** Serializes object */
String[] serialize();
/** Sets object to serialize */
void setObject( Object obj );
}