-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathmain.c
More file actions
1109 lines (976 loc) · 25.3 KB
/
Copy pathmain.c
File metadata and controls
1109 lines (976 loc) · 25.3 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/******************************************************************************
**
** Copyright(C) 1995, an unpublished work by The 3DO Company. All rights
*reserved.
** This material contains confidential information that is the property of The
*3DO Company.
** Any unauthorized duplication, disclosure or use is prohibited.
** $Id: orbit.c,v 1.19 1995/01/16 19:48:35 vertex Exp $
**
******************************************************************************/
/**
||| AUTODOC PUBLIC examples/3doorbit
||| 3doorbit - Demonstrates incorporating moving animations and sound
effects.
|||
||| Synopsis
|||
||| 3doorbit
|||
||| Description
|||
||| Demonstrates loading a background image, several animations, and
some
||| sound effects, and shows how you can integrate them.
|||
||| The 3DO logo spins around and spirals back into place.
|||
||| Associated Files
|||
||| orbit.c, orbit.h, orbiterror.h
|||
||| Location
|||
||| examples/Graphics/3DO_Orbit
|||
**/
#include "orbit.h"
void
Usage(void)
{
PRT(("Stop exits\n"));
return;
}
/*********************
** Initialize - initialization routine
**
** Synopsis
**
** static s32 Initialize( ScreenContext *sc, s32 nScreens )
**
** Description
**
** This function opens the graphics, audio, and math folios,
*initializes for 1 * controlpad, and creates an error text and a couple
*of IO req items
**
** Arguments
**
** sc pointer to a screen context structure
**
** nScreens the number of screens to create
**
**
** Return Value
**
** The function returns 0 if successful or an error code(a negative
*value) * if an error occurs.
**
**
** Implementation
**
** Called prior to main loop
**
** Caveats
**
** none
**
** Associated Files
**
** orbit.h orbiterror.h orbitsound.c controlpad.h controlpad.c
*effectshandler.c effectshandler.h
**
** See Also
**
**
*********************/
static s32
Initialize(ScreenContext *sc, s32 nScreens)
{
s32 status = 0;
/*
create an error text item to return opera style errors
*/
status = CreateItem(MKNODEID(KERNELNODE, ERRORTEXTNODE), OrbitErrorTags);
if(status < 0)
goto CLEANUP;
gOrbitErrorItem = status;
/*
open the graphics folio, fill in the screen context structure
for nScreens screens
*/
if(!CreateBasicDisplay(sc, DI_TYPE_NTSC,(int)nScreens))
{
status = ORBITGRAPHICS_ERR;
goto CLEANUP;
}
sc->sc_curScreen = 0;
/*
get an io req item for SPORT transfers, and for using the VBL timer
*/
status = CreateVRAMIOReq();
if(status < 0)
goto CLEANUP;
gVramIOReq = status;
status = CreateVBLIOReq();
if(status < 0)
goto CLEANUP;
gVblIOReq = status;
/*
open the math folio for doing some trig
*/
status = OpenMathFolio();
if(status < 0)
goto CLEANUP;
/*
open the audio folio and set up for playing soundeffects. Use the
convenience functions found in effectshandler.c
*/
status = OpenAudioFolio();
if(status < 0)
goto CLEANUP;
status = ehNewMixerInfo(&gAudioCtx, 2, "mixer2x2.dsp");
if(status < 0)
{
status = ORBITAUDIOCTX_ERR;
goto CLEANUP;
}
/*
Create a cue to use for knowing when a sample has finished playing.
allocate a signal with which we will be notified that a sound effect
has stopped
*/
status = CreateCue(NULL);
if(status < 0)
goto CLEANUP;
gCue = status;
gCueSignal = GetCueSignal(gCue);
/*
init structures and resources for querying the controlpad
*/
status = InitControlPad(1);
if(status < 0)
goto CLEANUP;
CLEANUP:
return status;
}
/*********************
** DrawScreen - routine to draw the background, all the cels, and display
*the screen
**
** Synopsis
**
** static void DrawScreen( ScreenContext *sc, OrbitObjPtr obj, ubyte
**background )
**
** Description
**
** This function toggles the screen counter, copies the background
*pic, draws the cels, and * displays the screen
**
** Arguments
**
** sc pointer to a screen context structure
**
** obj array of objects containing info about the
*cels
**
** background pointer to the background bitmap
**
** Return Value
**
** None.
**
**
** Implementation
**
** Called once per frame update.
**
** Caveats
**
** None.
**
** Associated Files
**
**
** See Also
**
** CopyVRAMPages(), DrawCels(), DisplayScreen()
**
*********************/
static void
DrawScreen(ScreenContext *sc, OrbitObjPtr obj, ubyte *background)
{
/*
toggle the current screen counter
*/
sc->sc_curScreen ^= 1;
/*
copy the background image. This does an implicit WaitVBL.
*/
CopyVRAMPages(gVramIOReq, sc->sc_Bitmaps[sc->sc_curScreen]->bm_Buffer,
background, sc->sc_nFrameBufferPages, ~0);
/*
draw all of the cels at once. These have been previously linked
together
*/
DrawCels(sc->sc_BitmapItems[sc->sc_curScreen], obj[0].obj_CCB);
/*
This queues up the screen we just drew to be displayed at
the next vertical blank. The function returns immediately, however
*/
DisplayScreen(sc->sc_Screens[sc->sc_curScreen], 0);
return;
}
/*********************
** main - main routine
**
** Synopsis
**
** int main( void )
**
** Description
**
** This function initializes the system, loads in a 3DO background and
** all of the graphics objects, loads in sound effects, drops into a
*main loop where it queries the control * pad and reacts to it,
*double buffers, and renders all the artwork
**
** Arguments
**
**
** Return Value
**
** The function exits with 0.
**
**
** Implementation
**
**
** Caveats
**
** None.
**
** Associated Files
**
** orbit.h orbiterror.h orbitsound.c orbitsound.h controlpad.h
*controlpad.c
**
** See Also
**
**
*********************/
int
main(s32 argc, char *argv[])
{
ScreenContext sc;
OrbitObjPtr obj = NULL;
ubyte *background = NULL;
u32 button;
s32 status = 0;
PRT(("%s %s\n", argv[0], VERSION));
Usage();
/*
initialize the system, open all the folios, get all the necessary
resources
*/
if((status = Initialize(&sc, 2)) < 0)
{
PrintfSysErr(status);
exit(0);
}
/*
load in the background image
*/
background
=(ubyte *)LoadImage("orbit_data/art/background.imag", NULL, NULL, &sc);
if(background == NULL)
{
status = ORBITLOADIMAGE_ERR;
goto CLEANUP;
}
/*
load in all the aiff files that will be used as sound effects
*/
status = LoadSounds();
if(status < 0)
goto CLEANUP;
/*
load all of the 3doorbit graphics objects
*/
status = LoadObj(&obj);
if(status < 0)
goto CLEANUP;
/*
initialize values for the graphics objects
*/
InitObj(obj);
/*
drop into the main loop until the user quits
*/
while(true)
{
/*
Query the control pad
*/
status = DoControlPad(1, &button, 0);
if(status < 0)
break;
/*
if the X button is hit, then exit
*/
if(button == ControlX)
break;
/*
update the positioning of the objects. If the animation sequence
has reached its conclusion, then reset all the objects and start over.
*/
if(UpdateObj(obj))
InitObj(obj);
/*
render and display all of the objects in their updated positions
*/
DrawScreen(&sc, obj, background);
}
CLEANUP:
if(status < 0)
PrintfSysErr(status);
FadeToBlack(&sc, 20);
UnloadObj(obj);
KillControlPad();
DeleteCue(gCue);
ehDisposeSampleInfo(gClickSound);
ehDisposeSampleInfo(gCheerSound);
ehDisposeMixerInfo(gAudioCtx);
CloseAudioFolio();
CloseMathFolio();
DeleteBasicDisplay(&sc);
PRT(("Exiting\n"));
exit(0);
}
/*********************
** LoadSounds - loads in sound effects
**
** Synopsis
**
** static s32 LoadSounds(void)
**
** Description
**
** This function loads in a couple of sound effects that will be used
*during the program
**
** Arguments
**
** None.
**
** Return Value
**
** The function returns 0 if all went well, < 0 on an error.
**
**
** Implementation
**
** This function must be called before any of the sound effects can be
*played back.
**
** Caveats
**
** None.
**
** Associated Files
**
** effectshandler.c effectshandler.h
**
** See Also
**
** ehLoadSoundEffect()
**
*********************/
static s32
LoadSounds(void)
{
s32 status = 0;
status = ehLoadSoundEffect(&gClickSound, gAudioCtx,
"orbit_data/sounds/click.aiff", 0);
if(status < 0)
{
status = ORBITLOADSOUND_ERR;
goto CLEANUP;
}
status = ehLoadSoundEffect(&gCheerSound, gAudioCtx,
"orbit_data/sounds/cheer.aiff", 1);
if(status < 0)
{
status = ORBITLOADSOUND_ERR;
goto CLEANUP;
}
CLEANUP:
return status;
}
/*********************
** SetObjCCB - sets the 3doorbit objects' ccbs
**
** Synopsis
**
** static s32 SetObjCCB( OrbitObj *obj, s32 iObj )
**
** Description
**
** This function sets a 3doorbit object CCB with legitimate values
*from the first frame of the animation
**
** Arguments
**
** None.
**
** Return Value
**
** The function returns 0 if all went well, < 0 on an error.
**
**
** Implementation
**
** This function must be called to set values in the CCBs and avoid
*errors.
**
** Caveats
**
** None.
**
** Associated Files
**
** orbit.h
**
** See Also
**
**
*********************/
static s32
SetObjCCB(OrbitObj *obj, s32 iObj)
{
s32 status = 0;
/*
allocate space for a CCB, then grab the first frame of the animation
and copy its values into this dummy ccb to make sure that we have
legitimate values in there.
*/
obj[iObj].obj_CCB
=(CCB *)AllocMem(sizeof(CCB), MEMTYPE_CEL | MEMTYPE_FILL | 0x00);
if(obj[iObj].obj_CCB != NULL)
memcpy(obj[iObj].obj_CCB, GetAnimCel(obj[iObj].obj_ANIM, 0),
sizeof(CCB));
else
status = ORBITALLOC_ERR;
return status;
}
/*********************
** LoadObj - loads in the three graphical objects for 3doorbit
**
** Synopsis
**
** static s32 LoadObj( OrbitObjPtr *pObj )
**
** Description
**
** This function loads in one cel and two anims
**
** Arguments
**
** None.
**
** Return Value
**
** The function returns 0 if all went well, < 0 on an error.
**
**
** Implementation
**
** This function must be called before any graphics can be displayed.
**
** Caveats
**
** None.
**
** Associated Files
**
** orbit.h
**
** See Also
**
** LoadCel(), LoadAnim()
**
*********************/
static s32
LoadObj(OrbitObjPtr *pObj)
{
s32 iObj = 0, status = 0;
OrbitObjPtr obj;
/*
allocate an array of 3 OrbitObj
*/
obj =(OrbitObjPtr)AllocMem(3 * sizeof(OrbitObj),
MEMTYPE_TRACKSIZE | MEMTYPE_FILL | 0x00);
if(obj == NULL)
{
status = ORBITALLOC_ERR;
goto CLEANUP;
}
/*
load in the first cel... this will be cel[0] in the list of cels
passed off to the cel engine
*/
obj[iObj].obj_CCB = LoadCel("orbit_data/art/ball.cel", MEMTYPE_CEL);
if(obj[iObj].obj_CCB == NULL)
{
status = ORBITALLOC_ERR;
goto CLEANUP;
}
/*
actual height of cel, minus all the black border pixels
*/
obj[iObj].obj_Height = 42;
/*
load in the remaining two animations. Set a dummy ccb for each one
*/
obj[++iObj].obj_ANIM = LoadAnim("orbit_data/art/tvd.anim", MEMTYPE_CEL);
if(obj[iObj].obj_ANIM == NULL)
{
status = ORBITALLOC_ERR;
goto CLEANUP;
}
status = SetObjCCB(obj, iObj);
if(status < 0)
goto CLEANUP;
/*
actual height of cel, minus all the black border pixels
*/
obj[iObj].obj_Height = 33;
obj[++iObj].obj_ANIM = LoadAnim("orbit_data/art/cube3.anim", MEMTYPE_CEL);
if(obj[iObj].obj_ANIM == NULL)
{
status = ORBITALLOC_ERR;
goto CLEANUP;
}
status = SetObjCCB(obj, iObj);
if(status < 0)
goto CLEANUP;
/*
actual height of cel, minus all the black border pixels
*/
obj[iObj].obj_Height = 46;
*pObj = obj;
CLEANUP:
return status;
}
/*********************
** UnloadObj - frees up memory associated with orbitobj's
**
** Synopsis
**
** static void UnloadObj( OrbitObjPtr obj )
**
** Description
**
** This function frees up memory associated with orbitobj's
**
** Arguments
**
** obj an array of 3doorbit
*objects
**
** Return Value
**
** None.
**
**
** Implementation
**
**
** Caveats
**
** None.
**
** Associated Files
**
** orbit.h
**
** See Also
**
** UnloadCel(), UnloadAnim()
**
*********************/
static void
UnloadObj(OrbitObjPtr obj)
{
s32 iObj;
for(iObj = 0; iObj < 3; iObj++)
{
if(obj[iObj].obj_ANIM)
{
UnloadAnim(obj[iObj].obj_ANIM);
FreeMem(obj[iObj].obj_CCB, sizeof(CCB));
}
else
UnloadCel(obj[iObj].obj_CCB);
}
FreeMem(obj, -1);
return;
}
/*********************
** InitObj - initializes values for the beginning of the animation
*sequence
**
** Synopsis
**
** static void InitObj( OrbitObjPtr obj )
**
** Description
**
** This function initializes values for the orbit objects. Values
*such as the starting * positions, speeds, etc.
**
** Arguments
**
** obj an array of 3doorbit
*objects
**
** Return Value
**
** The function returns 0 if all went well, < 0 on an error.
**
**
** Implementation
**
** This function must be called before any graphics can be displayed.
**
** Caveats
**
** None.
**
** Associated Files
**
** orbit.h
**
** See Also
**
**
*********************/
static void
InitObj(OrbitObjPtr obj)
{
s32 iObj;
frac16 angle;
/*
the trig functions are based on lookup tables dividing a circle into
256 units. We want the objects to originally be 120 degrees apart... which
translates into 85.3333 of a circle in the operamath units. As a
frac16, 85.3333 is(85 << 16) +(1 <<16)/3, which breaks down into 85 <<
16 + 0x5555, or 0x555555
*/
angle = 0x555555;
/*
link the ccbs for the orbit objects together so that they can all be
drawn with a single call to draw cels.
*/
for(iObj = 0; iObj < 3; iObj++)
{
if(iObj == 2)
{
obj[iObj].obj_CCB->ccb_Flags |= CCB_LAST;
obj[iObj].obj_CCB->ccb_NextPtr = NULL;
}
else
{
obj[iObj].obj_CCB->ccb_Flags &= ~CCB_LAST;
obj[iObj].obj_CCB->ccb_NextPtr = obj[iObj + 1].obj_CCB;
}
/*
set the initial radius, angle, velocity, frame increment, etc for
the orbit objects. Watch out for what is a frac16 and an s32. Get
a little bit of a speed boost by figuring ahead of time what the
frac16 representation is of an s32 so we don't have to continually
do bit shifting during run time
*/
obj[iObj].obj_radius = RADIUS;
obj[iObj].obj_theta = MulSF16(angle, iObj << 16);
obj[iObj].obj_velocity = VELOCITY;
obj[iObj].obj_frameIncr = FRAMEINCR;
/*
because our calculations are going to be based on the center of
the cel... we need to know where the upper left hand corner is in
relation to that.
*/
obj[iObj].obj_centerX = XCenter -(obj[iObj].obj_CCB->ccb_Width << 15);
obj[iObj].obj_centerY = YCenter -(obj[iObj].obj_CCB->ccb_Height << 15);
/*
This is what happens when your programmer doesn't talk to your
artist... or when you get artwork from somewhere beyond your control.
Because the artwork has some black borders, and I want the
artwork to be drawn right on top of each other(to spaces between)...
I have to figure out the appropriate offsets and take them into
consideration. That is why I needed to know what the real height of
the artwork is. Overall, it just makes this program and the logic
messier
*/
obj[iObj].obj_Border
=(obj[iObj].obj_CCB->ccb_Height - obj[iObj].obj_Height) << 15;
/*
A bunch of state flags that are going to be used to determine if
certain things should occur. For instance, should the large orbit be
broken and shifted into the spiral orbit.... is the object stopped and
should we focus on the next object, etc etc.
*/
obj[iObj].obj_Stopping = false;
obj[iObj].obj_Stopped = false;
obj[iObj].obj_WaitingToStop = false;
obj[iObj].obj_Set = false;
}
return;
}
/*********************
** UpdateObj - updates the positions of all the cels
**
** Synopsis
**
** static bool UpdateObj( OrbitObjPtr obj )
**
** Description
**
** This function drives the animation sequence for this program. Based
*on various states, it
** updates the positions of the three cels based on specific
*trajectories. * It updates the animations, as well as updating the
*trajectories given * the state of the animation.
**
** The logic is kinda messed up and confusing... please bear with it.
*Its been a while since I've had * my geometry and trig.
**
** Arguments
**
** obj an array of 3doorbit
*objects
**
** Return Value
**
** The function returns false if the sequence is not yet completed,
*true is it is
**
**
** Implementation
**
** Call this function once during each iteration of the main loop.
**
** Caveats
**
** None.
**
** Associated Files
**
**
** See Also
**
**
*********************/
static bool
UpdateObj(OrbitObjPtr obj)
{
s32 iObj;
static toStop = 0;
CCB *ccb, *objCCB;
OrbitObjPtr object;
u32 signals;
/*
if all the animations have ended, then play the ending sound, wait
until its done, then reset everything by returning true;
*/
if(toStop > 2)
{
/*
set up to monitor the soundeffect, and be notified when it has
concluded. Start the soundeffect, wait for the cue, then stop the
instrument
*/
MonitorAttachment(gCheerSound->si_Attachment, gCue, CUE_AT_END);
StartInstrument(gCheerSound->si_Player, NULL);
WaitSignal(gCueSignal);
StopInstrument(gCheerSound->si_Player, NULL);
toStop = 0;
return true;
}
/*
check to see whether the "click" sound effect has ended yet. We will
be notified at its conclusion through the cue and its signal. If we've
received the signal, then the effect has ended, and we can move onto the
trajectory of the next object. Clear the signal, and update which object
we're going to be slowing and stopping.
If the effect hasn't yet ended, then keep the other objects going
until it has
*/
signals = GetCurrentSignals();
if(signals & gCueSignal)
{
WaitSignal(gCueSignal);
StopInstrument(gClickSound->si_Player, NULL);
toStop++;
}
/*
if an object is in a position where it should be stopped, set its
position, stop it, wait until it gets to the first frame of the animation
and play the click sound effect
*/
if(obj[toStop].obj_Stopping && obj[toStop].obj_theta <= HALFCIRCLE)
{
obj[toStop].obj_velocity = 0;
obj[toStop].obj_theta = HALFCIRCLE;
obj[toStop].obj_CCB->ccb_XPos
= obj[toStop].obj_centerX
+ MulSF16(obj[toStop].obj_radius, SinF16(obj[toStop].obj_theta));
obj[toStop].obj_CCB->ccb_YPos
= obj[toStop].obj_centerY
+ MulSF16(obj[toStop].obj_radius, CosF16(obj[toStop].obj_theta));
if(obj[toStop].obj_ANIM)
{
/*
because GetAnimCel() returns the frame and then increments
the counter, we actually have to wait until the current frame is 1
rather than 0. When it is 1, we know that what is currently being
displayed is the first frame
*/
if(obj[toStop].obj_ANIM->cur_Frame == 0x10000)
{
obj[toStop].obj_Stopped = true;
obj[toStop].obj_Stopping = false;
MonitorAttachment(gClickSound->si_Attachment, gCue, CUE_AT_END);
StartInstrument(gClickSound->si_Player, NULL);
}
}
/*
there are two anims and one cel in this program... Obviously, for
the cel, we don't have to do anything special regarding which frame to
show... so just stop it and make some noise
*/
else
{
obj[toStop].obj_Stopped = true;
obj[toStop].obj_Stopping = false;
MonitorAttachment(gClickSound->si_Attachment, gCue, CUE_AT_END);
StartInstrument(gClickSound->si_Player, NULL);
}
}
/*
This is the central logic loop for updating an object. If its
moving, accelerate it until its speed reaches a predefined maximum
(oooh... I remember my physics now... the difference between speed and
velocity!). Until that time, simply adjust each object's position.
Once that max speed is reached, then at the appropriate time... reset
the object's trajectory so that it spirals into place
*/
for(iObj = 0; iObj < 3; iObj++)
{
/*
if the object is stopped, skip it
*/
if(obj[iObj].obj_Stopped)
continue;
/*
adjust the angle of the object. If its less than 0 degrees(
which in this case, due to the rotated axes(see below), is along the
positive y axis), make the angle positive.
Also, if the object was in its last orbit prior to stopping...
then start it stopping ;-)
*/
obj[iObj].obj_theta -= obj[iObj].obj_velocity;
if(obj[iObj].obj_theta < 0)
{