-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMario.cpp
More file actions
107 lines (94 loc) · 1.91 KB
/
Mario.cpp
File metadata and controls
107 lines (94 loc) · 1.91 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//
// Created by Thomas Kim on 9/18/22.
//
#include "Mario.h"
#include <string>
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
using namespace std;
Mario::Mario() {
marioHealth = 0;
marioPowerLevel = 0;
marioCoins = 0;
}
Mario::Mario(int health, int powerLevel, int coins) {
marioHealth = health;
marioPowerLevel = powerLevel;
marioCoins = coins;
}
Mario::~Mario() {}
void Mario::CoinInteraction() {
marioCoins += 1;
}
void Mario::setCoins(int coins) {
marioCoins = coins;
}
void Mario::setHealth(int health) {
marioHealth = health;
}
void Mario::setPowerLevel(int powerLevel) {
marioPowerLevel = powerLevel;
}
int Mario::getCoins() {
return marioCoins;
}
int Mario::getHealth() {
return marioCoins;
}
int Mario::getPowerLevel() {
return marioPowerLevel;
}
int Mario::Movement() {
int num = rand() % 4;
return num;
}
bool Mario::goombaInteraction() {
int num = rand()% 100 + 1;
if(num > 80){
if(marioPowerLevel > 0){
marioPowerLevel -= 1;
return false;
}
else{
marioHealth -= 1;
return false;
}
}
return true;
}
bool Mario::koopaInteraction() {
int num = rand() % 100 + 1;
if(num > 65){
if(marioPowerLevel > 0){
marioPowerLevel -= 1;
return false;
}
else{
marioHealth -= 1;
return false;
}
}
return true;
}
int Mario::mushroomInteraction() {
marioPowerLevel += 1;
return marioPowerLevel;
}
bool Mario::bossInteraction() {
while(marioHealth > 0){
int num = rand() % 2;
if(num == 0){
if(marioPowerLevel > 0){
marioPowerLevel -=2;
return false;
}
else{
marioHealth -=1;
return false;
}
}
}
return true;
}