Game Overview
Gemu Namae is a 2D platformer made for Ludum Dare 36 with the theme, "Ancient Technology". I decided to use C++ with SFML in order to challenge myself and push my learning some more. The aim of the game is to decend into the depths and avoid taking damage from the enemies that throw ancient daggers at you. As the player you can block shots and kill enemies with the whip.What went well?
What can be improved?
Block and Enemy spawn:
A code sample that deals with block spawning and enemy spawning by setting their position on a grid and then pushes them to a vector.void Game::Setup() { for (int x = 0; x < SOLID_WIDTH; x++) { for (int y = 0; y < SOLID_HEIGHT; y++) { block_sprite[x][y].setTexture(block_texture); if (SpawnSolidBlock() == true) { //set block_sprite pos to a 32x32 grid block_sprite[x][y].setPosition(x * 32, 32 + (y * 64)); block_vector.push_back(block_sprite[x][y]); if (SpawnEnemyOnBlock() == true) { //spawn enemy on block if there is a solid block and bool == true e1 = new Enemy("img/enemy1.png"); e1->set_pos(x * 32, block_sprite[x][y].getPosition().y - e1->getHeight()); enemyVector.push_back(e1); } } } } }
Object collision:
A code sample that deals with removing objects from the game when collision occurs. Below is the code used specifically for erasing the enemy and daggers.for (enemyiter = enemyVector.begin(); enemyiter != enemyVector.end(); enemyiter++) { //whip collision with enemy if (whip_sprite.getGlobalBounds().intersects((*enemyiter)->getSprite().getGlobalBounds())) { player.addScore(10); enemyVector.erase(enemyiter); break; } for ((*enemyiter)->dagger_iter = (*enemyiter)->dagger_vector.begin(); (*enemyiter)->dagger_iter != (*enemyiter)->dagger_vector.end(); (*enemyiter)->dagger_iter++) { //whip collision with dagger if (whip_sprite.getGlobalBounds().intersects((*enemyiter)->dagger_iter->getGlobalBounds())) { player.addScore(1); (*enemyiter)->dagger_vector.erase((*enemyiter)->dagger_iter); break; } //dagger collision with player if ((*enemyiter)->dagger_iter->getGlobalBounds().intersects(player_sprite.getGlobalBounds())) { player.takeDmg(1); (*enemyiter)->dagger_vector.erase((*enemyiter)->dagger_iter); break; } } }