3 * Daniel Nelson - 8/24/0
5 * Copyright (C) 2000 Daniel Nelson
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 * Daniel Nelson - aluminumangel.org
26 #ifndef GARBAGEMANAGER_H
27 #define GARBAGEMANAGER_H
34 #include "GarbageFlavorImage.h"
38 /* static */ class GarbageManager
{
40 static void gameStart ( );
41 static bool newFallingGarbage ( int height
, int width
, int flavor
);
43 static inline void newAwakingGarbage ( int x
, int y
, int height
,
44 int pop_delay
, int awake_delay
, ComboTabulator
*combo
, int pop_color
)
46 if (garbage_count
== GC_GARBAGE_STORE_SIZE
) return;
48 int id
= findFreeId();
50 Garbage
*garbage
= garbageStore
+ id
;
52 garbage
->initializeAwaking(x
, y
, height
, pop_delay
, awake_delay
, combo
,
56 static inline void newFallingGarbage ( int x
, int y
, int height
, int width
,
59 if (garbage_count
== GC_GARBAGE_STORE_SIZE
) return;
61 int id
= findFreeId();
63 Garbage
*garbage
= garbageStore
+ id
;
65 garbage
->initializeFalling(x
, y
, height
, width
, flavor
);
67 GarbageFlavorImage::requestGarbageFlavorImage(*garbage
);
70 static inline void deleteGarbage ( Garbage
*garbage
)
72 GarbageFlavorImage::notifyGarbageDestruction(*garbage
);
76 static inline void shiftUp ( )
78 int c
= garbage_count
;
79 for (int n
= 0; c
; n
++)
86 static inline bool isSpecialFlavor ( int flavor
)
91 static inline int mapBlockCodeToGarbageFlavor ( int code
)
93 return code
+ (GF_GRAY
+ 1);
96 static int garbage_count
;
97 static Garbage garbageStore
[GC_GARBAGE_STORE_SIZE
];
98 static bool storeMap
[GC_GARBAGE_STORE_SIZE
];
101 static inline int findFreeId ( )
104 for (n
= 0; storeMap
[n
]; n
++);
108 static inline void allocateId ( int id
)
110 assert(!storeMap
[id
]);
115 static inline void freeId ( int id
)
117 assert(storeMap
[id
]);
118 storeMap
[id
] = false;