Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
krkane
/
Rüütli Vaev
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
1
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
eeb8e691
authored
May 01, 2024
by
grlabu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace main.c
parent
89ae5fee
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
158 deletions
Source/main.c
Source/main.c
View file @
eeb8e691
#include "Header.h"
#include "bossdefeated.h"
#include <stdio.h>
#include "ui_bossdefeated.h"
#include <stdlib.h>
#include <time.h>
int
main
(
void
)
#include <QApplication>
{
#include <QDebug>
srand
(
time
(
NULL
));
PrintWelcomeMessage
();
int
selection
;
char
*
saveFile
=
"GameSave.txt"
;
while
(
1
)
{
selection
=
Menu
();
switch
(
selection
)
{
case
1
:
{
int
gameState
=
1
;
Player
player
=
CreatePlayer
();
int
defeatedEnemies
=
0
;
while
(
gameState
==
1
)
{
int
moveResult
=
Move
(
defeatedEnemies
);
if
(
moveResult
==
LOSE_HP
)
{
// Player encountered a trap
handleTrap
(
&
player
);
continue
;
// Restart the loop, allowing the player to choose the path again
}
if
(
moveResult
==
SAVE_GAME
)
{
SaveGame
(
saveFile
,
&
player
,
defeatedEnemies
);
return
EXIT_SUCCESS
;
}
else
if
(
moveResult
==
0
)
{
gameState
=
0
;
}
else
if
(
moveResult
==
1
)
{
if
(
defeatedEnemies
<
NUM_HENCHMEN
)
{
Enemy
enemy
=
CreateEnemy
(
defeatedEnemies
);
printf
(
"
\n
Kohtasid vastast tüübiga %s, %dHP ja rünnaku tugevusega"
" %d.
\n
"
,
enemy
.
type
,
enemy
.
health
,
enemy
.
attack
);
gameState
=
fight
(
&
player
,
&
enemy
);
}
else
{
// Generate the final boss
FinalBoss
boss
=
CreateFinalBoss
(
defeatedEnemies
);
printf
(
"
\n
Oled jõudmas koopa lõppu ning "
"äkitselt märkasid pealikku %s, %dHP ja"
" rünnaku tugevusega"
" %d.
\n
"
,
boss
.
type
,
boss
.
health
,
boss
.
attack
);
gameState
=
bossFight
(
&
player
,
&
boss
);
}
if
(
gameState
==
0
)
{
return
EXIT_SUCCESS
;
}
if
(
gameState
==
SAVE_GAME
)
{
SaveGame
(
saveFile
,
&
player
,
defeatedEnemies
);
return
EXIT_SUCCESS
;
}
defeatedEnemies
++
;
levelUp
(
&
player
);
}
}
break
;
}
case
2
:
DisplayGameRules
();
break
;
case
3
:
{
int
gameState
=
1
;
Player
player
;
int
defeatedEnemies
;
LoadGame
(
saveFile
,
&
player
,
&
defeatedEnemies
);
while
(
gameState
==
1
)
{
int
moveResult
=
Move
(
defeatedEnemies
);
if
(
moveResult
==
LOSE_HP
)
{
// Player encountered a trap
handleTrap
(
&
player
);
continue
;
// Restart the loop, allowing the player to choose the path again
}
if
(
moveResult
==
SAVE_GAME
)
BossDefeated
::
BossDefeated
(
QWidget
*
parent
)
{
:
QDialog
(
parent
)
SaveGame
(
saveFile
,
&
player
,
defeatedEnemies
);
,
ui
(
new
Ui
::
BossDefeated
)
return
EXIT_SUCCESS
;
{
}
qDebug
()
<<
"boss defeated"
;
ui
->
setupUi
(
this
);
else
if
(
moveResult
==
0
)
}
{
gameState
=
0
;
}
else
if
(
moveResult
==
1
)
{
if
(
defeatedEnemies
<
NUM_HENCHMEN
)
{
Enemy
enemy
=
CreateEnemy
(
defeatedEnemies
);
printf
(
"
\n
Kohtasid vastast tüübiga %s, %dHP ja rünnaku tugevusega"
" %d.
\n
"
,
enemy
.
type
,
enemy
.
health
,
enemy
.
attack
);
gameState
=
fight
(
&
player
,
&
enemy
);
}
else
{
// Generate the final boss
FinalBoss
boss
=
CreateFinalBoss
(
defeatedEnemies
);
printf
(
"
\n
Oled jõudmas koopa lõppu ning "
"äkitselt märkasid pealikku %s, %dHP ja"
" rünnaku tugevusega"
" %d.
\n
"
,
boss
.
type
,
boss
.
health
,
boss
.
attack
);
gameState
=
bossFight
(
&
player
,
&
boss
);
}
if
(
gameState
==
0
)
{
return
EXIT_SUCCESS
;
}
if
(
gameState
==
SAVE_GAME
)
{
SaveGame
(
saveFile
,
&
player
,
defeatedEnemies
);
return
EXIT_SUCCESS
;
}
defeatedEnemies
++
;
levelUp
(
&
player
);
}
}
break
;
}
case
0
:
BossDefeated
::~
BossDefeated
()
printf
(
"VÄLJUN...
\n\n
"
);
{
return
EXIT_SUCCESS
;
delete
ui
;
}
}
}
return
0
;
void
BossDefeated
::
on_pushButton_2_clicked
()
{
qApp
->
exit
(
0
);
}
}
void
BossDefeated
::
on_pushButton_clicked
()
{
qApp
->
exit
(
0
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment