Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
NetWorld
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LAIRD Timothy
NetWorld
Commits
5ffbb499
Commit
5ffbb499
authored
Apr 30, 2021
by
Timothy LAIRD
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more fixes
parent
d4d8145e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
17 additions
and
37 deletions
+17
-37
controlpanel.c
src/controlpanel.c
+2
-4
graphical-aspect.c
src/graphical-aspect.c
+8
-8
main-viewer.c
src/main-viewer.c
+3
-5
mission.c
src/mission.c
+1
-2
networld.c
src/networld.c
+0
-6
networld.h
src/networld.h
+0
-8
player.c
src/player.c
+3
-4
No files found.
src/controlpanel.c
View file @
5ffbb499
...
...
@@ -94,7 +94,6 @@ void Panel_drawRules(Panel * self, Main_Menu * rules){
UnloadFont
(
font
);
EndDrawing
();
}
void
Panel_drawWin
(
Panel
*
self
,
Player
*
player
,
Mission
*
mission
){
BeginDrawing
();
Font
font
=
GetFontDefault
();
...
...
@@ -102,8 +101,7 @@ void Panel_drawWin(Panel * self, Player * player, Mission * mission){
DrawText
(
"VICTORY"
,
(
self
->
screenWidth
*
35
)
/
100
,
(
self
->
screenHeight
*
15
)
/
100
,
(
self
->
screenWidth
*
5
)
/
100
,
BLACK
);
char
*
victoryText
=
malloc
(
sizeof
(
char
)
*
100
);
sprintf
(
victoryText
,
"Player %d has completed their mission and won the game
\n
Their mission was : "
,
player
->
ID
);
strcat
(
victoryText
,
mission
->
displayText
);
sprintf
(
victoryText
,
"%s has completed their mission and won the game
\n
Their mission was : %s"
,
player
->
name
,
mission
->
displayText
);
DrawText
(
victoryText
,
(
self
->
screenWidth
*
20
)
/
100
,
(
self
->
screenHeight
*
45
)
/
100
,
(
self
->
screenWidth
*
2
)
/
100
,
BLACK
);
free
(
victoryText
);
...
...
@@ -153,7 +151,7 @@ void Panel_drawNode(Panel * self, Node * n)
DrawCircleV
(
screenPosition
,
24
,
n
->
color
);
DrawCircleV
(
screenPosition
,
20
,
RAYWHITE
);
char
*
soldierText
=
malloc
(
20
*
sizeof
(
char
));
sprintf
(
soldierText
,
"%d"
,
n
->
soldiers
+
n
->
soldiersToAdd
);
sprintf
(
soldierText
,
"%d"
,
n
->
soldiers
);
DrawText
(
soldierText
,
(
int
)
screenPosition
.
x
-
MeasureText
(
soldierText
,
20
)
/
2
,
(
int
)
screenPosition
.
y
,
20
,
n
->
color
);
free
(
soldierText
);
}
...
...
src/graphical-aspect.c
View file @
5ffbb499
...
...
@@ -17,7 +17,7 @@ void Graphic_ShowPlayerInfo(Player *player, int screenWidth, int screenHeight, F
Rectangle
rec
=
{
0
,
screenHeight
-
250
,
250
,
250
};
//Draw current player number on the bottom left
DrawRectangleLinesEx
(
rec
,
10
,
player
->
color
);
char
*
playerNumber
=
malloc
(
20
*
sizeof
(
char
));
sprintf
(
playerNumber
,
"
Player %d"
,
player
->
ID
);
sprintf
(
playerNumber
,
"
%s"
,
player
->
name
);
DrawTextEx
(
*
font
,
playerNumber
,
(
Vector2
){
35
,
screenHeight
-
240
},
30
.
0
,
3
.
0
,
player
->
color
);
char
*
soldierNumber
=
malloc
(
40
*
sizeof
(
char
));
//Draw current player number of soldiers
...
...
@@ -65,7 +65,7 @@ void Graphic_AttackPhase(Player *player, int screenWidth, int screenHeight, Font
void
Graphic_WhoseTurnIsIt
(
Player
*
player
,
int
screenWidth
,
int
screenHeight
,
Font
*
font
)
{
char
*
whoseTurn
=
malloc
(
20
*
sizeof
(
char
));
//Display whose turn is it
sprintf
(
whoseTurn
,
"
Player %d Turn"
,
player
->
ID
);
sprintf
(
whoseTurn
,
"
%ss Turn"
,
player
->
name
);
DrawTextEx
(
*
font
,
whoseTurn
,
(
Vector2
){
screenWidth
/
2
-
(
MeasureTextEx
(
*
font
,
whoseTurn
,
50
.
0
,
3
.
0
).
x
)
/
2
,
30
},
50
.
0
,
3
.
0
,
player
->
color
);
free
(
whoseTurn
);
}
...
...
@@ -143,14 +143,14 @@ int Graphic_ChooseNumberOfAttackers(Player *attacker, Player *defender, Node *or
SetTargetFPS
(
60
);
//Display rectangles to choose how many soldiers/dices you want to engage in the fight
Rectangle
nbAttackerRectangle
[
10
];
for
(
int
i
=
0
;
i
<
originNode
->
soldiers
ToAdd
+
originNode
->
soldiers
;
i
++
)
for
(
int
i
=
0
;
i
<
originNode
->
soldiers
;
i
++
)
{
nbAttackerRectangle
[
i
]
=
(
Rectangle
){
200
+
(
i
-
1
)
*
250
,
screenHeight
-
500
,
150
,
70
};
}
char
whoseTurnToAttack
[
20
];
sprintf
(
whoseTurnToAttack
,
"
Player %d attacks "
,
attacker
->
ID
);
sprintf
(
whoseTurnToAttack
,
"
%s attacks "
,
attacker
->
name
);
char
whoseTurnToDefend
[
20
];
sprintf
(
whoseTurnToDefend
,
"
Player %d"
,
defender
->
ID
);
sprintf
(
whoseTurnToDefend
,
"
%s"
,
defender
->
name
);
while
(
!
endAnimation
)
{
...
...
@@ -162,7 +162,7 @@ int Graphic_ChooseNumberOfAttackers(Player *attacker, Player *defender, Node *or
DrawTextEx
(
*
font
,
whoseTurnToDefend
,
(
Vector2
){
screenWidth
/
2
+
100
,
70
},
50
.
0
,
3
.
0
,
defender
->
color
);
DrawText
(
"How many dices do you want to involve in the fight ?"
,
screenWidth
/
2
-
(
MeasureTextEx
(
*
font
,
"How many dice do you want to involve in the fight ?"
,
30
.
0
,
3
.
0
).
x
)
/
2
+
50
,
150
,
30
,
attacker
->
color
);
for
(
int
i
=
1
;
i
<
originNode
->
soldiers
ToAdd
+
originNode
->
soldiers
;
i
++
)
for
(
int
i
=
1
;
i
<
originNode
->
soldiers
;
i
++
)
{
DrawRectangleRec
(
nbAttackerRectangle
[
i
],
BLACK
);
char
str_i
[
5
];
...
...
@@ -197,9 +197,9 @@ void Graphic_diceRolling(Player *attacker, Player *defender, Node *originNode, N
int
defendersCount
=
nbOfDefenders
;
int
attackersCount
=
nbOfAttackers
;
char
*
whoseTurnToAttack
=
malloc
(
20
*
sizeof
(
char
));
sprintf
(
whoseTurnToAttack
,
"
Player %d "
,
attacker
->
ID
);
sprintf
(
whoseTurnToAttack
,
"
%s "
,
attacker
->
name
);
char
*
whoseTurnToDefend
=
malloc
(
20
*
sizeof
(
char
));
sprintf
(
whoseTurnToDefend
,
"
Player %d "
,
defender
->
ID
);
sprintf
(
whoseTurnToDefend
,
"
%s "
,
defender
->
name
);
Rectangle
skipAnimation
=
{
screenWidth
/
2
-
125
,
200
,
190
,
50
};
Rectangle
skipResult
=
{
screenWidth
/
2
-
105
,
200
,
150
,
50
};
...
...
src/main-viewer.c
View file @
5ffbb499
...
...
@@ -273,11 +273,9 @@ int game_update(NetWorld * world, Player * players, Mission * missions, Font* fo
break
;
case
init
:
//Check on missions
for
(
int
i
=
0
;
i
<
world
->
playerCount
;
i
++
){
if
(
Mission_check
(
&
missions
[
i
],
world
,
players
)){
world
->
hasWinner
=
true
;
winner
=
i
;
}
if
(
Mission_check
(
&
missions
[
currentPlayer
->
ID
],
world
,
players
)){
world
->
hasWinner
=
true
;
winner
=
currentPlayer
->
ID
;
}
//Switch turns
Player_end_turn
(
currentPlayer
);
...
...
src/mission.c
View file @
5ffbb499
...
...
@@ -30,8 +30,7 @@ void Mission_init(Mission * self, const int playerID, NetWorld * world, Player *
while
(
self
->
target
==
self
->
playerID
){
self
->
target
=
rand
()
%
world
->
playerCount
;
}
sprintf
(
displayText
,
"Eliminate Player "
);
strcat
(
displayText
,
(
players
[
self
->
target
].
name
));
sprintf
(
displayText
,
"Eliminate %s"
,
players
[
self
->
target
].
name
);
self
->
displayText
=
displayText
;
break
;
}
...
...
src/networld.c
View file @
5ffbb499
...
...
@@ -16,7 +16,6 @@ void Node_construct(Node * self)
self
->
card
=
0
;
self
->
edges
=
Edge_newArray
(
0
);
self
->
soldiers
=
1
;
self
->
soldiersToAdd
=
0
;
self
->
playerID
=
-
1
;
Rectangle
tmp
=
{
0
,
0
,
48
,
48
};
self
->
collisionHitbox
=
tmp
;
...
...
@@ -115,11 +114,6 @@ int Node_biconnect( Node * node1, Node * node2 )
return
i1
;
}
void
Node_confirm_placement
(
Node
*
self
){
self
->
soldiers
+=
self
->
soldiersToAdd
;
self
->
soldiersToAdd
=
0
;
}
bool
Node_are_connected
(
Node
*
self
,
Node
*
target
){
for
(
int
index
=
0
;
index
<
self
->
card
;
index
++
){
Edge
currentEdge
=
self
->
edges
[
index
];
...
...
src/networld.h
View file @
5ffbb499
...
...
@@ -20,8 +20,6 @@ struct Str_Node {
// Content:
//! Number of soldiers at the node
int
soldiers
;
//! Buffer variable to stop players from removing soldiers from their nodes
int
soldiersToAdd
;
//! Player the node belongs to
int
playerID
;
//! Click hitbox for the node
...
...
@@ -132,12 +130,6 @@ int Node_biconnect(
Node
*
node2
);
/**
* @brief Confirm the allocation of new soldiers
* @param self The node to confirm placement in
*/
void
Node_confirm_placement
(
Node
*
self
);
/**
* @brief Text if 2 nodes are connected
* @param self The origin node
...
...
src/player.c
View file @
5ffbb499
...
...
@@ -102,7 +102,7 @@ void Player_add_soldier(Player * self, Vector2 * mousePos){
for
(
int
nodeIndex
=
0
;
nodeIndex
<
self
->
nodeCount
;
nodeIndex
++
){
Node
*
currentNode
=
self
->
nodes
[
nodeIndex
];
if
(
CheckCollisionPointRec
(
*
mousePos
,
currentNode
->
collisionHitbox
)){
currentNode
->
soldiers
ToAdd
++
;
currentNode
->
soldiers
++
;
self
->
soldiers
--
;
break
;
}
...
...
@@ -113,8 +113,8 @@ void Player_remove_soldier(Player * self, Vector2 * mousePos){
for
(
int
nodeIndex
=
0
;
nodeIndex
<
self
->
nodeCount
;
nodeIndex
++
){
Node
*
currentNode
=
self
->
nodes
[
nodeIndex
];
if
(
CheckCollisionPointRec
(
*
mousePos
,
currentNode
->
collisionHitbox
)
&&
currentNode
->
soldiers
>
0
){
if
(
currentNode
->
soldiers
ToAdd
>
0
){
currentNode
->
soldiers
ToAdd
--
;
if
(
currentNode
->
soldiers
>
1
){
currentNode
->
soldiers
--
;
self
->
soldiers
++
;
}
break
;
...
...
@@ -146,7 +146,6 @@ void Player_unselect_Node(Player * self, Vector2 * mousePos){
void
Player_confirm_recrutement
(
Player
*
self
){
for
(
int
nodeIndex
=
0
;
nodeIndex
<
self
->
nodeCount
;
nodeIndex
++
){
Node_confirm_placement
(
self
->
nodes
[
nodeIndex
]);
self
->
nodes
[
nodeIndex
]
->
canAttack
=
true
;
}
};
...
...
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