mirror of
https://gitlab.com/drummyfish/anarch.git
synced 2024-12-21 23:08:49 -05:00
Add sprite sizes
This commit is contained in:
parent
50a1a74b7e
commit
ecedf3ba44
12
constants.h
12
constants.h
@ -316,13 +316,13 @@
|
||||
*/
|
||||
uint16_t SFG_monsterAttributeTable[SFG_MONSTERS_TOTAL] =
|
||||
{
|
||||
/* spider */ SFG_MONSTER_ATTRIBUTE(SFG_MONSTER_ATTACK_FIREBALL,40,120,3),
|
||||
/* spider */ SFG_MONSTER_ATTRIBUTE(SFG_MONSTER_ATTACK_FIREBALL,40,120,2),
|
||||
/* destr. */ SFG_MONSTER_ATTRIBUTE(SFG_MONSTER_ATTACK_FIREBALL_BULLET,50,130,3),
|
||||
/* warrior */ SFG_MONSTER_ATTRIBUTE(SFG_MONSTER_ATTACK_MELEE,255,70,2),
|
||||
/* plasma */ SFG_MONSTER_ATTRIBUTE(SFG_MONSTER_ATTACK_PLASMA,55,92,2),
|
||||
/* ender */ SFG_MONSTER_ATTRIBUTE(SFG_MONSTER_ATTACK_FIREBALL_BULLET,75,255,4),
|
||||
/* turret */ SFG_MONSTER_ATTRIBUTE(SFG_MONSTER_ATTACK_BULLET,32,50,2),
|
||||
/* explod. */ SFG_MONSTER_ATTRIBUTE(SFG_MONSTER_ATTACK_EXPLODE,255,60,2)
|
||||
/* warrior */ SFG_MONSTER_ATTRIBUTE(SFG_MONSTER_ATTACK_MELEE,255,70,1),
|
||||
/* plasma */ SFG_MONSTER_ATTRIBUTE(SFG_MONSTER_ATTACK_PLASMA,55,92,1),
|
||||
/* ender */ SFG_MONSTER_ATTRIBUTE(SFG_MONSTER_ATTACK_FIREBALL_BULLET,75,255,3),
|
||||
/* turret */ SFG_MONSTER_ATTRIBUTE(SFG_MONSTER_ATTACK_BULLET,32,50,0),
|
||||
/* explod. */ SFG_MONSTER_ATTRIBUTE(SFG_MONSTER_ATTACK_EXPLODE,255,60,1)
|
||||
};
|
||||
|
||||
// ----------------------------
|
||||
|
47
main.c
47
main.c
@ -53,21 +53,29 @@
|
||||
#define SFG_PROGRAM_MEMORY static const /**< Can be redefined to platform's
|
||||
specifier of program meory. */
|
||||
|
||||
/** Return 1 (0) if given key is pressed (not pressed). At least the mandatory
|
||||
/**
|
||||
Returns 1 (0) if given key is pressed (not pressed). At least the mandatory
|
||||
keys have to be implemented, the optional keys don't have to ever return 1.
|
||||
See the key contant definitions to see which ones are mandatory. */
|
||||
See the key contant definitions to see which ones are mandatory.
|
||||
*/
|
||||
int8_t SFG_keyPressed(uint8_t key);
|
||||
|
||||
/** Return time in ms sice program start. */
|
||||
/**
|
||||
Returns time in ms sice program start.
|
||||
*/
|
||||
uint32_t SFG_getTimeMs();
|
||||
|
||||
/** Sleep (yield CPU) for specified amount of ms. This is used to relieve CPU
|
||||
/**
|
||||
Sleep (yield CPU) for specified amount of ms. This is used to relieve CPU
|
||||
usage. If your platform doesn't need this or handles it in other way, this
|
||||
function can do nothing. */
|
||||
function can do nothing.
|
||||
*/
|
||||
void SFG_sleepMs(uint16_t timeMs);
|
||||
|
||||
/** Set specified screen pixel. The function doesn't have to check whether
|
||||
the coordinates are within screen. */
|
||||
/**
|
||||
Set specified screen pixel. The function doesn't have to check whether
|
||||
the coordinates are within screen.
|
||||
*/
|
||||
static inline void SFG_setPixel(uint16_t x, uint16_t y, uint8_t colorIndex);
|
||||
|
||||
/* ========================================================================= */
|
||||
@ -115,6 +123,12 @@ typedef struct
|
||||
*/
|
||||
} SFG_DoorRecord;
|
||||
|
||||
#define SFG_SPRITE_SIZE(size0to3) \
|
||||
(((size0to3 + 3) * SFG_BASE_SPRITE_SIZE) / 4)
|
||||
|
||||
#define SFG_SPRITE_SIZE_TO_HEAIGH_ABOVE_GROUND(size0to3) \
|
||||
((((size0to3) + 3) * (RCL_UNITS_PER_SQUARE / 2)) / 4)
|
||||
|
||||
/**
|
||||
Holds information about one instance of a level item (a type of level element,
|
||||
e.g. pickable items, decorations etc.). The format is following:
|
||||
@ -2507,14 +2521,18 @@ void SFG_draw()
|
||||
worldPosition.x = SFG_MONSTER_COORD_TO_RCL_UNITS(m.coords[0]);
|
||||
worldPosition.y = SFG_MONSTER_COORD_TO_RCL_UNITS(m.coords[1]);
|
||||
|
||||
uint8_t spriteSize = SFG_GET_MONSTER_SPRITE_SIZE(
|
||||
SFG_MONSTER_TYPE_TO_INDEX(SFG_MR_TYPE(m)));
|
||||
|
||||
RCL_PixelInfo p =
|
||||
RCL_mapToScreen(
|
||||
worldPosition,
|
||||
SFG_floorHeightAt(
|
||||
SFG_MONSTER_COORD_TO_SQUARES(m.coords[0]),
|
||||
SFG_MONSTER_COORD_TO_SQUARES(m.coords[1]))
|
||||
+ RCL_UNITS_PER_SQUARE / 2,
|
||||
SFG_player.camera);
|
||||
+
|
||||
SFG_SPRITE_SIZE_TO_HEAIGH_ABOVE_GROUND(spriteSize),
|
||||
SFG_player.camera);
|
||||
|
||||
if (p.depth > 0)
|
||||
{
|
||||
@ -2526,7 +2544,9 @@ void SFG_draw()
|
||||
|
||||
SFG_drawScaledSprite(s,
|
||||
p.position.x * SFG_RAYCASTING_SUBSAMPLE,p.position.y,
|
||||
RCL_perspectiveScale(SFG_BASE_SPRITE_SIZE,p.depth),
|
||||
RCL_perspectiveScale(
|
||||
SFG_SPRITE_SIZE(spriteSize),
|
||||
p.depth),
|
||||
p.depth / (RCL_UNITS_PER_SQUARE * 2),p.depth);
|
||||
}
|
||||
}
|
||||
@ -2552,15 +2572,14 @@ void SFG_draw()
|
||||
RCL_mapToScreen(
|
||||
worldPosition,
|
||||
SFG_floorHeightAt(e.coords[0],e.coords[1])
|
||||
+ RCL_UNITS_PER_SQUARE / 2,
|
||||
+ SFG_SPRITE_SIZE_TO_HEAIGH_ABOVE_GROUND(0),
|
||||
SFG_player.camera);
|
||||
|
||||
if (p.depth > 0)
|
||||
{
|
||||
SFG_drawScaledSprite(SFG_itemSprites[e.type - 1],
|
||||
p.position.x * SFG_RAYCASTING_SUBSAMPLE,p.position.y,
|
||||
|
||||
RCL_perspectiveScale(SFG_BASE_SPRITE_SIZE,p.depth)/*40*/,
|
||||
RCL_perspectiveScale(SFG_SPRITE_SIZE(0),p.depth),
|
||||
p.depth / (RCL_UNITS_PER_SQUARE * 2),p.depth - 1000);
|
||||
}
|
||||
}
|
||||
@ -2583,7 +2602,7 @@ void SFG_draw()
|
||||
|
||||
const uint8_t *s = SFG_effectSprites[proj->type];
|
||||
|
||||
int16_t spriteSize = SFG_BASE_SPRITE_SIZE / 2;
|
||||
int16_t spriteSize = SFG_SPRITE_SIZE(0);
|
||||
|
||||
if (proj->type == SFG_PROJECTILE_EXPLOSION ||
|
||||
proj->type == SFG_PROJECTILE_DUST)
|
||||
|
2
make.sh
2
make.sh
@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
clear; clear; g++ -x c -g -fmax-errors=5 -pedantic -O3 -Wall -Wextra -o game main.c -lSDL2 2>&1 >/dev/null && ./game
|
||||
clear; clear; g++ -x c -g -Wall -Wextra -fmax-errors=5 -pedantic -O3 -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -o game main.c -lSDL2 2>&1 >/dev/null && ./game
|
||||
|
Loading…
Reference in New Issue
Block a user