Jump to content
  • Advertisement

owenjr

Member
  • Content Count

    13
  • Joined

  • Last visited

Community Reputation

0 Neutral

1 Follower

About owenjr

  • Rank
    Member

Personal Information

  • Interests
    Art
    Design
    DevOps
    Production
    Programming

Social

  • Twitter
    edwardowen23
  • Github
    owenjr

Recent Profile Visitors

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

  1. Hi, I'm a Multimedia Engineering student. I am about to finish my dergree and I'm already thinking about what topic to cover in my final college project. I'm interested in the procedural animation with c++ and OpenGL of creatures, something like a spider for example. Can someone tell me what are the issues I should investigate to carry it out? I understand that it has some dependence on artificial intelligence but I do not know to what extent. Can someone help me to find information about it? Thank you very much. Examples: - Procedural multi-legged walking animation - Procedural Locomotion of Multi-Legged Characters in Dynamic Environments
  2. Hi there!I am trying to implement a basic AI for a Turrets game in SFML and C++ and I have some problems.This AI follows some waypoints stablished in a Bezier Courve. In first place, this path was followed only by one enemy. For this purpose, the enemy has to calculate his distance between his actual positionto the next waypoint he has to pick.If the distance is less than a specific value we stablish, then, we get to the next point. This will repeat until the final destination is reached. (in the submitting code, forget about the var m_go)Okay, our problem gets when we spawn several enemies and all have to follow the same path, because it produces a bad visual effect (everyone gets upside another).In order to solve this visual problem, we have decided to use a repulsion vector. The calculus gets like this: As you can see, we calculate the repulsion vector with the inverse of the distance between the enemy and his nearest neighbor.Then, we get it applying this to the "theorical" direction, by adding it, and we get a resultant, which is the direction thatour enemy has to follow to not "collide" with it's neighbors. But, our issue comes here: The enemys get sepparated in the middle of the curve and, as we spawn more enemys, the speed of all of them increases dramatically (including the enemies that don't calculate the repuslion vector).1 - Is it usual that this sepparation occours in the middle of the trajectory?2 - Is it there a way to control this direction without the speed getting affected?3 - Is it there any alternative to this theory?I submit the code below (There is a variable in Spanish [resultante] which it means resultant in English): if (!m_pathCompleted) { if (m_currentWP == 14 && m_cambio == true) { m_currentWP = 0; m_path = m_pathA; m_cambio = false; } if (m_neighbors.size() > 1) { for (int i = 0; i < m_neighbors.size(); i++) { if (m_enemyId != m_neighbors[i]->GetId()) { float l_nvx = m_neighbors[i]->GetSprite().getPosition().x - m_enemySprite.getPosition().x; float l_nvy = m_neighbors[i]->GetSprite().getPosition().y - m_enemySprite.getPosition().y; float distance = std::sqrt(l_nvx * l_nvx + l_nvy * l_nvy); if (distance < MINIMUM_NEIGHBOR_DISTANCE) { l_nvx *= -1; l_nvy *= -1; float l_vx = m_path[m_currentWP].x - m_enemySprite.getPosition().x; float l_vy = m_path[m_currentWP].y - m_enemySprite.getPosition().y; float l_resultanteX = l_nvx + l_vx; float l_resultanteY = l_nvy + l_vy; float l_waypointDistance = std::sqrt(l_resultanteX * l_resultanteX + l_resultanteY * l_resultanteY); if (l_waypointDistance < MINIMUM_WAYPOINT_DISTANCE) { if (m_currentWP == m_path.size() - 1) { std::cout << "\n"; std::cout << "[GAME OVER]" << std::endl; m_go = false; m_pathCompleted = true; } else { m_currentWP++; } } if (l_waypointDistance > MINIMUM_WAYPOINT_DISTANCE) { l_resultanteX = l_resultanteX / l_waypointDistance; l_resultanteY = l_resultanteY / l_waypointDistance; m_enemySprite.move(ENEMY_SPEED * l_resultanteX * dt, ENEMY_SPEED * l_resultanteY * dt); } } else { float vx = m_path[m_currentWP].x - m_enemySprite.getPosition().x; float vy = m_path[m_currentWP].y - m_enemySprite.getPosition().y; float len = std::sqrt(vx * vx + vy * vy); if (len < MINIMUM_WAYPOINT_DISTANCE) { if (m_currentWP == m_path.size() - 1) { std::cout << "\n"; std::cout << "[GAME OVER]" << std::endl; m_go = false; m_pathCompleted = true; } else { m_currentWP++; } } if (len > MINIMUM_WAYPOINT_DISTANCE) { vx = vx / len; vy = vy / len; m_enemySprite.move(ENEMY_SPEED * vx * dt, ENEMY_SPEED * vy * dt); } } } } } else { float vx = m_path[m_currentWP].x - m_enemySprite.getPosition().x; float vy = m_path[m_currentWP].y - m_enemySprite.getPosition().y; float len = std::sqrt(vx * vx + vy * vy); if (len < MINIMUM_WAYPOINT_DISTANCE) { if (m_currentWP == m_path.size() - 1) { std::cout << "\n"; std::cout << "[GAME OVER]" << std::endl; m_go = false; m_pathCompleted = true; } else { m_currentWP++; } } if (len > MINIMUM_WAYPOINT_DISTANCE) { vx = vx / len; vy = vy / len; m_enemySprite.move(ENEMY_SPEED * vx * dt, ENEMY_SPEED * vy * dt); } } } ¡¡Thank you very much in advance!!
  3. Hi, I want to know what are the basics of mathematics that I should know in depth to have a good level to start programming games of better quality. Which books could you recommend me?
  4. Wow, thank you for all this information. The kind of AI that I want is something like the Dungeon of the Endless's enemies, but in a randomly way. Just 3-4 spawns where the enemies comes from, and a point in the map which they have to destroy. Well-explained, we want the AI to arrive from its spawn to the target, randomly. Which can be the best algorithm that satisfies this purpose?
  5. Hi, I'm implementing a 2D turrets game with SFML and C++ for a college subject and I want a "unpredictable" IA path finding, not just enemies following a straight line. Our teacher has recommended us to implement a swarm algorithm or a A* to more advanced enemies. Is it there any good resource on how to implement them or another algorithm to be considered? Thanks for advanced!
  6. Thank you for your answer, finally I decided to implement this with a timer. It's easier for me considering that I'm still very noob in game dev hahaha.
  7. Hi, I'm building a SFML and c++ Galaga clone. I'm trying to limit the amount of bullets that the player can shoot. How can I implement this "fire rate"? I was thinking to use the sf::Clock to do this, but I don't know how to implement this logic. Can anyone explain it with a simple example with one rectangle or something like this? Thank you.
  8. WOW, I'm so stupid, sorry for that. Thanks a lot.
  9. Here's the code, thank you. void Batalla::HandleInput() { sf::Event event; while (this->m_data->m_window.pollEvent(event)) { if (sf::Event::Closed == event.type || sf::Keyboard::isKeyPressed(sf::Keyboard::Q)) { this->m_data->m_window.close(); } if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) { m_PlayerIsMoving = true; m_playerDirection = -1; if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space)) { m_isFiring = true; } } else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) { m_PlayerIsMoving = true; m_playerDirection = 1; if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space)) { m_isFiring = true; } } else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space)) { m_isFiring = true; } } }
  10. Hi, I'm building a SFML and c++ Galaga clone. I'm trying to move the ship in a continuous way, but I can't understand why mi ship still moving like "pixel by pixel". I've readed that use deltatime to do this is a good practice. This is the code that I used for it: Game::Run(), where I calculate my deltatime: void Game::Run() { float newTime, frameTime, interpolation; float currentTime = this->m_clock.getElapsedTime().asSeconds(); float accumulator = 0.0f; while (this->m_data->m_window.isOpen()) { this->m_data->m_machine.ProcessStateChanges(); newTime = this->m_clock.getElapsedTime().asSeconds(); frameTime = newTime - currentTime; if (frameTime > 0.25f) { frameTime = 0.25f; } currentTime = newTime; accumulator += frameTime; while (accumulator >= m_dt) { this->m_data->m_machine.GetActiveState()->HandleInput(); this->m_data->m_machine.GetActiveState()->Update(m_dt); accumulator -= m_dt; } interpolation = accumulator / m_dt; this->m_data->m_machine.GetActiveState()->Draw(interpolation); } } void Batalla::HandleInput () ("Batalla" is a state of the game) void Batalla::HandleInput() { sf::Event event; while (this->m_data->m_window.pollEvent(event)) { if (sf::Event::Closed == event.type || sf::Keyboard::isKeyPressed(sf::Keyboard::Q)) { this->m_data->m_window.close(); } if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) { m_PlayerIsMoving = true; m_playerDirection = -1; if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space)) { m_isFiring = true; } } else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) { m_PlayerIsMoving = true; m_playerDirection = 1; if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space)) { m_isFiring = true; } } else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space)) { m_isFiring = true; } } } void Batalla:Update(float dt) void Batalla::Update(float dt) { if (m_PlayerIsMoving) { m_player->Move(dt, m_playerDirection); m_playerDirection = 0; m_PlayerIsMoving = false; } if (m_isFiring) { Bullet * l_newBullet = new Bullet(m_data, sf::Vector2f(m_player->GetSprite().getPosition().x, m_player->GetSprite().getPosition().y)); m_bulletVector.push_back(l_newBullet); m_isFiring = false; } for (int i = 0; i < m_bulletVector.size(); i++) { m_bulletVector.at(i)->Move(dt); } } void Batalla::Draw(float dt) void Batalla::Draw(float dt) { this->m_data->m_window.clear(sf::Color::Black); this->m_data->m_window.draw(this->m_background); m_player->Draw(); for (int i = 0; i < m_bulletVector.size(); i++) { m_bulletVector.at(i)->Draw(); } this->m_data->m_window.display(); } void Player::Move(float l_dt, int l_playerDirection) (moves the player's ship) void Player::Move(float l_dt, int l_playerDirection) { m_playerSprite.move((SHIP_SPEED * l_dt * l_playerDirection), 0); } Can anyone help please help me? Thank you.
  11. Hi, I'm building a SFML and c++ Galaga clone. I've created a Player class that represents the ship and I've implemented the basic mechanics of movement and shooting. But I have a problem, I can't shoot and move the ship at the same time. What is the best way to solve it? Thank you.
  12. Hi, I'm building a Galaga game clone in c ++ and SFML. I have built a Player class, which manages the movement of the ship and a bullet class, which is what I use to create bullet-type objects and shoot them from the ship. At this point, I have a doubt, when the bullets do not hit any enemy and exceed the screen, should I erase them from memory? I'm beginner in game development, I'm sorry if my question is too trivial.
  13. Hi there. I'm pretty new to this and I don't know if it has been asked before, but here I go. I'm developing a game using SFML and C++. I would like to use the "Tiled" tool to load maps into my game but I don't actually find any tutorial or guide on how to exaclty use it (I know that I have to read an XML file and stuff). I just step into diverse projects that make all a mess. Anyone knows where can I find good information to make my map loader by myself? Thanks in advantage!!
  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!