First Commit

This commit is contained in:
MindCreeper03
2025-02-27 19:31:50 +01:00
parent bcbb6aff9a
commit e490df1715
2470 changed files with 1479965 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
# HOW to run Lode runner in emulator mode
Read [instructions](https://github.com/lexus2k/ssd1306/wiki/How-to-run-emulator-mode) and
install all required prerequisites.
## Compiling game and running emulation in Linux
> cd ssd1306/tools<br>
> ./build_and_run.sh -p linux -e -f games/lode_runner<br>
## Compiling game and running emulation in Windows
For MinGW32 use the script below:
> cd ssd1306\tools<br>
> build_and_run.bat "games/lode_runner"<br>

View File

@@ -0,0 +1,46 @@
/*
MIT License
Copyright (c) 2018, Alexey Dynda
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "game_basic.h"
uint8_t gameField[B_WIDTH*14] =
{
5,0,0,0,0,3,3,0,0,0,0,5,5,0,0,0,0,3,3,0,0,0,0,5,0,0,0,0,0,5,
5,0,2,0,0,4,0,2,1,1,2,0,0,0,0,0,4,0,0,2,1,1,2,5,0,0,0,0,0,5,
5,0,2,0,0,1,0,2,0,0,1,1,5,2,0,0,1,1,0,2,0,0,1,1,1,1,1,1,1,5,
5,0,2,1,0,0,0,2,0,4,0,0,0,2,0,0,0,0,0,2,0,4,0,5,0,0,0,0,0,5,
5,1,2,1,1,1,1,1,1,1,1,1,5,1,5,2,1,1,1,1,1,1,1,1,1,1,1,1,1,5,
5,0,2,0,0,0,0,0,4,0,0,0,0,0,5,2,0,0,0,0,4,0,0,5,0,0,0,0,0,5,
1,1,1,1,1,1,1,2,1,1,1,1,1,2,0,2,1,1,1,1,1,1,1,1,1,1,1,1,1,5,
5,0,0,0,0,3,3,2,0,0,0,5,5,1,1,1,0,3,3,0,0,0,0,5,0,0,0,0,0,5,
5,0,2,0,4,0,0,2,1,1,2,0,0,0,0,0,4,0,0,2,1,1,2,5,0,0,0,0,0,5,
5,0,2,0,1,1,0,2,0,0,1,1,5,2,0,0,1,1,0,2,0,0,1,1,1,1,1,1,1,5,
5,0,2,0,0,0,0,2,0,4,0,0,0,2,0,0,0,0,0,2,0,4,0,5,0,0,0,0,0,5,
5,1,2,1,1,1,1,1,1,1,1,1,5,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,
5,0,2,0,0,0,0,0,4,0,0,5,5,0,2,0,0,0,0,0,4,0,0,5,0,0,0,0,0,5,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,
};
GraphicsEngine engine;

View File

@@ -0,0 +1,81 @@
/*
MIT License
Copyright (c) 2018, Alexey Dynda
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include "ssd1306.h"
#include "nano_engine.h"
#define B_WIDTH 30
typedef NanoEngine<TILE_16x16_RGB8> GraphicsEngine;
extern uint8_t gameField[];
extern GraphicsEngine engine;
static inline bool isWalkable(uint8_t type) { return (type == 0) || (type == 2) || (type == 3) || (type == 4); }
static inline bool isSolid(uint8_t type) { return (type == 1) || (type == 2) || (type == 5); }
static inline bool isPipe(uint8_t type) { return type == 3; }
static inline bool isGold(uint8_t type) { return type == 4; }
static inline bool isStair(uint8_t type) { return type == 2; }
static inline uint16_t block_index(const NanoPoint& block)
{
return block.x + block.y * B_WIDTH;
}
static inline NanoPoint pos_to_block(const NanoPoint& pos)
{
return pos >> 3;
}
static inline NanoPoint block_to_pos(const NanoPoint& block)
{
return block << 3;
}
static inline NanoRect rect_to_blocks(const NanoRect& rect)
{
return rect >> 3;
}
static inline uint8_t block_value(const NanoPoint& block)
{
uint16_t index = block_index(block);
if (index >= B_WIDTH*14) index = 0;
return gameField[index];
}
static inline uint8_t block_at(const NanoPoint& p)
{
return block_value(pos_to_block(p));
}
static inline void set_block_at(const NanoPoint& p, uint8_t v)
{
uint16_t index = block_index(pos_to_block(p));
if (index >= B_WIDTH*14) index = 0;
gameField[index] = v;
}

View File

@@ -0,0 +1,321 @@
/*
MIT License
Copyright (c) 2018, Alexey Dynda
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/*
* Attiny85 PINS
* ____
* RESET -|_| |- 3V
* SCL (3) -| |- (2)
* SDA (4) -| |- (1) - BUZZER
* GND -|____|- (0) - BUTTONS module
*
* Atmega328 PINS with i2c SSD1306 to A4/A5, BUZZER on D8,
* Z-keypad ADC module on A0 pin.
* If you want to use GPIO keys, uncomment USE_GPIO_BUTTONS below
*
* Atmega328 PINS with spi Nokia 5110 LCD:
* LCD RST to D3
* LCD CES to D4
* LCD DC to D5
* LCD DIN to D11
* LCD CLK to D13
* LCD BL to VCC
*/
#include "game_basic.h"
#include "ninja.h"
#include "sprites.h"
#include "intf/ssd1306_interface.h"
#include "intf/spi/ssd1306_spi.h"
// Uncomment if you want to use gpio buttons
//#define USE_GPIO_BUTTONS
#if defined(__AVR_ATtiny25__) | defined(__AVR_ATtiny45__) | defined(__AVR_ATtiny85__)
#define BUZZER 1
#define BUTTON_PIN 0
#else // For Arduino Nano/Atmega328 we use different pins
#define BUZZER 8
#define BUTTON_PIN 0
#ifdef USE_GPIO_BUTTONS
static const uint8_t g_buttonsPins[6] = { 2, 6, 7, 8, 9, 12 };
#endif
#endif
const NanoRect game_window = { {0, 64}, {239, 319} };
// Commented line is for 90 degree
//const NanoRect game_window = { {64, 64}, {319, 239} };
uint8_t blockColors[] =
{
RGB_COLOR8(255,96,0),
RGB_COLOR8(255,255,192),
RGB_COLOR8(255,255,255),
RGB_COLOR8(255,255,64),
RGB_COLOR8(128,128,128),
};
/**
* Just produces some sound depending on params
*/
void beep(int bCount,int bDelay);
NanoFixedSprite<GraphicsEngine, engine> player( { 8, 8 }, { 8, 8 }, playerFlyingImage[0][0] );
/* The variable is used for player animation *
* The graphics defined for the hero has 2 images *
* for each direction. So, the variable is either *
* 0 or 1. */
uint8_t playerAnimation = 0;
/* Timestamp when playerAnimation was changed last time */
uint16_t playerAnimationTs = 0;
/* Number of coins collected */
uint8_t goldCollection = 0;
void showGameInfo()
{
engine.canvas.setMode(CANVAS_MODE_TRANSPARENT);
engine.canvas.setColor(RGB_COLOR8(0,0,0));
engine.canvas.drawBitmap1(1, 1, 8, 8, coinImage);
engine.canvas.setColor(RGB_COLOR8(255,255,0));
engine.canvas.drawBitmap1(0, 0, 8, 8, coinImage);
ssd1306_setFixedFont(digital_font5x7_AB);
char score[3] = {goldCollection/10 + '0', goldCollection%10 + '0', 0};
engine.canvas.setColor(RGB_COLOR8(0,0,0));
engine.canvas.printFixed(9,1,score);
engine.canvas.setColor(RGB_COLOR8(255,255,255));
engine.canvas.printFixed(8,0,score);
ssd1306_setFixedFont(digital_font5x7_AB);
}
static bool onDraw()
{
engine.canvas.clear();
engine.canvas.setMode(CANVAS_MODE_BASIC);
if (game_window.containsPartOf( engine.canvas.rect() ))
{
engine.worldCoordinates();
NanoRect blocks = rect_to_blocks( engine.canvas.rect() );
for (uint8_t row = max(0,blocks.p1.y);
row <= min(13,blocks.p2.y); row++)
{
for (uint8_t col = max(0,blocks.p1.x);
col <= min((B_WIDTH-1),blocks.p2.x); col++)
{
uint8_t blockType = block_value({col,row});
if (blockType != 0)
{
engine.canvas.setColor(blockColors[blockType - 1]);
NanoPoint pos = block_to_pos({col,row});
engine.canvas.drawBitmap1(pos.x, pos.y,
8, 8, bgSprites[blockType - 1]);
}
}
}
engine.canvas.setMode(CANVAS_MODE_TRANSPARENT);
engine.canvas.setColor(RGB_COLOR8(64,255,255));
player.draw();
engine.canvas.setColor(RGB_COLOR8(64,64,255));
ninja.draw();
engine.localCoordinates();
}
showGameInfo();
return true;
}
static NanoPoint calc_new_screen_position()
{
NanoPoint position = engine.getPosition() + game_window.p1;
if (player.x() - position.x >= game_window.width() - 24)
{
position.x = min(player.x() - (game_window.width() - 24), 128);
}
else if (player.x() - position.x < 24)
{
position.x = max(0, player.x() - 24);
}
if (player.y() - position.y >= game_window.height() - 24)
{
position.y = min(player.y() - (game_window.height() - 24), 64);
}
else if (player.y() - position.y < 24)
{
position.y = max(0, player.y() - 24);
}
return position - game_window.p1;
}
static void moveGameScreen()
{
NanoPoint position = calc_new_screen_position();
if (position != engine.getPosition())
{
engine.moveTo( position );
engine.refresh( game_window );
}
}
void movePlayer(uint8_t direction)
{
bool animated = false;
uint8_t bottomBlock = block_at(player.bottom());
uint8_t feetBlock = block_at(player.bottom() + (NanoPoint){0,1});
uint8_t handBlock = block_at(player.top());
uint8_t centerBlock = block_at(player.center());
uint8_t rightBlock = block_at(player.right());
uint8_t leftBlock = block_at(player.left());
moveGameScreen();
/* If player doesn't stand on the ground, and doesn't hold the pipe,
* make the player to fall down. */
if ( !isSolid(feetBlock) &&
(!isPipe(handBlock) || !isPipe(bottomBlock)) )
{
player.moveTo( { player.center().x & ~0x07, player.y() + 1 } );
player.setBitmap( &playerFlyingImage[MAN_ANIM_FLYING][playerAnimation][0] );
animated = true;
}
else
{
switch (direction)
{
case BUTTON_RIGHT:
if (isWalkable(rightBlock))
{
player.moveBy( { 1, 0 } );
if (isPipe(centerBlock))
player.setBitmap( &playerFlyingImage[MAN_ANIM_RIGHT_PIPE][playerAnimation][0] );
else
player.setBitmap( &playerFlyingImage[MAN_ANIM_RIGHT][playerAnimation][0] );
animated = true;
}
break;
case BUTTON_LEFT:
if (isWalkable(leftBlock))
{
player.moveBy( { -1, 0 } );
if (isPipe(centerBlock))
player.setBitmap( &playerFlyingImage[MAN_ANIM_LEFT_PIPE][playerAnimation][0] );
else
player.setBitmap( &playerFlyingImage[MAN_ANIM_LEFT][playerAnimation][0] );
animated = true;
}
break;
case BUTTON_UP:
if (isStair(bottomBlock) || isStair(centerBlock))
{
player.moveTo( { player.top().x & ~0x07, player.top().y - 1 } );
player.setBitmap( &playerFlyingImage[MAN_ANIM_UP][playerAnimation][0] );
animated = true;
}
break;
case BUTTON_DOWN:
if ( isStair(feetBlock) ||
(!isSolid(feetBlock) &&
isPipe(handBlock)) )
{
player.moveTo( { player.top().x & ~0x07, player.top().y + 1 } );
player.setBitmap( &playerFlyingImage[MAN_ANIM_DOWN][playerAnimation][0] );
animated = true;
}
break;
default:
break;
}
}
if (animated && ((uint16_t)(millis() - playerAnimationTs) > 150))
{
playerAnimationTs = millis();
playerAnimation = playerAnimation ? 0 : 1;
beep(10,20);
if (isGold(centerBlock))
{
engine.notify( "GOLD COIN" );
set_block_at(player.center(), 0);
goldCollection++;
showGameInfo();
engine.refresh(0,0,63,7);
/* Produce sound every time the player moves */
beep(20,40);
beep(20,80);
beep(20,120);
beep(20,80);
beep(20,40);
}
}
}
void setup()
{
ili9341_240x320_spi_init(3, 4, 5); // 3 RST, 4 CES, 5 DS
// ssd1306_128x64_i2c_init();
// pcd8544_84x48_spi_init(3, 4, 5); // 3 RST, 4 CES, 5 DS
// il9163_128x128_spi_init(3, 4, 5);
// st7735_128x160_spi_init(3, 4, 5);
// Commented line is for 90 degree
// ili9341_setRotation(1);
player.setBitmap( playerFlyingImage[MAN_ANIM_FLYING][playerAnimation] );
#ifdef USE_GPIO_BUTTONS
engine.connectGpioKeypad(g_buttonsPins);
#else
engine.connectZKeypad(BUTTON_PIN);
#endif
engine.drawCallback( onDraw );
engine.begin();
engine.setFrameRate(45);
engine.refresh();
pinMode(BUZZER, OUTPUT);
}
void loop()
{
if (!engine.nextFrame()) return;
movePlayer(engine.buttonsState());
ninja.move(player.getPosition());
engine.display();
}
void beep(int bCount,int bDelay)
{
for (int i = 0; i<=bCount*2; i++)
{
digitalWrite(BUZZER,i&1);
for(int i2=0; i2<bDelay; i2++)
{
__asm__("nop\n\t");
#if F_CPU > 8000000
__asm__("nop\n\t");
__asm__("nop\n\t");
__asm__("nop\n\t");
#endif
}
}
digitalWrite(BUZZER,LOW);
}

View File

@@ -0,0 +1,159 @@
/*
MIT License
Copyright (c) 2018, Alexey Dynda
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "ninja.h"
#include "sprites.h"
#include "intf/ssd1306_interface.h"
#include "intf/spi/ssd1306_spi.h"
Ninja ninja({72, 8});
void Ninja::move(const NanoPoint &target)
{
static uint16_t ninjaAnimationTs = 0;
static uint8_t ninjaAnimation = 0;
bool animated = false;
uint8_t direction = BUTTON_NONE;
uint8_t bottomBlock = block_at(bottom());
uint8_t feetBlock = block_at(bottom() + (NanoPoint){0,1});
uint8_t handBlock = block_at(top());
uint8_t centerBlock = block_at(center());
uint8_t rightBlock = block_at(right());
uint8_t leftBlock = block_at(left());
if ( !isSolid(feetBlock) &&
(!isPipe(handBlock) || !isPipe(bottomBlock)) )
{
moveTo( { center().x & ~0x07, m_pos.y + 1 } );
setBitmap( &playerFlyingImage[MAN_ANIM_FLYING][ninjaAnimation][0] );
animated = true;
}
else
{
if (target.y < m_pos.y - 1)
{
bool right = true;
bool left = true;
// search for stairs
for (int8_t i=0; i < 80; i=i+8)
{
if (right)
{
uint8_t block = block_at(center() + (NanoPoint){i,0});
if (!isWalkable(block)) { right = false; }
if (isStair(block)) { direction = BUTTON_RIGHT; break; }
}
if (left)
{
uint8_t block = block_at(center() - (NanoPoint){i,0});
if (!isWalkable(block)) { left = false; }
if (isStair(block)) { direction = BUTTON_LEFT; break; }
}
}
if (isStair(centerBlock) || isStair(bottomBlock)) direction = BUTTON_UP;
}
else if (target.y > m_pos.y + 1)
{
if (isPipe(handBlock))
{
direction = BUTTON_DOWN;
}
else
{
bool right = true;
bool left = true;
// search for stairs
for (int8_t i=0; i < 80; i=i+8)
{
if (right)
{
uint8_t block = block_at(center() + (NanoPoint){i,0});
if (!isWalkable(block)) right = false;
else
{
block = block_at(bottom() + (NanoPoint){i,1});
if (isWalkable(block)) { direction = BUTTON_RIGHT; break; }
}
}
if (left)
{
uint8_t block = block_at(center() - (NanoPoint){i,0});
if (!isWalkable(block)) left = false;
else
{
block = block_at(bottom() + (NanoPoint){-i,1});
if (isWalkable(block)) { direction = BUTTON_LEFT; break; }
}
}
}
if (isWalkable(feetBlock)) direction = BUTTON_DOWN;
}
}
else if (target.x > m_pos.x)
{
if (isWalkable(rightBlock)) direction = BUTTON_RIGHT;
}
else if (target.x < m_pos.x)
{
if (isWalkable(leftBlock)) direction = BUTTON_LEFT;
}
switch (direction)
{
case BUTTON_RIGHT:
moveBy( { 1, 0 } );
if (isPipe(centerBlock))
setBitmap( &playerFlyingImage[MAN_ANIM_RIGHT_PIPE][ninjaAnimation][0] );
else
setBitmap( &playerFlyingImage[MAN_ANIM_RIGHT][ninjaAnimation][0] );
animated = true;
break;
case BUTTON_LEFT:
moveBy( { -1, 0 } );
if (isPipe(centerBlock))
setBitmap( &playerFlyingImage[MAN_ANIM_LEFT_PIPE][ninjaAnimation][0] );
else
setBitmap( &playerFlyingImage[MAN_ANIM_LEFT][ninjaAnimation][0] );
animated = true;
break;
case BUTTON_UP:
moveTo( { top().x & ~0x07, top().y - 1 } );
setBitmap( &playerFlyingImage[MAN_ANIM_UP][ninjaAnimation][0] );
animated = true;
break;
case BUTTON_DOWN:
moveTo( { top().x & ~0x07, top().y + 1 } );
setBitmap( &playerFlyingImage[MAN_ANIM_DOWN][ninjaAnimation][0] );
animated = true;
break;
default:
break;
}
}
if (animated && ((uint16_t)(millis() - ninjaAnimationTs) > 150))
{
ninjaAnimationTs = millis();
ninjaAnimation = ninjaAnimation ? 0 : 1;
}
}

View File

@@ -0,0 +1,39 @@
/*
MIT License
Copyright (c) 2018, Alexey Dynda
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include "game_basic.h"
#include "sprites.h"
class Ninja: public NanoFixedSprite<GraphicsEngine, engine>
{
public:
explicit Ninja(NanoPoint pos)
: NanoFixedSprite<GraphicsEngine, engine>(pos, {8,8}, playerFlyingImage[0][0]) {}
void move(const NanoPoint &target);
};
extern Ninja ninja;

View File

@@ -0,0 +1,154 @@
/*
MIT License
Copyright (c) 2018, Alexey Dynda
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "sprites.h"
PROGMEM const uint8_t bgSprites[5][8] =
{
{
0B01110111,
0B01110111,
0B01110000,
0B01110111,
0B01110111,
0B00000111,
0B01110111,
0B01110111,
},
{
0B00010001,
0B11111111,
0B00010001,
0B00010001,
0B00010001,
0B11111111,
0B00010001,
0B00000000,
},
{
0B00000010,
0B00000010,
0B00000010,
0B00000010,
0B00000010,
0B00000010,
0B00000010,
0B00000010,
},
{
0B00000000,
0B11000000,
0B11100000,
0B10110000,
0B11010000,
0B10100000,
0B11000000,
0B00000000,
},
{
0B01111111,
0B01111111,
0B01111111,
0B01110111,
0B01111111,
0B01111111,
0B01111111,
0B00000000,
},
};
const PROGMEM uint8_t playerFlyingImage[MAN_ANIM_MAX][2][8] = {
{ // FLYING
{ 0x00, 0x04, 0x88, 0x4B, 0x3F, 0x48, 0x88, 0x04 },
{ 0x00, 0x10, 0x08, 0xCB, 0x3F, 0xC8, 0x08, 0x10 },
},
{ // UP + DOWN
{ 0x00, 0x00, 0x90, 0x4B, 0x3F, 0x28, 0x66, 0x00 },
{ 0x00, 0x00, 0x66, 0x2B, 0x3F, 0x48, 0x90, 0x00 },
},
{ // LEFT
{ 0x00, 0x10, 0x10, 0xCB, 0x3F, 0x48, 0x90, 0x00 },
{ 0x00, 0x00, 0x20, 0x1B, 0xFF, 0xD8, 0x00, 0x00 },
},
{ // RIGHT
{ 0x00, 0x90, 0x48, 0x3F, 0xCB, 0x10, 0x10, 0x00 },
{ 0x00, 0x00, 0xD8, 0xFF, 0x1B, 0x20, 0x00, 0x00 },
},
{ // RIGHT PIPE
{
0B00000110,
0B00001000,
0B00111110,
0B00110000,
0B00111000,
0B00110110,
0B00111000,
0B00111000,
},
{
0B00000000,
0B00000110,
0B00111000,
0B00110000,
0B00111110,
0B00110000,
0B00111000,
0B00111000,
},
},
{ // LEFT PIPE
{
0B00111000,
0B00111000,
0B00110110,
0B00111000,
0B00110000,
0B00111110,
0B00001000,
0B00000110,
},
{
0B00111000,
0B00111000,
0B00110000,
0B00111110,
0B00110000,
0B00111000,
0B00000110,
0B00000000,
},
},
};
const PROGMEM uint8_t coinImage[8] =
{
0B00000000,
0B00000000,
0B00111100,
0B01100110,
0B00111100,
0B00000000,
0B00000000,
0B00000000,
};

View File

@@ -0,0 +1,46 @@
/*
MIT License
Copyright (c) 2017-2018, Alexey Dynda
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include "ssd1306.h"
enum
{
MAN_ANIM_FLYING = 0,
MAN_ANIM_UP = 1,
MAN_ANIM_DOWN = 1,
MAN_ANIM_LEFT = 2,
MAN_ANIM_RIGHT = 3,
MAN_ANIM_RIGHT_PIPE = 4,
MAN_ANIM_LEFT_PIPE = 5,
MAN_ANIM_MAX = 6,
};
extern PROGMEM const uint8_t bgSprites[5][8];
extern const PROGMEM uint8_t playerFlyingImage[MAN_ANIM_MAX][2][8];
extern const PROGMEM uint8_t coinImage[8];