Start assets
This commit is contained in:
parent
afecda260e
commit
7bb028fad4
5 changed files with 684 additions and 7 deletions
61
game.h
61
game.h
|
@ -8,6 +8,7 @@
|
|||
#define _LCR_GAME_H
|
||||
|
||||
#include "map.h"
|
||||
#include "assets.h"
|
||||
|
||||
#define LCR_KEY_UP 0x00
|
||||
#define LCR_KEY_RIGHT 0x01
|
||||
|
@ -73,13 +74,36 @@ uint8_t _LCR_keyStates[LCR_KEYS_TOTAL]; /**< Assures unchanging key states
|
|||
during a single frame. */
|
||||
|
||||
/**
|
||||
Internal pixel drawing function that checks for out-of-screen coordinates.
|
||||
Internal pixel drawing function that takes into account things like subdivided
|
||||
resolution etc. This function does not check for out-of-screen coordinates!
|
||||
*/
|
||||
static inline void _LCR_drawPixel(unsigned int x, unsigned int y,
|
||||
void LCR_drawPixelUnsafe(unsigned int x, unsigned int y,
|
||||
uint_fast16_t color)
|
||||
{
|
||||
if (x < LCR_SETTING_RESOLUTION_X && y < LCR_SETTING_RESOLUTION_Y)
|
||||
LCR_drawPixel(x,y,color);
|
||||
#if LCR_SETTING_RESOLUTION_SUBDIVIDE == 1
|
||||
LCR_drawPixel(x,y,color);
|
||||
#else
|
||||
x *= LCR_SETTING_RESOLUTION_SUBDIVIDE;
|
||||
y *= LCR_SETTING_RESOLUTION_SUBDIVIDE;
|
||||
|
||||
unsigned int x2 = x + LCR_SETTING_RESOLUTION_SUBDIVIDE;
|
||||
|
||||
for (int yy = y; yy < y + LCR_SETTING_RESOLUTION_SUBDIVIDE; ++yy)
|
||||
for (int xx = x; xx < x2; ++xx)
|
||||
LCR_drawPixel(xx,yy,color);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
Internal pixel drawing function that checks for out-of-screen coordinates. Use
|
||||
this if the pixel can potentially lie of screen (however if you know it won't,
|
||||
use the normal unsafe function in sake of performance).
|
||||
*/
|
||||
static inline void LCR_drawPixelSafe(unsigned int x, unsigned int y,
|
||||
uint_fast16_t color)
|
||||
{
|
||||
if (x < LCR_EFFECTIVE_RESOLUTION_X && y < LCR_EFFECTIVE_RESOLUTION_Y)
|
||||
LCR_drawPixelUnsafe(x,y,color);
|
||||
}
|
||||
|
||||
void LCR_gameInit(void)
|
||||
|
@ -92,14 +116,37 @@ void LCR_gameEnd(void)
|
|||
{
|
||||
}
|
||||
|
||||
void LCR_drawSky()
|
||||
{
|
||||
const uint16_t *pixel = LCR_skyImages + 256;
|
||||
uint8_t odd = 1;
|
||||
|
||||
for (int y = 0; y < 128; ++y)
|
||||
for (int x = 0; x < 128; ++x)
|
||||
{
|
||||
LCR_drawPixelUnsafe(x,y,
|
||||
LCR_skyImages[
|
||||
odd ? (*pixel & 0x00ff) : (*pixel >> 8) ]
|
||||
|
||||
);
|
||||
|
||||
if (odd)
|
||||
odd = 0;
|
||||
else
|
||||
{
|
||||
odd = 1;
|
||||
pixel++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
uint8_t LCR_gameStep(uint32_t time)
|
||||
{
|
||||
for (int i = 0; i < LCR_KEYS_TOTAL; ++i)
|
||||
_LCR_keyStates[i] = LCR_keyPressed(i);
|
||||
|
||||
for (int i = 0; i < 100; ++i)
|
||||
for (int j = 0; j < 50; ++j)
|
||||
_LCR_drawPixel(i,j,0x00ff);
|
||||
LCR_drawSky();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue