Jump to content
  • Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

495 Neutral

1 Follower

About povilaslt2

  • Rank

Personal Information

  • Role
  • Interests


  • Github

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Probably will try to do this challenge if I learn how to do that path finding. How you will do your path finding for this challenge?
  2. povilaslt2

    October 2017 GameDev Challenge: Arcade Battle Arena!

    Probably will try to do this challenge if I learn how to do that path finding. How you will do your path finding for this challenge?
  3. Hello, I'm trying to implement enemy pathfinding algorihtm, but i have problem with empty tile collision when moving enemy to node. For example this image shows how it should move like shown in example: But it stucks at last tile: It happens because enemy collides with right side of "air" tile and then it removes from node list because it "collided", but it works with not "air" tiles of course. How do fix this problem? Code: void Enemy::generateMoveToNode(AStar::Vec2i lastNode) { auto lastSave = AStar::Vec2i{ 0.0f, 0.0f }; while (!target.empty()) { if (target.back().y == lastNode.y) { lastSave = target.back(); target.pop_back(); } else { moveToNodes.push_back(lastSave); moveToNodes.push_back(target.back()); generateMoveToNode(target.back()); return; } } moveToNodes.push_back(lastSave); } void Enemy::updateTarget(std::shared_ptr<InputManager> inputManager) { if (moveToNodes.empty()) return; // Calculate half sizes. float halfWidthA = getSize(0) / 2.0f; float halfHeightA = getSize(1) / 2.0f; float halfWidthB = 32.0f / 2.0f; float halfHeightB = 32.0f / 2.0f; // Calculate centers. auto centerA = glm::vec2(getPosition(0) + halfWidthA, getPosition(1) + halfHeightA); auto centerB = glm::vec2((moveToNodes.front().x * 32.0f) + halfWidthB, (moveToNodes.front().y * 32.0f) + halfHeightB); // Calculate current and minimum-non-intersecting distances between centers. float distanceX = centerA.x - centerB.x; float distanceY = centerA.y - centerB.y; float minDistanceX = halfWidthA + halfWidthB; float minDistanceY = halfHeightA + halfHeightB; setKey(inputManager->getKeyBinding("Move Left"), false); setKey(inputManager->getKeyBinding("Move Right"), false); setKey(inputManager->getKeyBinding("Jump"), false); setKey(inputManager->getKeyBinding("Duck"), false); // If we are not intersecting at all, return (0, 0). if (abs(distanceX) >= minDistanceX || abs(distanceY) >= minDistanceY) { if (moveToNodes.front().y > ceil(getPosition(1) / 32.0f)) setKey(inputManager->getKeyBinding("Jump"), true); else if (moveToNodes.front().y < ceil(getPosition(1) / 32.0f)) { if (getCanClimb()) setKey(inputManager->getKeyBinding("Duck"), true); } else { if (moveToNodes.front().x < ceil(getPosition(0) / 32.0f)) setKey(inputManager->getKeyBinding("Move Left"), true); else if (moveToNodes.front().x > floor(getPosition(0) / 32.0f)) setKey(inputManager->getKeyBinding("Move Right"), true); } updateInput(inputManager); return; } // Calculate and return intersection depths. float depthX = distanceX > 0 ? minDistanceX - distanceX : -minDistanceX - distanceX; float depthY = distanceY > 0 ? minDistanceY - distanceY : -minDistanceY - distanceY; updateInput(inputManager); moveToNodes.erase(moveToNodes.begin()); } generateMoveToNode: recursive function to generate all nodes. updateTarget: updates enemy every frame to check if it hits node and then removes it from list and checks next till no nodes left.
  4. povilaslt2


  5. povilaslt2


  6. povilaslt2

    Looking for project

    Have some SDL experience, created few programs using WinSock2 on windows.
  7. povilaslt2

    Looking for project

    Hello. I'm Programmer who is in search of 2D game project who preferably uses OpenGL and C++. You can see my projects in GitHub. Project genre doesn't matter (except MMO's :D).
  8. povilaslt2

    Question about Observer pattern

    I mean I don't want to put this code in render function. I want to do like callback or etc. Now I added std::function(lamda) as OnDeath function to every enemy and call it at destructor. Function is checking if enemy list has 1 item in it and then call what I need. Just IDK if it's correct usage.
  9. Hello, I have a question about Observer pattern. I have Application class that has lists of objects, enemies and etc and I want to notify Observer when enemies list JUST got empty. How do I do that? Do I extend std::vector's erase function? Application has render method that draws and updates application. Also this method deletes items from vectors if they are dead or etc.
  10. Dunno. Application have everything, enemies, player, UI, Font. So it would be way easier to add delete/objects, apply different font, change texture. Because otherwise i need to add a lot of arguments to a lot of functions to do the same.
  11. I mean instead of referencing TextureManager object in game object constructor I would reference Application object which is shown in first post for more flexibility.
  12. One more question. Can I just add whole Application object reference when creating an object? Because I will need it to create object on collision for example and even more.
  13. Hello, i'm currently developing spaceshooter game and I encountered few problems with game code design. I have Application class where all managers are. class Application { public: ~Application(); Application(); void addShader(const std::string&, std::shared_ptr<Shader>); void loadTexture(const std::string&, const std::string&, int, int, glm::vec2); std::shared_ptr<Texture> getTexture(const std::string&); inline std::shared_ptr<Font> getFont(const std::string& name) { return fontManager->getFont(name); } void loadFont(const std::string&, const std::string&); inline GameState getState() const { return gameState; } inline void setState(GameState state) { gameState = state; } inline std::shared_ptr<InputManager> getInputManager() const { return inputManager; } inline std::shared_ptr<Renderer> getRender() const { return renderer; } private: std::shared_ptr<Renderer> renderer; std::shared_ptr<TextureManager> textureManager; std::shared_ptr<InputManager> inputManager; GameState gameState; std::shared_ptr<FontManager> fontManager; }; But problem is that I need to access in example TextureManager class somewhere in "OnCollision" method to change texture of collider. How do I do that? Do I create TextureManager singleton or what?
  14. Ye but what if all enemies and player have use Base class which has bullets vector? Then I need to check player to enemies and enemies to player because of bullets?
  15. Hello. I'm trying to make dynamic collision detection system. In example: automatically adjust collision detection when new vector of objects added and etc. Now I have few vectors and I'm trying to do collision by just passing vector/object as parameter in "CheckCollision" function. player->Update(application, dt); if (player->CheckCollision(&enemies)) { InitScene(); application->SetState(GameState::NOTSTARTEDYET); UI["Pause Menu"]->HideAllElements(); UI["Options"]->HideAllElements(); UI["Main Menu"]->ShowAllElements(); } for (auto enemy : enemies) { enemy->Update(dt, t); if (enemy->CheckCollision(player)) { InitScene(); application->SetState(GameState::NOTSTARTEDYET); UI["Pause Menu"]->HideAllElements(); UI["Options"]->HideAllElements(); UI["Main Menu"]->ShowAllElements(); } } Can I somehow change this code to make code more dynamic when I add more vectors with enemies.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!