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
a95aa518
Commit
a95aa518
authored
Apr 22, 2021
by
ewen.madec
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes mouse hover nodes + edges color + choose nb of dice when attack
parent
48238969
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
141 additions
and
37 deletions
+141
-37
controlpanel.c
src/controlpanel.c
+4
-4
graphical-aspect.c
src/graphical-aspect.c
+123
-26
graphical-aspect.h
src/graphical-aspect.h
+3
-1
main-viewer.c
src/main-viewer.c
+8
-3
player.c
src/player.c
+2
-2
player.h
src/player.h
+1
-1
No files found.
src/controlpanel.c
View file @
a95aa518
...
...
@@ -32,8 +32,8 @@ void Panel_initialize(Panel * self, NetWorld * world, const int screenWidth, con
self
->
world
=
world
;
self
->
camera
.
x
=
0
.
f
;
self
->
camera
.
y
=
0
.
f
;
self
->
screenCenter
.
x
=
400
.
f
;
self
->
screenCenter
.
y
=
300
.
f
;
self
->
screenCenter
.
x
=
screenWidth
/
2
;
self
->
screenCenter
.
y
=
screenHeight
/
2
;
self
->
scale
=
10
.
f
;
//pixel per meters
self
->
screenWidth
=
screenWidth
;
self
->
screenHeight
=
screenHeight
;
...
...
@@ -66,7 +66,7 @@ void Panel_drawMainMenu(Panel * self, Main_Menu * menu){
// Rendering
void
Panel_drawGame
(
Panel
*
self
)
{
BeginDrawing
();
//
BeginDrawing();
ClearBackground
(
RAYWHITE
);
// Draw the edges for each nodes:
...
...
@@ -83,7 +83,7 @@ void Panel_drawGame(Panel * self)
Panel_drawNode
(
self
,
&
(
self
->
world
->
nodes
[
i
])
);
}
//Panel_drawBasis(self);
EndDrawing
();
//
EndDrawing();
}
void
Panel_drawBasis
(
Panel
*
self
)
...
...
src/graphical-aspect.c
View file @
a95aa518
This diff is collapsed.
Click to expand it.
src/graphical-aspect.h
View file @
a95aa518
...
...
@@ -17,7 +17,9 @@ Rectangle Graphic_ConfirmButton(Font font);
void
Graphic_MouseHoverNodeRecrutement
(
Player
*
self
,
Vector2
mousePosition
,
Panel
*
panel
);
void
Graphic_MouseHoverNodeChooseAttacker
(
Player
*
player
,
Vector2
mousePosition
,
Panel
*
panel
);
void
Graphic_MouseHoverNodeChooseTarget
(
Node
*
originNode
,
Vector2
mousePosition
,
Panel
*
panel
);
void
diceRolling
();
void
Graphic_RectuementBeginTurn
(
int
screenWidth
,
int
screenHeight
,
Font
font
);
int
Graphic_ChooseNumberOfAttackers
(
Player
*
attacker
,
Player
*
defender
,
Node
*
originNode
,
Node
*
targetNode
,
Font
font
);
void
diceRolling
(
Player
*
attacker
,
Player
*
defender
,
Node
*
originNode
,
Node
*
targetNode
,
int
nbOfAttackers
,
Font
font
);
...
...
src/main-viewer.c
View file @
a95aa518
...
...
@@ -50,6 +50,7 @@ int main(int nbArg, char ** arg)
for
(
int
index
=
0
;
index
<
world
->
size
;
index
++
){
Player_add_Node
(
&
(
players
[
index
%
playerCount
]),
&
(
world
->
nodes
[
index
]));
}
// Raylib Initialization
//----------------------
InitWindow
(
screenWidth
,
screenHeight
,
"NetWorld basic viewer"
);
...
...
@@ -82,7 +83,9 @@ int main(int nbArg, char ** arg)
}
break
;
case
game_ui
:
BeginDrawing
();
game_update
(
world
,
players
,
font
,
panel
);
EndDrawing
();
default:
break
;
}
...
...
@@ -107,7 +110,7 @@ void game_update(NetWorld * world, Player * players, Font font, Panel * panel)
Graphic_ShowPlayerInfo
(
currentPlayer
,
screenWidth
,
screenHeight
,
font
);
Graphic_WhoseTurnIsIt
(
currentPlayer
,
screenWidth
,
screenHeight
,
font
);
int
playerCount
=
world
->
playerCount
;
Player
*
newPlayers
=
malloc
(
sizeof
(
Player
));
//
Player * newPlayers = malloc(sizeof(Player));
switch
(
currentPlayer
->
turnPhase
){
case
recruitment
:
...
...
@@ -155,8 +158,10 @@ void game_update(NetWorld * world, Player * players, Font font, Panel * panel)
}
else
if
(
Node_are_connected
(
originNode
,
currentNode
)
&&
(
originNode
->
soldiers
>
1
)
&&
originNode
->
canAttack
){
printf
(
"Engagine attack on target Node
\n
"
);
Player_attack_Node
(
currentPlayer
,
&
(
players
[
nodePlayerID
]),
originNode
,
currentNode
);
diceRolling
();
int
nbOfAttackers
=
Graphic_ChooseNumberOfAttackers
(
currentPlayer
,
&
(
players
[
nodePlayerID
]),
originNode
,
currentNode
,
font
);
Player_attack_Node
(
currentPlayer
,
&
(
players
[
nodePlayerID
]),
originNode
,
currentNode
,
nbOfAttackers
);
//diceRolling(currentPlayer, &(players[nodePlayerID]), originNode, currentNode, nbOfAttackers ,font);
}
else
{
printf
(
"Failed to attack target : Origin has already attacked, nodes aren't connected or origin node has too few soldiers
\n
"
);
}
...
...
src/player.c
View file @
a95aa518
...
...
@@ -155,8 +155,8 @@ void Player_confirm_recrutement(Player * self){
};
void
Player_attack_Node
(
Player
*
self
,
Player
*
defender
,
Node
*
originNode
,
Node
*
targetNode
){
int
attackersCount
=
fmin
(
3
,
(
originNode
->
soldiers
-
1
))
;
void
Player_attack_Node
(
Player
*
self
,
Player
*
defender
,
Node
*
originNode
,
Node
*
targetNode
,
int
numberOfAttackers
){
int
attackersCount
=
numberOfAttackers
;
int
defendersCount
=
targetNode
->
soldiers
>=
3
?
2
:
1
;
int
attDiceRolls
[
attackersCount
];
int
defDiceRolls
[
defendersCount
];
...
...
src/player.h
View file @
a95aa518
...
...
@@ -87,7 +87,7 @@ void Player_select_Node(Player * self, Vector2 mousePos);
void
Player_unselect_Node
(
Player
*
self
,
Vector2
mousePos
);
void
Player_attack_Node
(
Player
*
self
,
Player
*
defender
,
Node
*
originNode
,
Node
*
targetNode
);
void
Player_attack_Node
(
Player
*
self
,
Player
*
defender
,
Node
*
originNode
,
Node
*
targetNode
,
int
numberOfAttackers
);
void
Player_confirm_recrutement
(
Player
*
self
);
...
...
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