Add sprites
This commit is contained in:
parent
c1329c8cf8
commit
4f1cb9aaaa
1 changed files with 178 additions and 97 deletions
275
game.cpp
275
game.cpp
|
@ -25,7 +25,7 @@
|
||||||
#define MIDDLE_ROW (SCREEN_HEIGHT / 2)
|
#define MIDDLE_ROW (SCREEN_HEIGHT / 2)
|
||||||
#define MIDDLE_COLUMN (SCREEN_WIDTH / 2)
|
#define MIDDLE_COLUMN (SCREEN_WIDTH / 2)
|
||||||
|
|
||||||
#define SPRITES 6
|
#define SPRITES 3
|
||||||
|
|
||||||
Pokitto::Core p;
|
Pokitto::Core p;
|
||||||
|
|
||||||
|
@ -343,82 +343,160 @@ const unsigned char texture3[] =
|
||||||
,0x56,0x54
|
,0x56,0x54
|
||||||
};
|
};
|
||||||
|
|
||||||
const unsigned char sprite[] =
|
const unsigned char sprite1[] =
|
||||||
{ 32, 32 // width, height
|
{ 32, 32 // width, height
|
||||||
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00
|
||||||
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
|
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
|
,0x00,0x00,0x00,0x64,0x64,0x64,0x76,0x64,0x64,0x64,0x64,0x64,0x00,0x07
|
||||||
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
|
,0x07,0x07,0x00,0x00,0x64,0x76,0x64,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
||||||
,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff
|
,0x00,0x00,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x07
|
||||||
,0x00,0x52,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
|
,0x07,0x07,0x07,0x07,0x00,0x00,0x76,0x64,0x00,0x00,0x00,0x09,0x09,0x09
|
||||||
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x52,0x76,0x76,0x64
|
,0x00,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x52,0x76,0x76,0x64
|
||||||
,0x00,0xff,0xff,0x00,0x64,0x76,0xff,0x52,0x64,0x00,0x00,0xff,0xff,0xff
|
,0x52,0x00,0x07,0x07,0x07,0x07,0x00,0x00,0x76,0x64,0x00,0x09,0x09,0x09
|
||||||
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x52
|
,0x09,0x09,0x52,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x00,0x52
|
||||||
,0x09,0x76,0x52,0x64,0x00,0xff,0xff,0x00,0x76,0xff,0xff,0x52,0x64,0x52
|
,0x09,0x76,0x52,0x64,0x52,0x00,0x07,0x07,0x07,0x00,0xff,0x76,0x09,0x09
|
||||||
,0x64,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
|
,0x52,0x09,0x52,0x09,0x09,0x52,0x09,0x00,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
,0xff,0x00,0x52,0x00,0x52,0x64,0x09,0x64,0x00,0xff,0xff,0x00,0xff,0xff
|
,0x00,0x76,0x76,0x64,0x52,0x64,0x09,0x64,0x52,0x00,0x07,0x07,0x00,0xff
|
||||||
,0xff,0x52,0x52,0x64,0x52,0x64,0x64,0x00,0x00,0xff,0xff,0xff,0xff,0xff
|
,0x09,0x09,0x09,0x52,0x09,0x52,0x09,0x52,0x52,0x52,0x52,0x00,0x00,0x07
|
||||||
,0xff,0xff,0xff,0xff,0x00,0x52,0x00,0x52,0x09,0x76,0x52,0x64,0x00,0xff
|
,0x07,0x07,0x07,0x00,0x52,0x76,0x52,0x64,0x09,0x76,0x52,0x64,0x52,0x00
|
||||||
,0xff,0x00,0xff,0x76,0xff,0x52,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x00
|
,0x07,0x00,0x76,0x52,0x52,0x64,0x64,0x52,0x52,0x52,0x52,0x64,0x52,0x64
|
||||||
,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x52,0x09,0x52,0x52,0x76
|
,0x64,0x64,0x64,0x00,0x07,0x07,0x00,0x52,0x09,0x76,0x09,0x64,0x52,0x76
|
||||||
,0x09,0x64,0x00,0xff,0xff,0x00,0x76,0x76,0xff,0x64,0x64,0x64,0x64,0x64
|
,0x09,0x64,0x52,0x00,0x00,0x76,0x64,0x00,0x00,0x00,0x00,0x00,0x64,0x52
|
||||||
,0x64,0x64,0x64,0x64,0x64,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0x00,0x52
|
,0x52,0x52,0x52,0x52,0x00,0x00,0x00,0x07,0x07,0x07,0x00,0x52,0x09,0x64
|
||||||
,0x52,0x52,0x09,0x64,0x52,0x52,0x00,0xff,0xff,0x00,0x76,0xff,0xff,0x64
|
,0x52,0x64,0x52,0x76,0x52,0x64,0x52,0x00,0x00,0xff,0x00,0x07,0x07,0x07
|
||||||
,0x64,0x64,0x09,0x52,0x64,0x64,0x76,0x64,0x64,0x64,0x64,0x00,0x00,0xff
|
,0x07,0x07,0x00,0x64,0x52,0x52,0x52,0x00,0x00,0x00,0x07,0x07,0x07,0x07
|
||||||
,0xff,0xff,0x00,0x52,0x09,0x09,0x52,0x76,0x09,0x52,0x00,0xff,0xff,0x00
|
,0x00,0x00,0x09,0x76,0x09,0x64,0x09,0x64,0x52,0x52,0x52,0x00,0x07,0x00
|
||||||
,0xff,0x76,0xff,0x52,0x64,0x64,0x09,0x09,0x52,0x52,0x64,0x64,0x64,0x52
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x64,0x52,0x00,0x00,0x76,0x76
|
||||||
,0x64,0x64,0x64,0x00,0x00,0xff,0x00,0x52,0x52,0x09,0x09,0x64,0x09,0x64
|
,0x00,0x07,0x07,0x07,0x00,0x64,0x09,0x76,0x52,0x64,0x09,0x76,0x09,0x52
|
||||||
,0x00,0xff,0xff,0x00,0x76,0x76,0xff,0x52,0x64,0x52,0x09,0x09,0x09,0x52
|
,0x52,0x00,0x07,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x07,0x00,0x64,0x09
|
||||||
,0x09,0x52,0x76,0x64,0x52,0x64,0x52,0x64,0x52,0x00,0x00,0x52,0x09,0x52
|
,0x00,0x76,0x64,0x00,0x00,0x07,0x07,0x07,0x00,0x52,0x00,0x76,0x09,0x52
|
||||||
,0x09,0x64,0x52,0x64,0x00,0xff,0xff,0x00,0x76,0x76,0xff,0x64,0x64,0x64
|
,0x09,0x64,0x52,0x64,0x52,0x00,0x07,0x00,0x07,0x07,0x00,0x64,0x76,0x64
|
||||||
,0x00,0x09,0x52,0x09,0x52,0x09,0x52,0x52,0x76,0x64,0x64,0x52,0x52,0x64
|
,0x00,0x07,0x00,0x09,0x76,0x64,0x76,0x00,0x76,0x00,0x07,0x00,0x64,0x64
|
||||||
,0x52,0x00,0x09,0x09,0x09,0x76,0x52,0x64,0x00,0xff,0xff,0x00,0xff,0x76
|
,0x09,0x64,0x52,0x64,0x09,0x76,0x52,0x64,0x52,0x00,0x00,0xff,0x00,0x00
|
||||||
,0xff,0x64,0x64,0x52,0x00,0x00,0x00,0x09,0x09,0x52,0x52,0x09,0x52,0x52
|
,0x76,0x00,0x00,0x64,0x64,0x00,0x52,0x52,0x64,0x00,0x00,0x76,0x64,0x64
|
||||||
,0x76,0x76,0x52,0x52,0x52,0x52,0x52,0x09,0x09,0x76,0x52,0x52,0x00,0xff
|
,0x00,0x64,0x00,0x00,0x09,0x76,0x09,0x64,0x09,0x76,0x52,0x52,0x52,0x00
|
||||||
,0xff,0x00,0x76,0x76,0xff,0x52,0x64,0x64,0x00,0xff,0xff,0x00,0x00,0x09
|
,0x07,0x00,0x76,0x76,0x00,0x07,0x07,0x00,0x64,0x00,0x09,0x64,0x52,0x64
|
||||||
,0x52,0x52,0x52,0x52,0x52,0x52,0x76,0x64,0x52,0x64,0x52,0x64,0x00,0x76
|
,0x64,0x64,0x00,0x00,0x64,0x00,0x00,0x52,0x09,0x64,0x09,0x52,0x00,0x76
|
||||||
,0x09,0x64,0x00,0xff,0xff,0x00,0x76,0x76,0x76,0x64,0x52,0x64,0x00,0xff
|
,0x09,0x64,0x52,0x00,0x07,0x07,0x00,0x00,0x07,0x07,0x07,0x00,0x64,0x52
|
||||||
,0xff,0xff,0xff,0x00,0x00,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x76,0x76
|
,0x64,0x52,0x52,0x64,0x64,0x00,0x07,0x07,0x00,0x07,0x00,0x52,0x09,0x64
|
||||||
,0x64,0x64,0x00,0x64,0x09,0x52,0x00,0xff,0xff,0x00,0x76,0x76,0xff,0x52
|
,0x52,0x52,0x00,0x64,0x09,0x52,0x52,0x00,0x07,0x07,0x00,0x00,0x07,0x07
|
||||||
,0x64,0x52,0x00,0xff,0xff,0xff,0xff,0x00,0x52,0x64,0x64,0x52,0x52,0x52
|
,0x07,0x00,0x64,0x52,0x64,0x52,0x52,0x52,0x64,0x00,0x07,0x07,0x00,0x07
|
||||||
,0x52,0x52,0x52,0x09,0x64,0x76,0x00,0x64,0x09,0x52,0x00,0xff,0xff,0x00
|
,0x00,0x52,0x00,0x64,0x09,0x64,0x00,0x64,0x09,0x52,0x52,0x00,0x07,0x00
|
||||||
,0x76,0x64,0x76,0x52,0x52,0x64,0x00,0xff,0xff,0x00,0x00,0x64,0x64,0x64
|
,0x64,0x64,0x00,0x07,0x07,0x00,0x52,0x00,0x09,0x64,0x52,0x52,0x52,0x64
|
||||||
,0x64,0x64,0x64,0x52,0x52,0x52,0x09,0x52,0x52,0x52,0x00,0x76,0x09,0x52
|
,0x00,0x00,0x64,0x00,0x00,0x09,0x00,0x76,0x09,0x52,0x00,0x76,0x09,0x52
|
||||||
,0x00,0xff,0xff,0x00,0x76,0x76,0x76,0x52,0x52,0x52,0x00,0x00,0x00,0x76
|
,0x52,0x00,0x00,0x64,0x00,0x00,0x64,0x00,0x00,0x52,0x64,0x00,0x52,0x52
|
||||||
,0x76,0x64,0x76,0x64,0x64,0x64,0x52,0x52,0x09,0x52,0x52,0x09,0x52,0x09
|
,0x64,0x00,0x00,0x64,0x64,0x64,0x00,0x64,0x00,0x00,0x00,0x64,0x09,0x52
|
||||||
,0x00,0x64,0x52,0x52,0x00,0xff,0xff,0x00,0x64,0x76,0x76,0x52,0x52,0x52
|
,0x00,0x64,0x52,0x52,0x52,0x00,0x07,0x00,0x07,0x07,0x00,0x52,0x64,0x52
|
||||||
,0x00,0x76,0xff,0x76,0x64,0x76,0x64,0x64,0x52,0x52,0x52,0x52,0x52,0x52
|
,0x00,0x07,0x00,0x09,0x64,0x64,0x64,0x00,0x64,0x00,0x07,0x00,0x64,0x64
|
||||||
,0x52,0x09,0x09,0x00,0x00,0x64,0x09,0x64,0x00,0xff,0xff,0x00,0x76,0x76
|
,0x00,0x64,0x09,0x52,0x00,0x64,0x09,0x64,0x52,0x00,0x07,0x07,0x07,0x07
|
||||||
,0xff,0x52,0x64,0xff,0xff,0x76,0x76,0x76,0x76,0x64,0x52,0x52,0x52,0x52
|
,0x07,0x00,0x00,0x00,0x07,0x00,0x64,0x00,0x00,0x64,0x52,0x00,0x00,0x07
|
||||||
,0x52,0x52,0x52,0x00,0x00,0x00,0x00,0x09,0x00,0x52,0x52,0x52,0x00,0xff
|
,0x07,0x07,0x00,0x52,0x09,0x64,0x52,0x52,0x00,0x64,0x52,0x52,0x52,0x00
|
||||||
,0xff,0x00,0x76,0x76,0xff,0xff,0xff,0x76,0x76,0x76,0x76,0x64,0x52,0x52
|
,0x07,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x64,0x00,0x00,0x00
|
||||||
,0x52,0x09,0x52,0x52,0x52,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x64
|
,0x64,0x64,0x00,0x07,0x07,0x07,0x00,0x64,0x00,0x64,0x09,0x52,0x00,0x52
|
||||||
,0x09,0x52,0x00,0xff,0xff,0x00,0x76,0x76,0x76,0x76,0x76,0x76,0x76,0x64
|
,0x09,0x52,0x52,0x00,0x00,0x64,0x00,0x07,0x07,0x07,0x07,0x07,0x00,0x64
|
||||||
,0x52,0x52,0x09,0x52,0x52,0x52,0x52,0x00,0x00,0x00,0x00,0xff,0x00,0x00
|
,0x00,0x00,0x09,0x00,0x00,0x00,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x52
|
||||||
,0x00,0x00,0x00,0x64,0x09,0x52,0x00,0xff,0xff,0x00,0x64,0x76,0x64,0x76
|
,0x52,0x52,0x00,0x64,0x09,0x52,0x52,0x00,0x00,0x64,0x64,0x00,0x00,0x00
|
||||||
,0x76,0x64,0x52,0x09,0x52,0x09,0x52,0x09,0x52,0x00,0x00,0x00,0x00,0xff
|
,0x00,0x00,0x64,0x00,0x00,0x09,0x09,0x09,0x00,0x00,0x00,0x00,0x07,0x07
|
||||||
,0xff,0xff,0x00,0x09,0x00,0x09,0x00,0x52,0x09,0x52,0x00,0xff,0xff,0x00
|
,0x00,0x00,0x00,0x64,0x09,0x52,0x00,0x52,0x09,0x52,0x52,0x00,0x07,0x00
|
||||||
,0x76,0x64,0x76,0x64,0x52,0x09,0x09,0x09,0x09,0x52,0x52,0x00,0x00,0xff
|
,0x64,0x00,0x09,0x52,0x52,0x52,0x09,0x09,0x52,0x09,0x52,0x52,0x52,0x52
|
||||||
,0xff,0x00,0x00,0xff,0xff,0xff,0x00,0x00,0x09,0x00,0x00,0x52,0x52,0x52
|
,0x52,0x00,0x00,0x07,0x00,0x09,0x00,0x52,0x09,0x52,0x00,0x52,0x52,0x52
|
||||||
,0x00,0xff,0xff,0x00,0x64,0x64,0x52,0x09,0x09,0x09,0x09,0x52,0x52,0x00
|
,0x52,0x00,0x07,0x07,0x00,0x64,0x00,0x09,0x09,0x09,0x09,0x09,0x09,0x09
|
||||||
,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0x09,0x00,0x00
|
,0x09,0x09,0x09,0x00,0x00,0x00,0x07,0x07,0x07,0x00,0x09,0x64,0x52,0x52
|
||||||
,0x00,0x64,0x09,0x52,0x00,0xff,0xff,0x00,0x09,0x09,0x09,0x09,0x09,0x52
|
,0x00,0x64,0x09,0x52,0x52,0x00,0x07,0x07,0x07,0x00,0x64,0x64,0x00,0x09
|
||||||
,0x52,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0x00,0x00
|
,0x09,0x52,0x09,0x09,0x09,0x09,0x52,0x00,0x00,0x07,0x07,0x07,0x07,0x07
|
||||||
,0x00,0x00,0x00,0x00,0x00,0x52,0x09,0x52,0x00,0xff,0xff,0x00,0x09,0x09
|
,0x00,0x52,0x52,0x52,0x00,0x52,0x09,0x52,0x52,0x00,0x07,0x07,0x07,0x07
|
||||||
,0x09,0x09,0x52,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00
|
,0x00,0x00,0x64,0x64,0x09,0x09,0x09,0x52,0x09,0x52,0x09,0x00,0x00,0x00
|
||||||
,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x09,0x00,0x64,0x52,0x52,0x00,0xff
|
,0x00,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x00,0x64,0x52,0x52,0x52,0x00
|
||||||
,0xff,0xff,0x00,0x00,0x52,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x00,0x64,0x64,0x09,0x09,0x52,0x09
|
||||||
,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x00,0x00,0x09,0x52
|
,0x52,0x09,0x00,0x00,0x00,0x00,0x07,0x07,0x07,0x07,0x00,0x00,0x09,0x52
|
||||||
,0x52,0x52,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff
|
,0x52,0x52,0x52,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x00
|
||||||
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff
|
,0x64,0x64,0x64,0x09,0x09,0x09,0x09,0x09,0x00,0x00,0x00,0x00,0x07,0x07
|
||||||
,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff
|
,0x07,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00
|
,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x64,0x64,0x64,0x64,0x64,0x64,0x64
|
||||||
,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff
|
,0x64,0x64,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x00,0x00
|
||||||
,0xff,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
|
,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
,0xff,0xff
|
,0x07,0x07
|
||||||
|
};
|
||||||
|
|
||||||
|
const unsigned char sprite2[] =
|
||||||
|
{ 32, 32 // width, height
|
||||||
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x07,0x07,0x07
|
||||||
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0xbf,0xbf
|
||||||
|
,0xbf,0x00,0x07,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x27,0x00,0x07,0x07
|
||||||
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
|
,0x07,0x00,0xbf,0x5b,0x5b,0x00,0x00,0x00,0x00,0x00,0x00,0x27,0x27,0x27
|
||||||
|
,0x0c,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
|
,0x07,0x07,0x07,0x07,0x00,0x52,0x6d,0x5b,0x09,0x0c,0x0c,0x0c,0x27,0x27
|
||||||
|
,0x27,0x0c,0x0a,0x0a,0x0a,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
|
,0x07,0x07,0x07,0x07,0x07,0x00,0x07,0x00,0x5b,0x09,0x09,0x09,0x0a,0x0a
|
||||||
|
,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0b,0x0b,0x0a,0x00,0x07,0x07,0x00,0x00
|
||||||
|
,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x3f,0x00,0x5b,0x09,0x5b
|
||||||
|
,0x09,0x00,0x02,0x01,0x01,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x00
|
||||||
|
,0x00,0x07,0x00,0x3e,0xb6,0x00,0x07,0x00,0x07,0x07,0x07,0x00,0x15,0x15
|
||||||
|
,0x3d,0x09,0x09,0x09,0x00,0x01,0x01,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x01
|
||||||
|
,0x01,0x01,0x01,0x52,0x52,0x00,0x07,0x00,0x3e,0x6d,0x00,0xb6,0x00,0x07
|
||||||
|
,0x00,0x0c,0x0c,0x15,0x15,0x3d,0x00,0x00,0x0a,0x0a,0x00,0x00,0x00,0x01
|
||||||
|
,0x01,0x01,0x01,0x01,0x01,0x01,0x52,0x6d,0x52,0x00,0x07,0x07,0x00,0x3d
|
||||||
|
,0x5b,0x6d,0x00,0x00,0x27,0x27,0x0c,0x0c,0x15,0x3f,0x00,0x01,0x00,0x00
|
||||||
|
,0x09,0x00,0x52,0x00,0x09,0x00,0x00,0x00,0x01,0x01,0x09,0xb6,0x09,0x00
|
||||||
|
,0x07,0x07,0x07,0x00,0x3d,0x09,0x00,0x0a,0x0c,0x15,0x27,0x09,0x09,0x09
|
||||||
|
,0x09,0x00,0x3f,0x00,0x52,0x09,0x64,0x00,0x3d,0x3d,0x3f,0x64,0x64,0x09
|
||||||
|
,0xb6,0x6d,0x09,0x00,0x07,0x07,0x00,0xbf,0x6d,0x00,0x5b,0x52,0x0a,0x09
|
||||||
|
,0x09,0x09,0x5b,0x6d,0x09,0x5b,0x3d,0x00,0x64,0x00,0x64,0x09,0x00,0x1d
|
||||||
|
,0x3f,0x5b,0x52,0x52,0x09,0x52,0x00,0x00,0x07,0x00,0xb6,0xff,0x3e,0x00
|
||||||
|
,0x3e,0x3e,0x3d,0x09,0x5b,0x6d,0xbf,0xb6,0x52,0x3e,0x1d,0x3d,0x00,0x64
|
||||||
|
,0x00,0x52,0x00,0x00,0x09,0x52,0x52,0x12,0x09,0x00,0x00,0x00,0x00,0x3d
|
||||||
|
,0x3d,0x3d,0x00,0x00,0x00,0x00,0x09,0x09,0x09,0x6d,0x6d,0x52,0x52,0x3e
|
||||||
|
,0x1d,0x3d,0x00,0x64,0x00,0x52,0x00,0x02,0x00,0x00,0x09,0x00,0x00,0x01
|
||||||
|
,0x00,0x00,0x07,0x00,0x52,0x5b,0x3d,0x00,0x3d,0x3f,0x3f,0x09,0x5b,0x52
|
||||||
|
,0x5b,0x6d,0x52,0x3d,0x1d,0x3f,0x00,0x64,0x00,0x52,0x00,0x01,0x01,0x01
|
||||||
|
,0x01,0x0a,0x0a,0x0a,0x00,0x00,0x07,0x07,0x00,0x52,0x5b,0x00,0x52,0x52
|
||||||
|
,0x0a,0x27,0x09,0x09,0x09,0x09,0x52,0x5b,0x3f,0x00,0x00,0x64,0x00,0x52
|
||||||
|
,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x07,0x07,0x07,0x07,0x00
|
||||||
|
,0x3f,0x09,0x00,0x0a,0x0c,0x27,0x0c,0x15,0x3f,0x09,0x09,0x09,0x3f,0x00
|
||||||
|
,0x64,0x00,0x52,0x09,0x00,0x3d,0x3f,0x5b,0x00,0x00,0x01,0x01,0x00,0x07
|
||||||
|
,0x07,0x07,0x00,0x1d,0x52,0x5b,0x00,0x0c,0x27,0x0c,0x0c,0x15,0x0c,0x3d
|
||||||
|
,0x00,0x00,0x00,0x00,0x52,0x09,0x00,0x00,0x3f,0x3e,0x3d,0x52,0x52,0x64
|
||||||
|
,0x09,0x52,0x00,0x00,0x07,0x00,0x1d,0x5b,0x00,0x5b,0x00,0x27,0x0c,0x0c
|
||||||
|
,0x15,0x15,0x15,0x3d,0x52,0x52,0x0a,0x52,0xbf,0x6d,0x00,0x00,0x00,0x3f
|
||||||
|
,0x52,0x12,0x12,0x09,0x64,0xb6,0x52,0x00,0x00,0x3f,0x5b,0x00,0x07,0x00
|
||||||
|
,0x07,0x00,0x00,0x0c,0x27,0x15,0x15,0x3e,0x00,0x09,0x52,0xbf,0x6d,0x5b
|
||||||
|
,0x0a,0x0a,0x0a,0x01,0x00,0x00,0x00,0x00,0x00,0x64,0x09,0x00,0x00,0x00
|
||||||
|
,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x00,0x27,0x3e,0x27,0x27,0x15
|
||||||
|
,0x09,0x00,0x00,0x0a,0x0a,0x0a,0x0a,0x0a,0x01,0x01,0x01,0x00,0x00,0x09
|
||||||
|
,0x09,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00
|
||||||
|
,0x3d,0x0c,0x0c,0x27,0x27,0x27,0x27,0x15,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a
|
||||||
|
,0x01,0x01,0x01,0x0a,0x00,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
|
,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x27,0x27,0x27
|
||||||
|
,0x27,0x15,0x15,0x0a,0x0a,0x0a,0x0a,0x0a,0x00,0x07,0x07,0x07,0x07,0x07
|
||||||
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
|
,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x15,0x15,0x15,0x15,0x15,0x00,0x07
|
||||||
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x00
|
||||||
|
,0x00,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
|
,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
|
||||||
|
,0x07,0x07
|
||||||
};
|
};
|
||||||
|
|
||||||
const unsigned char *textures[] = {texture1, texture2, texture3};
|
const unsigned char *textures[] = {texture1, texture2, texture3};
|
||||||
|
@ -428,7 +506,7 @@ inline uint8_t sampleImage(const unsigned char *image, Unit x, Unit y)
|
||||||
// TODO: optimize
|
// TODO: optimize
|
||||||
|
|
||||||
x = wrap(x,UNITS_PER_SQUARE);
|
x = wrap(x,UNITS_PER_SQUARE);
|
||||||
y = UNITS_PER_SQUARE - wrap(y,UNITS_PER_SQUARE) - 1;
|
y = wrap(y,UNITS_PER_SQUARE);
|
||||||
|
|
||||||
int32_t index =
|
int32_t index =
|
||||||
image[1] * ((image[1] * x) / UNITS_PER_SQUARE) + (image[0] * y) /
|
image[1] * ((image[1] * x) / UNITS_PER_SQUARE) + (image[0] * y) /
|
||||||
|
@ -437,6 +515,8 @@ inline uint8_t sampleImage(const unsigned char *image, Unit x, Unit y)
|
||||||
return image[2 + index];
|
return image[2 + index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned char translaprentColor;
|
||||||
|
|
||||||
void drawSprite(const unsigned char *sprite, int16_t x, int16_t y, Unit depth, int16_t size)
|
void drawSprite(const unsigned char *sprite, int16_t x, int16_t y, Unit depth, int16_t size)
|
||||||
{
|
{
|
||||||
// TODO: optimize
|
// TODO: optimize
|
||||||
|
@ -462,7 +542,7 @@ void drawSprite(const unsigned char *sprite, int16_t x, int16_t y, Unit depth, i
|
||||||
{
|
{
|
||||||
c = sampleImage(sprite,(i * UNITS_PER_SQUARE) / size,(j * UNITS_PER_SQUARE) / size);
|
c = sampleImage(sprite,(i * UNITS_PER_SQUARE) / size,(j * UNITS_PER_SQUARE) / size);
|
||||||
|
|
||||||
if (c != 0xff)
|
if (c != translaprentColor)
|
||||||
p.display.drawPixel(xPos,y + j,c);
|
p.display.drawPixel(xPos,y + j,c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -506,8 +586,10 @@ inline uint8_t addIntensity(uint8_t color, int intensity)
|
||||||
class Sprite
|
class Sprite
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
const unsigned char *mImage;
|
||||||
Vector2D mPosition;
|
Vector2D mPosition;
|
||||||
Unit mHeight;
|
Unit mHeight;
|
||||||
|
Unit mPixelSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Character
|
class Character
|
||||||
|
@ -517,9 +599,9 @@ public:
|
||||||
|
|
||||||
Character()
|
Character()
|
||||||
{
|
{
|
||||||
mCamera.position.x = 27127;//UNITS_PER_SQUARE * 1;
|
mCamera.position.x = 8898;//UNITS_PER_SQUARE * 1;
|
||||||
mCamera.position.y = 1361;//UNITS_PER_SQUARE * 5;
|
mCamera.position.y = 4818;//UNITS_PER_SQUARE * 5;
|
||||||
mCamera.direction = -3400;//200;
|
mCamera.direction = -3175;//200;
|
||||||
mCamera.fovAngle = UNITS_PER_SQUARE / 4;
|
mCamera.fovAngle = UNITS_PER_SQUARE / 4;
|
||||||
mCamera.height = UNITS_PER_SQUARE * 2;
|
mCamera.height = UNITS_PER_SQUARE * 2;
|
||||||
mCamera.resolution.x = 110 / SUBSAMPLE;
|
mCamera.resolution.x = 110 / SUBSAMPLE;
|
||||||
|
@ -605,21 +687,23 @@ void draw()
|
||||||
{
|
{
|
||||||
RayConstraints c;
|
RayConstraints c;
|
||||||
|
|
||||||
c.maxHits = 16;
|
c.maxHits = 8;
|
||||||
c.maxSteps = 16;
|
c.maxSteps = 10;
|
||||||
c.computeTextureCoords = 1;
|
c.computeTextureCoords = 1;
|
||||||
|
|
||||||
render(player.mCamera,floorHeightAt,ceilingHeightAt,textureAt,pixelFunc,c);
|
render(player.mCamera,floorHeightAt,ceilingHeightAt,textureAt,pixelFunc,c);
|
||||||
|
|
||||||
Unit previousDepth;
|
Unit previousDepth;
|
||||||
|
|
||||||
|
// draw sprites
|
||||||
|
|
||||||
for (uint8_t i = 0; i < SPRITES; ++i)
|
for (uint8_t i = 0; i < SPRITES; ++i)
|
||||||
{
|
{
|
||||||
PixelInfo pos = mapToScreen(sprites[i].mPosition,sprites[i].mHeight,player.mCamera);
|
PixelInfo pos = mapToScreen(sprites[i].mPosition,sprites[i].mHeight,player.mCamera);
|
||||||
|
|
||||||
if (pos.depth > 0)
|
if (pos.depth > 0)
|
||||||
drawSprite(sprite,pos.position.x * SUBSAMPLE,pos.position.y,
|
drawSprite(sprites[i].mImage,pos.position.x * SUBSAMPLE,pos.position.y,
|
||||||
pos.depth,perspectiveScale(32,pos.depth));
|
pos.depth,perspectiveScale(sprites[i].mPixelSize,pos.depth));
|
||||||
|
|
||||||
if (i != 0 && pos.depth > previousDepth)
|
if (i != 0 && pos.depth > previousDepth)
|
||||||
{
|
{
|
||||||
|
@ -643,17 +727,18 @@ p.display.print(player.mCamera.direction);
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
#define placeSprite(I,X,Y,Z)\
|
translaprentColor = rgbToIndex(7,0,0);
|
||||||
|
|
||||||
|
#define placeSprite(S,I,X,Y,Z,P)\
|
||||||
|
sprites[I].mImage = S;\
|
||||||
sprites[I].mPosition.x = X * UNITS_PER_SQUARE + UNITS_PER_SQUARE / 2;\
|
sprites[I].mPosition.x = X * UNITS_PER_SQUARE + UNITS_PER_SQUARE / 2;\
|
||||||
sprites[I].mPosition.y = Y * UNITS_PER_SQUARE + UNITS_PER_SQUARE / 2;\
|
sprites[I].mPosition.y = Y * UNITS_PER_SQUARE + UNITS_PER_SQUARE / 2;\
|
||||||
sprites[I].mHeight = Z * UNITS_PER_SQUARE + UNITS_PER_SQUARE / 2;
|
sprites[I].mHeight = Z * UNITS_PER_SQUARE + UNITS_PER_SQUARE / 2;\
|
||||||
|
sprites[I].mPixelSize = P;
|
||||||
|
|
||||||
placeSprite(0,5,7,0)
|
placeSprite(sprite1,0,10,5,1,100)
|
||||||
placeSprite(1,6,7,0)
|
placeSprite(sprite1,1,14,5,1,100)
|
||||||
placeSprite(2,5,8,0)
|
placeSprite(sprite2,2,15,19,1,200)
|
||||||
placeSprite(3,6,8,0)
|
|
||||||
placeSprite(4,-1,-2,1)
|
|
||||||
placeSprite(5,12,5,1)
|
|
||||||
|
|
||||||
#undef placeSprite
|
#undef placeSprite
|
||||||
|
|
||||||
|
@ -664,7 +749,6 @@ int main()
|
||||||
for (uint8_t b = 0; b < 4; ++b)
|
for (uint8_t b = 0; b < 4; ++b)
|
||||||
pal[rgbToIndex(r,g,b)] = p.display.RGBto565(36 * r, 36 * g, 85 * b);
|
pal[rgbToIndex(r,g,b)] = p.display.RGBto565(36 * r, 36 * g, 85 * b);
|
||||||
|
|
||||||
|
|
||||||
p.display.load565Palette(&pal[0]); // load a palette the same way as any other palette in any other screen mode
|
p.display.load565Palette(&pal[0]); // load a palette the same way as any other palette in any other screen mode
|
||||||
p.display.persistence = 1;
|
p.display.persistence = 1;
|
||||||
p.setFrameRate(60);
|
p.setFrameRate(60);
|
||||||
|
@ -734,9 +818,6 @@ int main()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
player.mCamera.direction += addition * step2;
|
player.mCamera.direction += addition * step2;
|
||||||
|
|
||||||
player.mCamera.height =
|
|
||||||
max(floorHeightAt(player.mCamera.position.x / UNITS_PER_SQUARE,player.mCamera.position.y / UNITS_PER_SQUARE) + UNITS_PER_SQUARE / 2,player.mCamera.height);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue