목록TextRpg (4)
오븐 노트
Creature ㄴ Creature.cpp #include "Creature.h" void Creature::OnAttacked(Creature* attacker) { int damage = attacker->_attack - _defence; if (damage < 0) damage = 0; _hp -= damage; if (_hp < 0) _hp = 0; } Creature ㄴ Creature.h #pragma once enum CreatureType { CT_PLAYER = 0, CT_MONSTER = 1 }; class Creature { public: Creature(int creatureType) : _creatureType(creatureType), _hp(0), _attack(0), _de..
#include using namespace std; // main // - EnterLobby (PlayerInfo) // -- CreatePlayer // -- EnterGame (MonsterInfo) // --- CreateMonsters // --- EnterBattle enum PlayerType { PT_Knight = 1, PT_Archer = 2, PT_Mage = 3, }; enum MonsterType { MT_Slime = 1, MT_Orc = 2, MT_Skeleton = 3, }; struct StatInfo { int hp = 0; int attack = 0; int defence = 0; }; void EnterLobby(); void PrintMessage(const cha..
#include using namespace std; enum playerType { PT_Knight = 1, PT_Archer = 2, PT_Mage = 3, }; enum MonsterType { MT_Slime = 1, MT_Orc = 2, MT_Skeleton = 3, }; struct ObjectInfo { int type; int hp; int attack; int defence; }; // 구조체 멤버의 타입이 각기 다른 경우 padding 값이 할당되어 정렬됨 ObjectInfo playerInfo; ObjectInfo monsterInfo; void EnterLobby(); void SelectPlayer(); void EnterField(); void CreateRandomMonste..
#include using namespace std; enum playerType { PT_Knight = 1, PT_Archer = 2, PT_Mage = 3, }; enum MonsterType { MT_Slime = 1, MT_Orc = 2, MT_Skeleton = 3, }; int playerType; int hp; int attack; int defance; int monsterType; int monsterHp; int monsterAttack; int monsterDefence; void EnterLobby(); void SelectPlayer(); void EnterField(); void CreateRandomMonster(); int main() { // 랜덤 시드 설정 srand(t..