The equivalent of the output of that image would be:
#pragma once
#include <cstdint>
constexpr std::uint32_t piskel_ghost_frame_count = 1;
constexpr std::uint32_t piskel_ghost_frame_width = 24;
constexpr std::uint32_t piskel_ghost_frame_height = 24;
constexpr std::uint32_t piskel_ghost_color_bits = 4;
// 16-bit (565 rgb) palette data for "Piskel Ghost"
static const std::uint16_t piskel_ghost_pal[] =
{
0x0, 0xffff, 0x7e0, 0xf800,
};
// Piskel data for "Piskel Ghost"
static const std::uint8_t piskel_ghost_data[piskel_ghost_frame_count][288] =
{
{
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0x11,
0x11,0x11,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x11,0x00,
0x10,0x01,0x10,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x12,
0x01,0x20,0x10,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0x10,0x22,
0x02,0x20,0x11,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0x11,0x00,
0x10,0x01,0x11,0x00,0x00,0x00,
0x00,0x10,0x00,0x01,0x11,0x11,
0x11,0x11,0x11,0x00,0x01,0x00,
0x01,0x11,0x11,0x11,0x11,0x10,
0x01,0x11,0x11,0x01,0x11,0x10,
0x00,0x10,0x00,0x11,0x11,0x10,
0x01,0x11,0x10,0x00,0x01,0x00,
0x00,0x00,0x00,0x01,0x11,0x11,
0x11,0x11,0x10,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0x11,0x11,
0x11,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x11,0x11,
0x11,0x11,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x11,0x11,
0x11,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0x11,
0x11,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0x11,
0x11,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0x11,
0x11,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0x11,
0x10,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0x11,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0x10,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x11,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
}
};
The main differences:
-
#pragma once
is desirable if the file is going to be included as a .h
file, it will ‘multiple definition’ errors if the header is included more than once
-
#include <cstdint>
should be preferred because #include <stdint.h>
is deprecated (see here and/or here.)
- When using
cstdint
, expect the fixed width integer types to be in the std
namespace. Many implementations also put them in the global namspace, but that’s not guaranteed by the standard
-
constexpr
variables should be preferred over macros because the identifiers are confined to a specific namespace (in this case, the global namespace), whereas macros pollute the entire translation unit
Other things of note:
- Naming conventions are debatable
- Brace style is debatable
- Indentation style is debatable
- Spelling is debatable
It would be good (though not strictly necessary) to be able to choose which styles are used in the output.