본문 바로가기
프로그래밍/C 언어(코딩)

C언어] RPG게임만들기-1 (플레이어 설정)

by 곰나나 2024. 1. 1.

[RPG게임만들기]

RPG게임만들기 플레이어 만들기.

1. 플레이어 정보 (HP, MP, 물리공격력,마법공격력, 힘, 민첩, 행운, 마력, 방어력, 저항력, 스피드,크리티컬)

물리 공격력 = (기본 1) + (힘*3)/10.0

마법 공격력 = (기본 0.5) + (마력*2)/8.0

힘 = (기본 10)

민첩 = (기본  10)

행운 = (기본  10)

마력 = (기본  5)

방어력 = (기본  5)+(힘/15)

저항력 = (기본  3)+(마력/20)

스피드 = (기본  1)*(민첩/5)

크리티컬 = (기본  0)*(행운/2)

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <stdio.h>
 
//& 플레이어 구조체 정의
typedef struct {
    //& 멤버 변수(플레이어 정보 설정)
    int HP;
    int MP;
    double physicalAttack;
    double magicalAttack;
    int strength;
    int agility;
    int luck;
    int magicPower;
    double defense;
    double resistance;
    double speed;
    double critical;
} Player;
 
//& 속성 계산 함수
void calculateAttributes(Player* player) 
{
    //& 물리 공격력 = (기본 1)+(힘 * 3) / 10.0
    player->physicalAttack = (1)+(player->strength * 3/ 10.0;
 
    // 마법 공격력 = (기본0.5)+(마력 * 2) / 8.0
    player->magicalAttack = (0.5)+(player->magicPower * 2/ 8.0;
 
    // 방어력 = 5 + (힘 / 15)
    player->defense = 5 + (player->strength / 15.0);
 
    // 저항력 = 3 + (마력 / 20)
    player->resistance = 3 + (player->magicPower / 20.0);
 
    // 스피드 = 1 * (민첩 / 5)
    player->speed = 1 * (player->agility / 5.0);
 
    // 크리티컬 = 0 * (행운 / 2)
    player->critical = 0 * (player->luck / 2.0);
}
 
int main() 
{
    //& 플레이어 구조체 생성
    Player player;
 
    //& 기본 속성 초기화
    player.HP = 100;
    player.MP = 50;
    player.strength = 10;
    player.agility = 10;
    player.luck = 10;
    player.magicPower = 5;
 
    //& 속성 계산
    calculateAttributes(&player);
 
    //& 속성 출력
    printf("[플레이어 능력치 정보] \n");
    printf("물리 공격력: %lf\n", player.physicalAttack);
    printf("마법 공격력: %lf\n", player.magicalAttack);
    printf("방어력: %lf\n", player.defense);
    printf("저항력: %lf\n", player.resistance);
    printf("스피드: %lf\n", player.speed);
    printf("크리티컬: %lf\n", player.critical);
 
    return 0;
}//main
cs

728x90