Jump to content

ErhanK

Members
  • Posts

    64
  • Joined

  • Last visited

Everything posted by ErhanK

  1. Hi. I want to load the player entity position from an object in the editor. It works very well but; I want to spawn in the center of the scene when there is no object named "info_player_start". When I remove the comment lines, it always spawns at the center of the scene. I don't understand why. Here is my code... #include "Game.h" Game::Game() { loadMap(); loadEntities(); player = new Player(playerStartPosition); } Game::~Game() { delete player; } void Game::loadMap() { std::string mapname = System::GetProperty("map", "Maps/start.map"); if (!Map::Load(mapname)) Debug::Error("Failed to load map \"" + mapname + "\"."); } void Game::loadEntities() { for (const auto e : World::GetCurrent()->entities) { if (e->GetKeyValue("name") == "info_player_start") { playerStartPosition = e->GetPosition(); } /*else { playerStartPosition = Vec3(0.0f, 0.0f, 0.0f); }*/ } } void Game::Update() { player->Update(); }
  2. Really? Ok thank you. I'll try
  3. Hi, I have a question. How can I use "PostRender" in c++ for drawing a rectangle like this lua script? I did but, screen is flickering. I think this is must be in PostRender --This function will be called after the world is rendered, before the screen is refreshed. --Use this to perform any 2D drawing you want the entity to display. function Script:PostRender(context) local window = context:GetWindow() context:SetBlendMode(Blend.Alpha) --draw selection rectangle if ( self.beginSelectPos ~= nil and self.endSelectPos ~= nil ) then context:SetColor(1,0,0,0.5) context:DrawRect(self.beginSelectPos.x, self.beginSelectPos.y, self.endSelectPos.x-self.beginSelectPos.x, self.endSelectPos.y-self.beginSelectPos.y) context:SetColor(0,0,0,0) end
  4. Hello, I created a C++ project and I have "Game" class and "Player" class..App class is creating game class.Game class is creating Player class and player class is creating camera etc.. How i can access or reference context or window class in the player class? For example : i want to call window->GetMousePosition() in the player class.
×
×
  • Create New...