diff --git a/C++/scripts/md5 b/C++/scripts/md5 index 3e77b3f..7cf8083 100644 --- a/C++/scripts/md5 +++ b/C++/scripts/md5 @@ -1,3 +1,3 @@ build.sh:530634457ea9041267c05d4ced95eee1 - commit.sh:d03a46e721060c22ccb146e19d27e70a - -web.sh:241ce74055952325f82f009b494df250 - +web.sh:3dcc2fe7e036359eedd257a864e9a1e1 - diff --git a/C++ProjectTemplate b/C++ProjectTemplate index dc59e7a..9d73bb6 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/main.cpp b/main.cpp index 05849a6..4141020 100644 --- a/main.cpp +++ b/main.cpp @@ -9,28 +9,56 @@ public: Example() { sAppName = "Example"; + } public: + vector data; + int TILE_WIDTH=16; + int TILE_HEIGHT=16; + + int tileOffsetX=0; + int tileOffsetY=0; + int TV_WIDTH=TILE_WIDTH*8; + int TV_HEIGHT=TILE_HEIGHT*7; + int MAP_WIDTH=256; + int MAP_HEIGHT=240; + + int TV_POSX=256/4; + int TV_POSY=240/4; bool OnUserCreate() override { SetPixelMode(olc::Pixel::ALPHA); ConsoleCaptureStdOut(true); // Called once at the start, so create things here - for (int x = 0; x < ScreenWidth(); x++) - for (int y = 0; y < ScreenHeight(); y++) - Draw(x, y, olc::Pixel(rand() % 255, rand() % 255, rand()% 255)); - for (int x=0;x<50;x++) { - for (int y=0;y<50;y++) { - Draw(x, y, olc::Pixel(255, 0, 0, 128)); - } + for (int i=0;i<256*240;i++) { + data.push_back(rand()%255); } return true; } bool OnUserUpdate(float fElapsedTime) override { - // called once per frame + + if (GetKey(olc::RIGHT).bPressed) { + tileOffsetX=std::clamp(tileOffsetX+1,0,MAP_WIDTH); + } + if (GetKey(olc::LEFT).bPressed) { + tileOffsetX=std::clamp(tileOffsetX-1,0,MAP_WIDTH); + } + if (GetKey(olc::UP).bPressed) { + tileOffsetY=std::clamp(tileOffsetY-1,0,MAP_HEIGHT); + } + if (GetKey(olc::DOWN).bPressed) { + tileOffsetY=std::clamp(tileOffsetY+1,0,MAP_HEIGHT); + } + for (int x=0;x