Difference between revisions of "Modules/game pawn"

From MSX Game Library

< Modules

Line 15: Line 15:
  
 
Simple color sprite (1 layer):
 
Simple color sprite (1 layer):
<pre>
+
<syntaxhighlight lang="c">
 
const Game_Sprite g_SpriteLayers[] =
 
const Game_Sprite g_SpriteLayers[] =
 
{
 
{
 
{ 0, 0, 0,  COLOR_WHITE, 0 }, // Sprite position offset: 0,0. Pattern offset: 0. Color: White. No special flag
 
{ 0, 0, 0,  COLOR_WHITE, 0 }, // Sprite position offset: 0,0. Pattern offset: 0. Color: White. No special flag
 
};
 
};
</pre>
+
</syntaxhighlight>
  
 
Two color sprite (2 layer):
 
Two color sprite (2 layer):
<pre>
+
<syntaxhighlight lang="c">
 
const Game_Sprite g_SpriteLayers[] =
 
const Game_Sprite g_SpriteLayers[] =
 
{
 
{
Line 29: Line 29:
 
{ 0, -8, 4,  COLOR_GRAY, 0 }, // Sprite position offset: 0,-8. Pattern offset: 4. Color: Gray. No special flag
 
{ 0, -8, 4,  COLOR_GRAY, 0 }, // Sprite position offset: 0,-8. Pattern offset: 4. Color: Gray. No special flag
 
};
 
};
</pre>
+
</syntaxhighlight>
  
 
3 layers sprite with auto-switch (to generate more color by flickering)
 
3 layers sprite with auto-switch (to generate more color by flickering)
<pre>
+
<syntaxhighlight lang="c">
// Pawn sprite layers
 
 
const Game_Sprite g_SpriteLayers[] =
 
const Game_Sprite g_SpriteLayers[] =
 
{
 
{
Line 41: Line 40:
 
{ 0, 0, 8,  COLOR_LIGHT_RED, 0 },
 
{ 0, 0, 8,  COLOR_LIGHT_RED, 0 },
 
};
 
};
</pre>
+
</syntaxhighlight>

Revision as of 13:27, 10 February 2022

The game_pawn module handle character animation, rendering, collision and physics.

This module offer several structures the user can use to configure a pawn (a player, an enemy or event an item) for rendering (multi-layers and flip/flap) and movement.

Dependencies

Settings

GAMEPAWN_USE_PHYSICS: Include collision and physics handling functions.

Examples

Define pawn's sprites

Simple color sprite (1 layer):

const Game_Sprite g_SpriteLayers[] =
{
	{ 0, 0, 0,  COLOR_WHITE, 0 }, // Sprite position offset: 0,0. Pattern offset: 0. Color: White. No special flag
};
‎

Two color sprite (2 layer):

const Game_Sprite g_SpriteLayers[] =
{
	{ 0, 0, 0,  COLOR_WHITE, 0 }, // Sprite position offset: 0,0. Pattern offset: 0. Color: White. No special flag
	{ 0, -8, 4,  COLOR_GRAY, 0 }, // Sprite position offset: 0,-8. Pattern offset: 4. Color: Gray. No special flag
};
‎

3 layers sprite with auto-switch (to generate more color by flickering)

const Game_Sprite g_SpriteLayers[] =
{
	{ 0, 0, 0,  COLOR_BLACK, PAWN_SPRITE_EVEN }, // Sprite used only on 'even' frame number
	{ 0, 0, 12, COLOR_BLACK, PAWN_SPRITE_ODD }, // Sprite used only on 'odd' frame number
	{ 0, 0, 4,  COLOR_WHITE, 0 },
	{ 0, 0, 8,  COLOR_LIGHT_RED, 0 },
};
‎