mirror of
https://gitlab.com/drummyfish/anarch.git
synced 2024-11-22 08:52:17 -05:00
Format
This commit is contained in:
parent
350ecf5c91
commit
f0a538e557
12
levels.h
12
levels.h
@ -162,8 +162,11 @@ static inline SFG_TileDefinition SFG_getMapTile
|
|||||||
return level->tileDictionary[tile & 0x3f];
|
return level->tileDictionary[tile & 0x3f];
|
||||||
}
|
}
|
||||||
|
|
||||||
SFG_PROGRAM_MEMORY SFG_Level SFG_level0 =
|
#define SFG_NUMBER_OF_LEVELS 2
|
||||||
|
|
||||||
|
SFG_PROGRAM_MEMORY SFG_Level SFG_levels[SFG_NUMBER_OF_LEVELS] =
|
||||||
{
|
{
|
||||||
|
{ // level 0
|
||||||
{ // mapArray
|
{ // mapArray
|
||||||
#define o 0
|
#define o 0
|
||||||
#define AA (0x09 | SFG_TILE_PROPERTY_ELEVATOR)
|
#define AA (0x09 | SFG_TILE_PROPERTY_ELEVATOR)
|
||||||
@ -337,10 +340,8 @@ SFG_PROGRAM_MEMORY SFG_Level SFG_level0 =
|
|||||||
{SFG_LEVEL_ELEMENT_NONE, {0, 0}}, {SFG_LEVEL_ELEMENT_NONE, {0, 0}},
|
{SFG_LEVEL_ELEMENT_NONE, {0, 0}}, {SFG_LEVEL_ELEMENT_NONE, {0, 0}},
|
||||||
{SFG_LEVEL_ELEMENT_NONE, {0, 0}}, {SFG_LEVEL_ELEMENT_NONE, {0, 0}}
|
{SFG_LEVEL_ELEMENT_NONE, {0, 0}}, {SFG_LEVEL_ELEMENT_NONE, {0, 0}}
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
{ // level 1
|
||||||
SFG_PROGRAM_MEMORY SFG_Level SFG_level1 =
|
|
||||||
{
|
|
||||||
{ // mapArray
|
{ // mapArray
|
||||||
#define o 0
|
#define o 0
|
||||||
#define AA (0x09 | SFG_TILE_PROPERTY_ELEVATOR)
|
#define AA (0x09 | SFG_TILE_PROPERTY_ELEVATOR)
|
||||||
@ -514,6 +515,7 @@ SFG_PROGRAM_MEMORY SFG_Level SFG_level1 =
|
|||||||
{SFG_LEVEL_ELEMENT_NONE, {0, 0}}, {SFG_LEVEL_ELEMENT_NONE, {0, 0}},
|
{SFG_LEVEL_ELEMENT_NONE, {0, 0}}, {SFG_LEVEL_ELEMENT_NONE, {0, 0}},
|
||||||
{SFG_LEVEL_ELEMENT_NONE, {0, 0}}, {SFG_LEVEL_ELEMENT_NONE, {0, 0}}
|
{SFG_LEVEL_ELEMENT_NONE, {0, 0}}, {SFG_LEVEL_ELEMENT_NONE, {0, 0}}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
85
main.c
85
main.c
@ -566,7 +566,8 @@ static inline void SFG_setGamePixel(uint16_t x, uint16_t y, uint8_t colorIndex)
|
|||||||
|
|
||||||
void SFG_recompurePLayerDirection()
|
void SFG_recompurePLayerDirection()
|
||||||
{
|
{
|
||||||
SFG_player.camera.direction = RCL_wrap(SFG_player.camera.direction,RCL_UNITS_PER_SQUARE);
|
SFG_player.camera.direction =
|
||||||
|
RCL_wrap(SFG_player.camera.direction,RCL_UNITS_PER_SQUARE);
|
||||||
|
|
||||||
SFG_player.direction = RCL_angleToDirection(SFG_player.camera.direction);
|
SFG_player.direction = RCL_angleToDirection(SFG_player.camera.direction);
|
||||||
|
|
||||||
@ -923,7 +924,9 @@ RCL_Unit SFG_texturesAt(int16_t x, int16_t y)
|
|||||||
{
|
{
|
||||||
uint8_t p;
|
uint8_t p;
|
||||||
|
|
||||||
SFG_TileDefinition tile = SFG_getMapTile(SFG_currentLevel.levelPointer,x,y,&p);
|
SFG_TileDefinition tile =
|
||||||
|
SFG_getMapTile(SFG_currentLevel.levelPointer,x,y,&p);
|
||||||
|
|
||||||
return
|
return
|
||||||
SFG_TILE_FLOOR_TEXTURE(tile) | (SFG_TILE_CEILING_TEXTURE(tile) << 3) | p;
|
SFG_TILE_FLOOR_TEXTURE(tile) | (SFG_TILE_CEILING_TEXTURE(tile) << 3) | p;
|
||||||
// ^ store both textures (floor and ceiling) and properties in one number
|
// ^ store both textures (floor and ceiling) and properties in one number
|
||||||
@ -1131,7 +1134,8 @@ void SFG_setAndInitLevel(const SFG_Level *level)
|
|||||||
&(SFG_currentLevel.monsterRecords[SFG_currentLevel.monsterRecordCount]);
|
&(SFG_currentLevel.monsterRecords[SFG_currentLevel.monsterRecordCount]);
|
||||||
|
|
||||||
monster->stateType = e->type | SFG_MONSTER_STATE_INACTIVE;
|
monster->stateType = e->type | SFG_MONSTER_STATE_INACTIVE;
|
||||||
monster->health = SFG_GET_MONSTER_MAX_HEALTH(SFG_MONSTER_TYPE_TO_INDEX(e->type));
|
monster->health =
|
||||||
|
SFG_GET_MONSTER_MAX_HEALTH(SFG_MONSTER_TYPE_TO_INDEX(e->type));
|
||||||
|
|
||||||
monster->coords[0] = e->coords[0] * 4 + 2;
|
monster->coords[0] = e->coords[0] * 4 + 2;
|
||||||
monster->coords[1] = e->coords[1] * 4 + 2;
|
monster->coords[1] = e->coords[1] * 4 + 2;
|
||||||
@ -1361,7 +1365,8 @@ uint8_t SFG_pushAway(
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t SFG_pushPlayerAway(RCL_Unit centerX, RCL_Unit centerY, RCL_Unit distance)
|
uint8_t SFG_pushPlayerAway(
|
||||||
|
RCL_Unit centerX, RCL_Unit centerY, RCL_Unit distance)
|
||||||
{
|
{
|
||||||
RCL_Unit p[3];
|
RCL_Unit p[3];
|
||||||
|
|
||||||
@ -1750,8 +1755,10 @@ void SFG_monsterPerformAI(SFG_MonsterRecord *monster)
|
|||||||
SFG_TileDefinition tile =
|
SFG_TileDefinition tile =
|
||||||
SFG_getMapTile(SFG_currentLevel.levelPointer,mX,mY,&properties);
|
SFG_getMapTile(SFG_currentLevel.levelPointer,mX,mY,&properties);
|
||||||
|
|
||||||
SFG_createExplosion(mX * RCL_UNITS_PER_SQUARE ,mY * RCL_UNITS_PER_SQUARE,
|
SFG_createExplosion(mX * RCL_UNITS_PER_SQUARE,
|
||||||
SFG_TILE_FLOOR_HEIGHT(tile) * SFG_WALL_HEIGHT_STEP + SFG_WALL_HEIGHT_STEP);
|
mY * RCL_UNITS_PER_SQUARE,
|
||||||
|
SFG_TILE_FLOOR_HEIGHT(tile) * SFG_WALL_HEIGHT_STEP +
|
||||||
|
SFG_WALL_HEIGHT_STEP);
|
||||||
|
|
||||||
monster->health = 0;
|
monster->health = 0;
|
||||||
}
|
}
|
||||||
@ -2126,7 +2133,8 @@ void SFG_gameStepPlaying()
|
|||||||
{
|
{
|
||||||
if (SFG_keyJustPressed(SFG_KEY_LEFT) || SFG_keyJustPressed(SFG_KEY_A))
|
if (SFG_keyJustPressed(SFG_KEY_LEFT) || SFG_keyJustPressed(SFG_KEY_A))
|
||||||
SFG_playerRotateWeapon(0);
|
SFG_playerRotateWeapon(0);
|
||||||
else if (SFG_keyJustPressed(SFG_KEY_RIGHT) || SFG_keyJustPressed(SFG_KEY_B))
|
else if (SFG_keyJustPressed(SFG_KEY_RIGHT) ||
|
||||||
|
SFG_keyJustPressed(SFG_KEY_B))
|
||||||
SFG_playerRotateWeapon(1);
|
SFG_playerRotateWeapon(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2147,9 +2155,11 @@ void SFG_gameStepPlaying()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (SFG_keyJustPressed(SFG_KEY_LEFT) | SFG_keyJustPressed(SFG_KEY_A))
|
if (SFG_keyJustPressed(SFG_KEY_LEFT) ||
|
||||||
|
SFG_keyJustPressed(SFG_KEY_A))
|
||||||
SFG_playerRotateWeapon(0);
|
SFG_playerRotateWeapon(0);
|
||||||
else if (SFG_keyJustPressed(SFG_KEY_RIGHT) | SFG_keyJustPressed(SFG_KEY_B))
|
else if (SFG_keyJustPressed(SFG_KEY_RIGHT) ||
|
||||||
|
SFG_keyJustPressed(SFG_KEY_B))
|
||||||
SFG_playerRotateWeapon(1);
|
SFG_playerRotateWeapon(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2811,7 +2821,7 @@ void SFG_gameStepMenu()
|
|||||||
switch (item)
|
switch (item)
|
||||||
{
|
{
|
||||||
case SFG_MENU_ITEM_PLAY:
|
case SFG_MENU_ITEM_PLAY:
|
||||||
SFG_setAndInitLevel(&SFG_level0);
|
SFG_setAndInitLevel(&SFG_levels[SFG_game.selectedLevel]);
|
||||||
SFG_game.state = SFG_GAME_STATE_PLAYING;
|
SFG_game.state = SFG_GAME_STATE_PLAYING;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -2821,7 +2831,8 @@ void SFG_gameStepMenu()
|
|||||||
}
|
}
|
||||||
else if (item == SFG_MENU_ITEM_PLAY)
|
else if (item == SFG_MENU_ITEM_PLAY)
|
||||||
{
|
{
|
||||||
if (SFG_keyRegisters(SFG_KEY_RIGHT) && SFG_game.selectedLevel < 9)
|
if (SFG_keyRegisters(SFG_KEY_RIGHT) &&
|
||||||
|
(SFG_game.selectedLevel < SFG_NUMBER_OF_LEVELS - 1))
|
||||||
{
|
{
|
||||||
SFG_game.selectedLevel++;
|
SFG_game.selectedLevel++;
|
||||||
SFG_playSoundSafe(3,64);
|
SFG_playSoundSafe(3,64);
|
||||||
@ -3087,7 +3098,8 @@ void SFG_drawWeapon(int16_t bobOffset)
|
|||||||
uint32_t shotAnimationFrame =
|
uint32_t shotAnimationFrame =
|
||||||
SFG_game.frame - SFG_player.weaponCooldownStartFrame;
|
SFG_game.frame - SFG_player.weaponCooldownStartFrame;
|
||||||
|
|
||||||
uint32_t animationLength = SFG_GET_WEAPON_FIRE_COOLDOWN_FRAMES(SFG_player.weapon);
|
uint32_t animationLength =
|
||||||
|
SFG_GET_WEAPON_FIRE_COOLDOWN_FRAMES(SFG_player.weapon);
|
||||||
|
|
||||||
bobOffset -= SFG_HUD_BAR_HEIGHT;
|
bobOffset -= SFG_HUD_BAR_HEIGHT;
|
||||||
|
|
||||||
@ -3112,7 +3124,8 @@ void SFG_drawWeapon(int16_t bobOffset)
|
|||||||
shotAnimationFrame < animationLength / 2)
|
shotAnimationFrame < animationLength / 2)
|
||||||
SFG_blitImage(SFG_effectSprites[0],
|
SFG_blitImage(SFG_effectSprites[0],
|
||||||
SFG_WEAPON_IMAGE_POSITION_X,
|
SFG_WEAPON_IMAGE_POSITION_X,
|
||||||
SFG_WEAPON_IMAGE_POSITION_Y - (SFG_TEXTURE_SIZE / 3) * SFG_WEAPON_IMAGE_SCALE + bobOffset,
|
SFG_WEAPON_IMAGE_POSITION_Y -
|
||||||
|
(SFG_TEXTURE_SIZE / 3) * SFG_WEAPON_IMAGE_SCALE + bobOffset,
|
||||||
SFG_WEAPON_IMAGE_SCALE);
|
SFG_WEAPON_IMAGE_SCALE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3150,10 +3163,11 @@ void SFG_drawMenu()
|
|||||||
SFG_getTexel(SFG_backgroundImages[0],((x + scroll) / BACKGROUND_SCALE)
|
SFG_getTexel(SFG_backgroundImages[0],((x + scroll) / BACKGROUND_SCALE)
|
||||||
% SFG_TEXTURE_SIZE,y / BACKGROUND_SCALE));
|
% SFG_TEXTURE_SIZE,y / BACKGROUND_SCALE));
|
||||||
|
|
||||||
uint16_t y = CHAR_SIZE;
|
uint16_t y = CHAR_SIZE;
|
||||||
|
|
||||||
SFG_blitImage(SFG_logoImage,
|
SFG_blitImage(SFG_logoImage,
|
||||||
SFG_GAME_RESOLUTION_X / 2 - 16 * SFG_FONT_SIZE_MEDIUM,y,SFG_FONT_SIZE_MEDIUM);
|
SFG_GAME_RESOLUTION_X / 2 - 16 * SFG_FONT_SIZE_MEDIUM,y,
|
||||||
|
SFG_FONT_SIZE_MEDIUM);
|
||||||
|
|
||||||
y += 32 * SFG_FONT_SIZE_MEDIUM + CHAR_SIZE;
|
y += 32 * SFG_FONT_SIZE_MEDIUM + CHAR_SIZE;
|
||||||
|
|
||||||
@ -3161,55 +3175,46 @@ SFG_blitImage(SFG_logoImage,
|
|||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
uint8_t item = SFG_getMenuItem(i);
|
uint8_t item = SFG_getMenuItem(i);
|
||||||
|
|
||||||
if (item == SFG_MENU_ITEM_NONE)
|
if (item == SFG_MENU_ITEM_NONE)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
const char *text = SFG_menuItemTexts[item];
|
const char *text = SFG_menuItemTexts[item];
|
||||||
|
|
||||||
uint8_t textLen = 0;
|
uint8_t textLen = 0;
|
||||||
|
|
||||||
while (text[textLen] != 0)
|
while (text[textLen] != 0)
|
||||||
textLen++;
|
textLen++;
|
||||||
|
|
||||||
|
|
||||||
uint16_t drawX = (SFG_GAME_RESOLUTION_X - textLen * CHAR_SIZE) / 2;
|
uint16_t drawX = (SFG_GAME_RESOLUTION_X - textLen * CHAR_SIZE) / 2;
|
||||||
|
uint8_t textColor = 7;
|
||||||
|
|
||||||
|
if (i != SFG_game.selectedMenuItem)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
uint8_t textColor = 7;
|
|
||||||
|
|
||||||
if (i != SFG_game.selectedMenuItem)
|
|
||||||
{
|
|
||||||
textColor = 23;
|
textColor = 23;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
for (uint16_t l = y - SFG_FONT_SIZE_MEDIUM; l < y + CHAR_SIZE; ++l)
|
for (uint16_t l = y - SFG_FONT_SIZE_MEDIUM; l < y + CHAR_SIZE; ++l)
|
||||||
for (uint16_t k = SELECTION_START_X; k < SFG_GAME_RESOLUTION_X - SELECTION_START_X; ++k)
|
for (uint16_t k = SELECTION_START_X;
|
||||||
|
k < SFG_GAME_RESOLUTION_X - SELECTION_START_X; ++k)
|
||||||
SFG_setGamePixel(k,l,2);
|
SFG_setGamePixel(k,l,2);
|
||||||
}
|
}
|
||||||
|
|
||||||
SFG_drawText(text,drawX,y,SFG_FONT_SIZE_MEDIUM,textColor);
|
SFG_drawText(text,drawX,y,SFG_FONT_SIZE_MEDIUM,textColor);
|
||||||
|
|
||||||
if (item == SFG_MENU_ITEM_PLAY)
|
if (item == SFG_MENU_ITEM_PLAY)
|
||||||
SFG_drawNumber((SFG_game.selectedLevel + 1),
|
SFG_drawNumber((SFG_game.selectedLevel + 1),
|
||||||
drawX + CHAR_SIZE * (textLen + 1) ,y,SFG_FONT_SIZE_MEDIUM,93);
|
drawX + CHAR_SIZE * (textLen + 1) ,y,SFG_FONT_SIZE_MEDIUM,93);
|
||||||
|
|
||||||
|
|
||||||
y += CHAR_SIZE + SFG_FONT_SIZE_MEDIUM;
|
y += CHAR_SIZE + SFG_FONT_SIZE_MEDIUM;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SFG_drawText("0.7 CC0",SFG_HUD_MARGIN,SFG_GAME_RESOLUTION_Y - SFG_HUD_MARGIN
|
||||||
|
- SFG_FONT_SIZE_SMALL * SFG_FONT_CHARACTER_SIZE,SFG_FONT_SIZE_SMALL,4);
|
||||||
SFG_drawText("0.7 CC0",SFG_HUD_MARGIN,SFG_GAME_RESOLUTION_Y - SFG_HUD_MARGIN
|
|
||||||
- SFG_FONT_SIZE_SMALL * SFG_FONT_CHARACTER_SIZE,
|
|
||||||
SFG_FONT_SIZE_SMALL,4);
|
|
||||||
|
|
||||||
#undef CHAR_SIZE
|
#undef CHAR_SIZE
|
||||||
#undef MAX_ITEMS
|
#undef MAX_ITEMS
|
||||||
|
Loading…
Reference in New Issue
Block a user