OK, I think I "solved" it.
I noticed that it would be animated when I put it in a different switch case.
So I've created an "instructions" case, and put all the required code there.
Might be a bit of a dirty "hack", but it works I guess...
No idea why though. Maybe I'm missing something...
Code: Select all
#include <genesis.h>
#include "gfx.h"
#define ANIM_STATIC 0
#define ANIM_SCORE 1
#define ANIM_BRONZE 2
#define ANIM_SILVER 3
#define ANIM_GOLD 4
#define ANIM_PLATIN 5
#define ANIM_INSTR 6
#define GRAVITY FIX16(0.4)
#define MIN_POSX FIX16(10)
#define MAX_POSX FIX16(280)
#define MAX_POSY FIX16(154)
#define SLIDESPEED FIX16(6)
#define FALSE 0
#define TITLE 0
#define INTRO 1
#define GAME 2
#define INSTRUCTIONS 3
#define MAX_SPRITE 16
// forward
static void disableInts();
static void enableInts();
static void joyEvent(u16 joy, u16 changed, u16 state);
static void introJoyEvent(u16 joy, u16 changed, u16 state);
static void gameJoyEvent(u16 joy, u16 changed, u16 state);
// sprite structure
//Sprite allsprites[MAX_SPRITE];
//Sprite sprflappy = &allsprites[0];
//Sprite sprinstr = &allsprites[1];
Sprite sprites[MAX_SPRITE];
//Sprite sprflappy = &sprites[0];
fix16 camposx;
fix16 camposy;
fix16 posx;
fix16 posy;
fix16 movx;
fix16 movy;
s16 xorder;
s16 yorder;
int gamestate = TITLE;
int music_status;
volatile int waitflag = FALSE;
int score = 0;
int flappyTitlePosition = 250;
char flappyPosString;
int main()
{
//Title screen
u16 tileIndex = TILE_USERINDEX;
u16 palette[64];
//play VGM
SND_startPlay_VGM(mustitle);
// set screen width
VDP_setScreenWidth320();
VDP_setPaletteColors(0, palette_black, 64);
//Initialize the joy handler for the title screen
JOY_init();
//draw the background
VDP_drawImageEx(VDP_PLAN_B, &bgcity, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, tileIndex), 0, 0, TRUE, TRUE);
tileIndex += bgcity.tileset->numTile;
//draw the logo
VDP_drawImageEx(VDP_PLAN_A, &gamelogo, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, tileIndex), 7, 4, TRUE, TRUE);
tileIndex += gamelogo.tileset->numTile;
//Initialize sprite engine
SPR_init(256);
//Draw the title screen text
VDP_drawText("* Press START to play! *", 8, 12);
VDP_drawText("By Steve Gilissen (KUROTO)", 7, 26);
VDP_drawText("Music: Chippin' by DEMICKXII", 6, 27);
camposx = FIX16(0);
camposy = FIX16(0);
posx = FIX16(250);
posy = FIX16(42); //was: MAX_POSY;
movx = FIX16(0);
movy = FIX16(0);
xorder = 0;
yorder = 0;
// initialize the sprite (Flappy! :D)
SPR_initSprite(&sprites[0], &flappy_sprite, fix16ToInt(posx), fix16ToInt(posy), TILE_ATTR(PAL0, TRUE, FALSE, FALSE));
SPR_update(&sprites[0], 1);
// prepare the palette
memcpy(&palette[0], bgcity.palette->data, 16*2);
memcpy(&palette[16], gamelogo.palette->data, 16*2);
memcpy(&palette[32], flappy_sprite.palette->data, 16*2);
JOY_setEventHandler(joyEvent);
while(TRUE)
{
switch(gamestate)
{
case INTRO:
//updateIntroAnim();
//Clear the A Plane to remove the logo and title screen text
VDP_clearPlan(APLAN, FALSE);
//move Flappy to the left of the screen to start in the right position
for (flappyTitlePosition; flappyTitlePosition>0; flappyTitlePosition--)
{
SPR_setPosition(&sprites[0], flappyTitlePosition, fix16ToInt(posy));
SPR_update(&sprites, 2);
VDP_waitVSync();
}
//VDP_waitVSync();
//stop playing music
//SND_stopPlay_VGM();
SPR_initSprite(&sprites[1], &flappy_sprite2, 140, 80, TILE_ATTR(PAL0, TRUE, FALSE, FALSE));
SPR_setAnim(&sprites[1], ANIM_INSTR);
SPR_update(&sprites, 2);
VDP_waitVSync();
gamestate = INSTRUCTIONS;
break;
case GAME:
//updateGameAnim();
SPR_setPosition(&sprites[1], -100, -100);
VDP_drawText("Score:", 0, 0);
//SND_stopPlay_VGM();
//update sprites
//disableInts();
SPR_update(&sprites, 2);
//enableInts();
VDP_waitVSync();
JOY_setEventHandler(gameJoyEvent);
break;
case INSTRUCTIONS:
//updateGameAnim();
JOY_setEventHandler(introJoyEvent);
//update sprites
//disableInts();
SPR_update(&sprites, 2);
//enableInts();
VDP_waitVSync();
break;
case TITLE:
disableInts();
SPR_update(&sprites, 1);
enableInts();
VDP_waitVSync();
break;
}
}
return 0;
}
static void disableInts()
{
if (!SYS_isInInterrupt()) SYS_disableInts();
}
static void enableInts()
{
if (!SYS_isInInterrupt()) SYS_enableInts();
}
static void introJoyEvent(u16 joy, u16 changed, u16 state)
{
// START button state changed
if (changed & BUTTON_START)
{
}
if (changed & state & (BUTTON_A | BUTTON_B | BUTTON_C))
{
gamestate = GAME;
}
}
static void gameJoyEvent(u16 joy, u16 changed, u16 state)
{
// START button state changed
if (changed & BUTTON_START)
{
}
if (changed & state & (BUTTON_A | BUTTON_B | BUTTON_C))
{
SND_playSfx_VGM((u32) sndFlap, sizeof(sndFlap));
}
}
static void joyEvent(u16 joy, u16 changed, u16 state)
{
// START button state changed
if (changed & BUTTON_START)
{
gamestate = INTRO;
}
if (changed & state & (BUTTON_A | BUTTON_B | BUTTON_C))
{
}
}