setup complete - visible character
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
#include "world.h"
|
||||
|
||||
World::World(const char* file, glm::vec2 blockSize) {
|
||||
// load from file
|
||||
this -> blocksize = blockSize;
|
||||
unsigned int tileCode;
|
||||
std::string line;
|
||||
std::ifstream fstream(file);
|
||||
if (fstream)
|
||||
{
|
||||
while (std::getline(fstream, line)) // read each line from level file
|
||||
{
|
||||
std::istringstream sstream(line);
|
||||
std::vector<unsigned int> row;
|
||||
while (sstream >> tileCode) // read each word seperated by spaces
|
||||
row.push_back(tileCode);
|
||||
this->tileData.push_back(row);
|
||||
}
|
||||
for (int y = 0; y < this->tileData.size(); y++) {
|
||||
for (int x = 0; x < this->tileData[0].size(); x++) {
|
||||
if (this->tileData[y][x]) {
|
||||
this->objects.push_back(new Object(this->Sprite, glm::vec2(0.0f + blocksize.x * (float)x, 0.0f + blocksize.y * (float)y), blocksize, this->tileData[y][x]));
|
||||
//std::cout << this->tileData[y][x];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void World::drawWorld(SpriteRenderer& renderer) {
|
||||
for (int i = 0; i < this->objects.size(); i++) {
|
||||
this->objects[i]->drawObject(renderer);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
#include "../Object.h"
|
||||
|
||||
class World
|
||||
{
|
||||
public:
|
||||
Texture Sprite = ResourceManager::LoadTexture("art/terrain/dirt.png", "dirtSheet");
|
||||
glm::vec2 blocksize;
|
||||
std::vector<Object*> objects;
|
||||
std::vector<std::vector<unsigned int>> tileData;
|
||||
|
||||
World(const char* file, glm::vec2 blockSize);
|
||||
~World();
|
||||
|
||||
void drawWorld(SpriteRenderer& renderer);
|
||||
};
|
||||
Reference in New Issue
Block a user