기술

[SFML]The Baby :: Horror maze game

ORANGEBOY 2020. 7. 10. 12:47

 Game introduction.


Ÿ Title of the game: The Baby :: Horror maze game

Ÿ Development Environment: Windows 10 64bit, Visual Studio 2019, SFML-2.5.1

Ÿ Planning Intention: Ever since I came to fear from the pressure of time,

Ÿ Genre: Horror game

Ÿ Differentiation Elements : View Shader Adjustment

Ÿ Game Manipulation: keyboard (UI moved by W, A, S, D direction key & LShift)



<----------  DOWNLOAD GAME : https://bit.ly/3gDs6gi  ---------->

<---------- DOWNLOAD DEVELOPMENT FILEhttps://github.com/Flowver/TheBaby   ---------->






Why baby? It's more cruel when innocent.






Why Maze? Fear comes from ignorance.











 Description of how the game is designed.


2.1. Starting screen


When running, the Start / How to Play / Quit button is displayed. 

1. Tap Start to start the Game


The first player to start the game is offered three lives and five sprint gauges.  ♥♥



Life is given only 3 chances in one game. No more. (You can start with MAX by restarting the game.) 

The Sprint gauge is automatically filled when not in use and can be used with 'Direction(W,A,S,D)+LShift'.









2.2. Playing games


There is no time limit and with the start of the game you are destined to be chased. 

All you have to do is explore the maze and find a portal. 



Find the portal and free the maze-bound player. 

Otherwise, a giant baby will appear and kill you. 

The baby is slightly slower than you but has special abilities. 

They can cross the walls of the maze without restriction. 

Please take that into consideration and think about whether you want to go back to your path. But that won't make any difference. :D





Oh, that's right. So there's one thing you can use. It's a magic marker that can light up a dark map. The magic marker is always in the same place. If you run into the magic marker, you can see the map a little brighter for five seconds! Maybe!

Then please continue to explore!




2.3. Gaming Ending


Game over if you lose three lives ♥♥

If you find the portal, you win the game.





2.4. Starting screen


When you come back to the main screen after playing a game, you can check the main screen that has changed. (The baby will look different.)









 Description of how OOP is applied to game development.





3.1

Entity is the parent class of the player, enemy, portal, and potion, and is applied to the child class in duplicate.

The child classes individually set required variables, designators, accessors, functions, and so on.



<individual list>

void Player::sprint()

const bool Player::isDead() const

void Enemy::chase(Entity &entity)

initAnimations() - Rect size



void Player::sprint() { if (this->getAttributeComponent()->sprint > 0 && sf::Keyboard::isKeyPressed(sf::Keyboard::LShift)) { sprinting = true; this->setmaxVelocity(600.f); loseSprint(0.05f); //decrease sprint timer towards 0 } else { sprinting = false; //sprint timer is equal or less than 0 change move speed to walking pace this->setmaxVelocity(200.f); gainSprint(0.02f); } }





3.2



Switch syntax is applied according to IDLE, ACTIVE, and HOVER, which are button states.


void gui::Button::update(const sf::Vector2i& mousePosWindow) { /*Update the booleans for hover and pressed*/ //Idle this->buttonState = BTN_IDLE; //Hover if (this->shape.getGlobalBounds().contains(static_cast<sf::Vector2f>(mousePosWindow))) { this->buttonState = BTN_HOVER; //Pressed if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) { this->buttonState = BTN_ACTIVE; } } switch (this->buttonState) { case BTN_IDLE: this->shape.setFillColor(this->idleColor); this->text.setFillColor(this->textIdleColor); this->shape.setOutlineColor(this->outlineIdleColor); break; case BTN_HOVER: this->shape.setFillColor(this->hoverColor); this->text.setFillColor(this->textHoverColor); this->shape.setOutlineColor(this->outlineHoverColor); break; case BTN_ACTIVE: this->shape.setFillColor(this->activeColor); this->text.setFillColor(this->textActiveColor); this->shape.setOutlineColor(this->outlineActiveColor); break; default: this->shape.setFillColor(sf::Color::Red); this->text.setFillColor(sf::Color::Blue); this->shape.setOutlineColor(sf::Color::Green); break; } }





3.3


The part responsible for the skeleton of the whole code. Several variables have been defined in advance.

The stdafx.h is a header that compiles several commonly used headers at once in advance so that they can be rewritten without recompiled later on.







3.4



"this" pointer was used a lot, as seen in other codes. This pointer points to the object on which the function is executed. The purpose of this pointer is to inform the object that is calling the function.


void TileMap::updateTiles(Entity* entity, const float& dt) { //TILES this->layer = 0; this->fromX = entity->getGridPosition(this->gridSizeI).x - 15; if (this->fromX < 0) this->fromX = 0; else if (this->fromX > this->maxSizeWorldGrid.x) this->fromX = this->maxSizeWorldGrid.x; this->toX = entity->getGridPosition(this->gridSizeI).x + 16; if (this->toX < 0) this->toX = 0; else if (this->toX > this->maxSizeWorldGrid.x) this->toX = this->maxSizeWorldGrid.x; this->fromY = entity->getGridPosition(this->gridSizeI).y - 8; if (this->fromY < 0) this->fromY = 0; else if (this->fromY > this->maxSizeWorldGrid.y) this->fromY = this->maxSizeWorldGrid.y; this->toY = entity->getGridPosition(this->gridSizeI).y + 9; if (this->toY < 0) this->toY = 0; else if (this->toY > this->maxSizeWorldGrid.y) this->toY = this->maxSizeWorldGrid.y; for (int x = this->fromX; x < this->toX; x++) { for (int y = this->fromY; y < this->toY; y++) { for (size_t k = 0; k < this->map[x][y][this->layer].size(); k++) { //Update the tile this->map[x][y][this->layer][k]->update(); } } } }






3.5


All the things in each child relationship of entity were dynamically allocated as operators 'new' and 'delete'. Therefore, in the case of enemies, memory is allocated as much as the enemy is continuously generated.


A dynamic array was naturally defined as a dynamic allocation. Enemies and potion (=magic marker) were called as vectors.




    
void GameState::updateSpawn() {

	//Spawning
	this->spawnTimer += 1.5f;
	if (this->spawnTimer >= this->spawnTimerMax)
	{
		this->enemies.push_back(new Enemy(1911, 2019, this->textures["ENEMY_SHEET"]));
		this->spawnTimer = 0.f;
	}
}





3.6



The above multiple object oriendered programming has been applied in duplicate.












 Screen capture images for game play.










 Movies for game play




<----------  DOWNLOAD GAME : https://bit.ly/3gDs6gi  ---------->

<---------- DOWNLOAD DEVELOPMENT FILE : https://github.com/Flowver/TheBaby   ---------->






 + Update



7/10 - ENEMY HITBOX ADJUSTMENT: Towards the baby's foot

 

 

 

Preference

 

 

https://github.com/Headturna/SFML_RPG

'기술' 카테고리의 다른 글

Unity DAY1  (0) 2020.07.13
06/04 Lighting Tech. Composition  (0) 2020.06.04
06/02 Lighting Tech. Light  (0) 2020.06.02