Added smoke when driving. Removed chasers for now.
This commit is contained in:
parent
c546f29ff4
commit
e93a967cb0
Binary file not shown.
Binary file not shown.
|
@ -14,8 +14,7 @@
|
|||
// headers for binary data generated by bin2o macro in makefile
|
||||
#include "car_pal_bin.h"
|
||||
#include "car_bin.h"
|
||||
#include "chaser_bin.h"
|
||||
|
||||
#include "smoke_bin.h"
|
||||
|
||||
#include "sinlut.h"
|
||||
|
||||
|
@ -30,11 +29,12 @@ typedef s32 FIXED; // 32bit FIXED in 24.8 format
|
|||
#define lut_cos(x) _sinLUT[(x + (SIN_SIZE>>2)) & SIN_MASK]
|
||||
|
||||
|
||||
#define NUMCHASERS 10
|
||||
#define NUMSMOKES 20
|
||||
|
||||
u16 PaletteBuffer[256];
|
||||
OBJATTR oe_buffer[1+NUMCHASERS];
|
||||
OBJATTR oe_buffer[1+NUMSMOKES];
|
||||
OBJAFFINE *const oa_buffer = (OBJAFFINE*)oe_buffer;
|
||||
s8 smoke_frame[NUMSMOKES];
|
||||
|
||||
unsigned int frame;
|
||||
|
||||
|
@ -48,8 +48,8 @@ int main(void)
|
|||
{
|
||||
OBJATTR*car = &oe_buffer[0];
|
||||
OBJAFFINE*car_aff = &oa_buffer[0];
|
||||
// We'll make a few chasers
|
||||
OBJATTR*chasers = &oe_buffer[1];
|
||||
// We'll make a few smoke clouds
|
||||
OBJATTR*smokes = &oe_buffer[1];
|
||||
|
||||
// Set up the interrupt handlers
|
||||
InitInterrupt();
|
||||
|
@ -72,20 +72,23 @@ int main(void)
|
|||
void* free_space = BITMAP_OBJ_BASE_ADR;
|
||||
CpuFastSet(car_bin, free_space, COPY32 | car_bin_size/4);
|
||||
free_space += car_bin_size;
|
||||
CpuFastSet(chaser_bin, free_space, COPY32 | chaser_bin_size/4);
|
||||
free_space += chaser_bin_size;
|
||||
|
||||
CpuFastSet(car_pal_bin, OBJ_COLORS, COPY32 | car_pal_bin_size/4);
|
||||
|
||||
// load smoke
|
||||
CpuFastSet(smoke_bin, free_space, COPY32 | smoke_bin_size/4);
|
||||
free_space += smoke_bin_size;
|
||||
|
||||
car->attr2 = OBJ_CHAR(512);
|
||||
|
||||
s32 base = (s32)(0.707106781 * 256);
|
||||
s32 one = 1 << 8;
|
||||
u8 next_smoke = 0;
|
||||
|
||||
u8 i;
|
||||
for (i=0; i<NUMCHASERS; i++) {
|
||||
chasers[i].attr2 = OBJ_CHAR(520);
|
||||
chasers[i].attr1 = OBJ_X(20+(i*10));
|
||||
chasers[i].attr0 = OBJ_256_COLOR | OBJ_DOUBLE | OBJ_ROT_SCALE_ON | OBJ_Y(40);
|
||||
for (i=0; i<NUMSMOKES; i++) {
|
||||
smokes[i].attr1 = OBJ_X(20+(i*10));
|
||||
smokes[i].attr0 = OBJ_256_COLOR | OBJ_Y(40);
|
||||
// 6 == off
|
||||
smoke_frame[i] = 6;
|
||||
}
|
||||
|
||||
FIXED x = INT2FIX(112);
|
||||
|
@ -157,6 +160,35 @@ int main(void)
|
|||
car->attr1 = OBJ_SIZE(1) | OBJ_X(FIX2INT(x));
|
||||
car->attr0 = OBJ_256_COLOR | OBJ_DOUBLE | OBJ_ROT_SCALE_ON | OBJ_Y(FIX2INT(y));
|
||||
|
||||
// Update smoke cloud frames
|
||||
if ((frame & 3) == 3) {
|
||||
for (i=0; i<NUMSMOKES; i++) {
|
||||
if (smoke_frame[i] < 6) {
|
||||
smoke_frame[i] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// place a new smoke cloud after car if driving
|
||||
// forwards
|
||||
if ((speed!=0) && ((frame & 1) == 1)) {
|
||||
for (i=0; i<NUMSMOKES; i++) {
|
||||
if (smoke_frame[i] == 6) {
|
||||
smoke_frame[i] = 0;
|
||||
smokes[i].attr1 = OBJ_X(FIX2INT(x)+12);
|
||||
smokes[i].attr0 = OBJ_256_COLOR | OBJ_Y(FIX2INT(y)+12);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
next_smoke += 1;
|
||||
if (next_smoke>=NUMSMOKES) {
|
||||
next_smoke = 1;
|
||||
}
|
||||
|
||||
for (i=0; i<NUMSMOKES; i++)
|
||||
smokes[i].attr2 = OBJ_CHAR(520 + 2*smoke_frame[i]);
|
||||
|
||||
VBlankIntrWait();
|
||||
CpuFastSet(oe_buffer, OAM, COPY32 | sizeof(oe_buffer)/4);
|
||||
}
|
||||
|
|
Reference in New Issue