2 // A miniature implementation of the object manager.
3 // It runs the little "mascots" that come on the screen after a while in the options menu.
5 #include "../common/llist.h"
8 using namespace Options
;
10 Object
*firstobj
, *lastobj
;
12 #define OC_CONTROLLER 0
16 void Options::init_objects()
20 create_object(0, 0, OC_CONTROLLER
);
23 void Options::close_objects()
28 Object
*next
= o
->next
;
33 firstobj
= lastobj
= NULL
;
36 void Options::run_and_draw_objects(void)
38 void (*ai_routine
[])(Object
*) = {
48 (*ai_routine
[o
->type
])(o
);
49 Object
*next
= o
->next
;
54 LL_REMOVE(o
, prev
, next
, firstobj
, lastobj
);
57 else if (o
->sprite
!= SPR_NULL
)
62 draw_sprite(o
->x
>> CSF
, o
->y
>> CSF
, o
->sprite
, o
->frame
, o
->dir
);
69 Object
*Options::create_object(int x
, int y
, int type
)
73 Object
*o
= new Object
;
79 LL_ADD_END(o
, prev
, next
, firstobj
, lastobj
);
86 void c------------------------------() {}
89 static void ai_oc_controller(Object
*o
)
101 case 1: // delay before next event
105 o
->state
= (++o
->timer2
* 10);
116 create_object(0, 0, OC_QUOTE
);
127 /*if (o->timer < 175)
129 if ((o->timer % 6) == 1)
130 create_object(-16<<CSF, random(-16, SCREEN_HEIGHT) << CSF, OC_CURRENT);
135 if ((o
->timer
% 10) == 1)
136 create_object(-16<<CSF
, random(-16, SCREEN_HEIGHT
) << CSF
, OC_IKACHAN
);
147 static void ai_oc_quote(Object
*o
)
155 o
->xmark
= (SCREEN_WIDTH
- 50) << CSF
;
156 o
->xmark2
= (SCREEN_WIDTH
+ 10) << CSF
;
159 o
->y
= (SCREEN_HEIGHT
- sprites
[o
->sprite
].h
- 8) << CSF
;
162 o
->sprite
= SPR_OC_QUOTE
;
198 if (o
->timer
== 100) o
->frame
= 0;
213 if (o
->x
> o
->xmark2
)
221 static void ai_oc_ikachan(Object
*o
)
228 o
->timer
= random(3, 20);
229 o
->sprite
= SPR_IKACHAN
;
231 case 1: // he pushes ahead
236 o
->timer
= random(10, 50);
243 case 2: // after a short time his tentacles look less whooshed-back
248 o
->timer
= random(40, 50);
250 o
->yinertia
= random(-0x100, 0x100);
269 if (o
->x
> SCREEN_WIDTH
<<CSF
)
274 static void ai_oc_current(Object *o)
276 o->sprite = SPR_WATER_DROPLET;
277 o->frame = random(0, 4);
281 if (o->x > SCREEN_WIDTH<<CSF)