Multiple sprites?
Posted: Wed Apr 02, 2014 11:21 pm
So I'm trying to get multiple sprites going for a pong clone but I'm not sure I've figured it out. I'm cobbling this together from multiple code sources. Based on what I've read this SHOULD work, but upon compiling I get an invalid initializer error for the sprites after the SpriteList. Can someone give me a hand?
All it should do is draw a "fish" background and then draw two separate "sprPaddle" sprites next to each other, for testing (identical for now, will use swapped palettes later)
All it should do is draw a "fish" background and then draw two separate "sprPaddle" sprites next to each other, for testing (identical for now, will use swapped palettes later)
Code: Select all
/* Required files from SGDK */
#include <genesis.h>
/* Load resources files (generated from .res files in /res/) */
#include <tiles.h>
#include <sprites.h>
Sprite SpritesList[MAX_SPRITE];
Sprite objPaddle = &SpritesList[0];
Sprite objPaddle2 = &SpritesList[1];
redPaddle_X = FIX16(8);
redPaddle_Y = FIX16(16);
bluePaddle_X = FIX16(24);
bluePaddle_Y = FIX16(16);
int main()
{
void GameField_init();
/* This is the initialization block. Everything before the while loop will only happen once when the game boots up. */
SPR_init(256);
/* Draw fish image to PLANE B */
u16 tileIndex = TILE_USERINDEX;
VDP_drawImageEx(VDP_PLAN_B, &fish, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, tileIndex), 0, 0, TRUE, TRUE);
tileIndex += fish.tileset->numTile;
/* Print some text (text is plane A so this will be over the fish) */
VDP_drawText("This is a status line, I think", 0, 0);
/*Initialization code for GAME FIELD */
GameField_init();
while(1)
{
SPR_update(&SpritesList, 2);
VDP_updateSprites();
VDP_waitVSync();
}
return 0;
}
void GameField_init()
{
/* Paddle sprite init! */
SPR_initSprite(&objPaddle, &sprPaddle, fix16ToInt(redPaddle_X), fix16ToInt(redPaddle_Y), TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
/* Copy the palette! */
VDP_setPalette(PAL2, sprPaddle.palette->data);
SPR_initSprite(&objPaddle2, &sprPaddle, fix16ToInt(bluePaddle_X), fix16ToInt(bluePaddle_Y), TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
}