mirror of
https://github.com/CTurt/dsgmLib.git
synced 2025-06-18 22:55:33 -04:00
219 lines
3.8 KiB
C
219 lines
3.8 KiB
C
#include "DSGM.h"
|
|
|
|
#include "DSGM_projectHelper.h"
|
|
|
|
// User variables / declarations
|
|
u8 direction = 0;
|
|
|
|
// Resources
|
|
DSGM_Sound DSGM_Sounds[DSGM_SOUND_COUNT] = {
|
|
};
|
|
|
|
DSGM_Background DSGM_Backgrounds[DSGM_BACKGROUND_COUNT] = {
|
|
};
|
|
|
|
DSGM_Palette DSGM_Palettes[DSGM_PALETTE_COUNT] = {
|
|
DSGM_FORM_NITRO_PALETTE(DSGMPal0),
|
|
};
|
|
|
|
DSGM_Sprite DSGM_Sprites[DSGM_SPRITE_COUNT] = {
|
|
DSGM_FORM_NITRO_SPRITE(taptapman, DSGMPal0, SpriteSize_32x32, 9),
|
|
DSGM_FORM_NITRO_SPRITE(ball, DSGMPal0, SpriteSize_32x32, 1),
|
|
};
|
|
|
|
DSGM_Object DSGM_Objects[DSGM_OBJECT_COUNT] = {
|
|
// player
|
|
{
|
|
&DSGM_Sprites[taptapman],
|
|
DSGM_NO_EVENT,
|
|
player_loop,
|
|
DSGM_NO_EVENT,
|
|
DSGM_NO_EVENT,
|
|
|
|
NULL, 0
|
|
},
|
|
// ball
|
|
{
|
|
&DSGM_Sprites[ballSprite],
|
|
DSGM_NO_EVENT,
|
|
DSGM_NO_EVENT,
|
|
DSGM_NO_EVENT,
|
|
DSGM_NO_EVENT,
|
|
|
|
NULL, 0
|
|
},
|
|
};
|
|
|
|
DSGM_Room DSGM_Rooms[DSGM_ROOM_COUNT] = {
|
|
// Room_1
|
|
{
|
|
// Backgrounds
|
|
{
|
|
// Bottom screen
|
|
{
|
|
// Layer 0
|
|
{
|
|
DSGM_TEXT_BACKGROUND, // Background
|
|
DSGM_BOTTOM, // Screen
|
|
0, // Layer
|
|
false, // Attached to view system
|
|
0, 0, 0
|
|
},
|
|
|
|
// Layer 1
|
|
{
|
|
DSGM_NO_BACKGROUND, // Background
|
|
DSGM_BOTTOM, // Screen
|
|
1, // Layer
|
|
true, // Attached to view system
|
|
0, 0, 0
|
|
},
|
|
|
|
// Layer 2
|
|
{
|
|
DSGM_NO_BACKGROUND, // Background
|
|
DSGM_BOTTOM, // Screen
|
|
2, // Layer
|
|
true, // Attached to view system
|
|
0, 0, 0
|
|
},
|
|
|
|
// Layer 3
|
|
{
|
|
DSGM_NO_BACKGROUND, // Background
|
|
DSGM_BOTTOM, // Screen
|
|
3, // Layer
|
|
true, // Attached to view system
|
|
0, 0, 0
|
|
},
|
|
},
|
|
|
|
// Top screen
|
|
{
|
|
// Layer 0
|
|
{
|
|
DSGM_TEXT_BACKGROUND, // Background
|
|
DSGM_TOP, // Screen
|
|
0, // Layer
|
|
false, // Attached to view system
|
|
0, 0, 0
|
|
},
|
|
|
|
// Layer 1
|
|
{
|
|
DSGM_NO_BACKGROUND, // Background
|
|
DSGM_TOP, // Screen
|
|
1, // Layer
|
|
true, // Attached to view system
|
|
0, 0, 0
|
|
},
|
|
|
|
// Layer 2
|
|
{
|
|
DSGM_NO_BACKGROUND, // Background
|
|
DSGM_TOP, // Screen
|
|
2, // Layer
|
|
true, // Attached to view system
|
|
0, 0, 0
|
|
},
|
|
|
|
// Layer 3
|
|
{
|
|
DSGM_NO_BACKGROUND, // Background
|
|
DSGM_TOP, // Screen
|
|
3, // Layer
|
|
true, // Attached to view system
|
|
0, 0, 0
|
|
},
|
|
}
|
|
},
|
|
|
|
// Initial views
|
|
{
|
|
// Bottom screen
|
|
{
|
|
0, 0
|
|
},
|
|
|
|
// Top screen
|
|
{
|
|
0, 0
|
|
}
|
|
},
|
|
|
|
// Views
|
|
{
|
|
// Bottom screen
|
|
{
|
|
0, 0
|
|
},
|
|
|
|
// Top screen
|
|
{
|
|
0, 0
|
|
}
|
|
},
|
|
|
|
// Object groups are dynamic, so must be set up at run time, see DSGM_SetupRooms.
|
|
{
|
|
NULL,
|
|
NULL
|
|
},
|
|
{
|
|
0,
|
|
0
|
|
}
|
|
},
|
|
};
|
|
|
|
int DSGM_currentRoom = Room_1;
|
|
|
|
void DSGM_SetupRooms(int room) {
|
|
if(room != DSGM_ALL_ROOMS) {
|
|
switch(room) {
|
|
case Room_1: goto Room_1; break;
|
|
}
|
|
}
|
|
|
|
Room_1:
|
|
DSGM_Debug("Room_1 reset\n");
|
|
DSGM_LeaveRoom(&DSGM_Rooms[Room_1]);
|
|
|
|
DSGM_SetupViews(&DSGM_Rooms[Room_1]);
|
|
|
|
DSGM_SetupObjectGroups(&DSGM_Rooms[Room_1], DSGM_TOP, 0);
|
|
|
|
DSGM_SetupObjectGroups(&DSGM_Rooms[Room_1], DSGM_BOTTOM, 2);
|
|
|
|
DSGM_SetupObjectInstances(&DSGM_Rooms[Room_1].objectGroups[DSGM_BOTTOM][0], &DSGM_Objects[player], DSGM_BOTTOM, 1,
|
|
64, 64
|
|
);
|
|
|
|
DSGM_SetupObjectInstances(&DSGM_Rooms[Room_1].objectGroups[DSGM_BOTTOM][1], &DSGM_Objects[ball], DSGM_BOTTOM, 2,
|
|
120, 80,
|
|
20, 50
|
|
);
|
|
|
|
DSGM_AddCollisionEvent(&DSGM_Objects[player], &DSGM_Objects[ball], player_collide_ball);
|
|
|
|
if(room != DSGM_ALL_ROOMS) return;
|
|
}
|
|
|
|
void player_loop(DSGM_ObjectInstance *me) {
|
|
DSGM_ClearText(DSGM_BOTTOM);
|
|
|
|
if(direction == 0) {
|
|
me->x++;
|
|
}
|
|
else {
|
|
me->x--;
|
|
}
|
|
|
|
if(me->x == 223 || me->x == 0) direction = !direction;
|
|
}
|
|
|
|
void player_collide_ball(DSGM_ObjectInstance *me, DSGM_ObjectInstance *collider) {
|
|
DSGM_DrawText(DSGM_BOTTOM, 1, 1, "Collision!");
|
|
collider->y += 1;
|
|
}
|