Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "TileImportObj.h"
- TileImportObj::TileImportObj()
- {
- spriteSet(0)->load();
- activeSet = 0;
- x = minX;
- tSetS = "";
- for (int i = 0; i < TILESET; i++)
- {
- for (int j = 0; j < TILE; j++)
- {
- tileID[i][j] = 0;
- }
- }
- }
- TileImportObj::~TileImportObj()
- {
- }
- void TileImportObj::getTiles()
- {
- showingX = 6;
- if (tilesY < 7)
- amountX = tilesX;
- else
- amountX = tilesX * 2;
- spots = amountX - 6;
- X2 = 0;
- minX = 1920 - 512 + 128 + 48;
- maxX = 1920 - 96;
- }
- void TileImportObj::draw()
- {
- drawRectangle(1920 - 64 * 6, 0, 64 * 6, 1080, .9, .9, .9, 1);
- if (activeSet != 0)
- {
- for (int i = 0; i < tilesY; i++)
- {
- for (int j = 0; j < tilesX; j++)
- {
- if (i < 6)
- drawSpritePart(getSprite(activeSet, 0), 1536 + j * 64 - X2, 696 + i * 64, 64, 64, 1 / tilesX * j, 1 / tilesY * i, 1 / tilesX * (j + 1), 1 / tilesY * (i + 1));
- else
- drawSpritePart(getSprite(activeSet, 0), 1536 + tilesX * 64 + j * 64 - X2, 696 + (i - 6) * 64, 64, 64, 1 / tilesX * j, 1 / tilesY * i, 1 / tilesX * (j + 1), 1 / tilesY * (i + 1));
- }
- }
- drawSprite(getSprite(0, 0), 1920 - 512 + 128, 1080 - 512 + 128 - 48, 48, 48);
- drawSpritePart(getSprite(0, 0), 1920 - 48, 1080 - 512 + 128 - 48, 48, 48, 1, 0, 0, 1);
- drawSprite(getSprite(0, 1), x, 1080 - 512 + 128 - 48, 48, 48);
- }
- if (loadSet)
- {
- this->setDepth(-2);
- drawRectangle(10, 10, 1900, 1060, .8, .8, .8, 1);
- drawTextCenter(getFont(0, 0), "What title set do you want to load?", getCameraWidth() / 2, 20, 20, 0, 0, 0, 1);
- drawRectangle(getCameraWidth() / 2 - 50, 50, 100, 75, .7, .7, .7, 1);
- drawTextCenter(getFont(0, 0), tSetS, getCameraWidth() / 2, 65, 40, 0, 0, 0, 1);
- }
- else
- this->setDepth(0);
- }
- void TileImportObj::run()
- {
- if (activeSet == 0)
- loadSet = true;
- if (loadSet)
- {
- actiontag->disableRun();
- if (tSetS.length() < 2)
- {
- if (getKeyPress(Key::Num0) || getKeyPress(Key::Num1) || getKeyPress(Key::Num2) || getKeyPress(Key::Num3) || getKeyPress(Key::Num4) || getKeyPress(Key::Num5) || getKeyPress(Key::Num6) || getKeyPress(Key::Num7) || getKeyPress(Key::Num8) || getKeyPress(Key::Num9))
- keyboardTextBuffer(&tSetS);
- }
- if (getKeyPress(Key::BackSpace))
- keyboardTextBuffer(&tSetS);
- else if (tSetS.length() > 0 && getKeyPress(Key::Return))
- {
- activeSet = atoi(tSetS.c_str());
- tSetS = "";
- if (spriteSet(activeSet) != NULL && activeSet != 0)
- {
- setTileset();
- }
- }
- }
- if (spots > 1 && !loadSet)
- {
- if (getMousePress(0))
- {
- if (inside(getMouseX(), getMouseY(), 1920 - 512 + 128, 1080 - 512 + 128 - 48, 1920 - 512 + 128 + 48, 1080 - 512 + 128))
- {
- if (showingX < 7)
- showingX = 6;
- else
- {
- showingX -= 1;
- pos = (1826 - 1588) / spots;
- x -= pos;
- X2 -= 64;
- }
- }
- if (inside(getMouseX(), getMouseY(), 1920 - 48, 1080 - 512 + 128 - 48, 1920, 1080 - 512 + 128))
- {
- if (showingX >= amountX)
- showingX = amountX;
- else
- {
- showingX += 1;
- pos = (1826 - 1588) / spots;
- x += pos;
- X2 += 64;
- }
- }
- x = (x < minX ? minX : (x > maxX ? maxX : x));
- }
- }
- }
- void TileImportObj::setTags(Tag *t, Tag *t2)
- {
- actiontag = t2;
- mytag = t;
- }
- void TileImportObj::setTileset()
- {
- if (spriteSet(activeSet)->isLoaded() == false)
- spriteSet(activeSet)->load();
- tilesX = getSprite(activeSet, 0)->getWidth() / 32;
- tilesY = getSprite(activeSet, 0)->getHeight() / 32;
- getTiles();
- std::cout << "Loading set " << activeSet << std::endl;
- actiontag->enableRun();
- loadSet = false;
- for (int i = 0; i < (tilesX * tilesY) + 1; i++)
- {
- tileID[activeSet][i] = i; //0 should be null
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement