diff --git a/demo1.cpp b/demo1.cpp index 9659c10..11181e9 100644 --- a/demo1.cpp +++ b/demo1.cpp @@ -638,11 +638,10 @@ inline void pixelFunc(PixelInfo pixel) rgbToIndex(intensity/2,intensity,intensity/3) : rgbToIndex(intensity,intensity/2,0); - uint8_t *buf = pokitto.display.screenbuffer; buf += pixel.position.x * SUBSAMPLE; - buf += pixel.position.y * pokitto.display.width; + buf += pixel.position.y * SCREEN_WIDTH; for (uint8_t i = 0; i < SUBSAMPLE - 1; ++i) *buf++ = c; @@ -699,8 +698,7 @@ bool runReleased = false; int main() { - pokitto.begin(); - initPalette(); + initGeneral(); player.setPositionSquare(4,5); @@ -708,10 +706,6 @@ int main() sprites[1] = Sprite(sprite1,14,5,1,100); sprites[2] = Sprite(sprite2,15,19,1,200); - pokitto.display.persistence = 1; - pokitto.setFrameRate(FPS); - pokitto.display.setFont(fontTiny); - uint32_t previousTime = 0; uint32_t dt; diff --git a/general.hpp b/general.hpp index 43d62c0..2aed030 100644 --- a/general.hpp +++ b/general.hpp @@ -223,4 +223,17 @@ public: Unit mPixelSize; }; +void initGeneral() +{ + pokitto.begin(); + pokitto.setFrameRate(FPS); + pokitto.display.setFont(fontTiny); + pokitto.display.persistence = 1; + + initPalette(); + + for (uint8_t i = 0; i < SUBSAMPLED_WIDTH; ++i) + zBuffer[i] = 0; +} + #endif