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
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
...
@@ -32,8 +32,8 @@ void Panel_initialize(Panel * self, NetWorld * world, const int screenWidth, con
self
->
world
=
world
;
self
->
world
=
world
;
self
->
camera
.
x
=
0
.
f
;
self
->
camera
.
x
=
0
.
f
;
self
->
camera
.
y
=
0
.
f
;
self
->
camera
.
y
=
0
.
f
;
self
->
screenCenter
.
x
=
400
.
f
;
self
->
screenCenter
.
x
=
screenWidth
/
2
;
self
->
screenCenter
.
y
=
300
.
f
;
self
->
screenCenter
.
y
=
screenHeight
/
2
;
self
->
scale
=
10
.
f
;
//pixel per meters
self
->
scale
=
10
.
f
;
//pixel per meters
self
->
screenWidth
=
screenWidth
;
self
->
screenWidth
=
screenWidth
;
self
->
screenHeight
=
screenHeight
;
self
->
screenHeight
=
screenHeight
;
...
@@ -66,7 +66,7 @@ void Panel_drawMainMenu(Panel * self, Main_Menu * menu){
...
@@ -66,7 +66,7 @@ void Panel_drawMainMenu(Panel * self, Main_Menu * menu){
// Rendering
// Rendering
void
Panel_drawGame
(
Panel
*
self
)
void
Panel_drawGame
(
Panel
*
self
)
{
{
BeginDrawing
();
//
BeginDrawing();
ClearBackground
(
RAYWHITE
);
ClearBackground
(
RAYWHITE
);
// Draw the edges for each nodes:
// Draw the edges for each nodes:
...
@@ -83,7 +83,7 @@ void Panel_drawGame(Panel * self)
...
@@ -83,7 +83,7 @@ void Panel_drawGame(Panel * self)
Panel_drawNode
(
self
,
&
(
self
->
world
->
nodes
[
i
])
);
Panel_drawNode
(
self
,
&
(
self
->
world
->
nodes
[
i
])
);
}
}
//Panel_drawBasis(self);
//Panel_drawBasis(self);
EndDrawing
();
//
EndDrawing();
}
}
void
Panel_drawBasis
(
Panel
*
self
)
void
Panel_drawBasis
(
Panel
*
self
)
...
...
src/graphical-aspect.c
View file @
a95aa518
...
@@ -87,8 +87,8 @@ void Graphic_MouseHoverNodeRecrutement(Player * player, Vector2 mousePosition, P
...
@@ -87,8 +87,8 @@ void Graphic_MouseHoverNodeRecrutement(Player * player, Vector2 mousePosition, P
Node
*
currentNode
=
player
->
nodes
[
nodeIndex
];
Node
*
currentNode
=
player
->
nodes
[
nodeIndex
];
if
(
CheckCollisionPointRec
(
mousePosition
,
currentNode
->
collisionHitbox
)){
if
(
CheckCollisionPointRec
(
mousePosition
,
currentNode
->
collisionHitbox
)){
//printf("collision noeud !\n");
//printf("collision noeud !\n");
Vector2
screenPosition
=
Panel_pixelFromPosition
(
panel
,
&
(
currentNode
->
position
)
);
Vector2
screenPosition
=
Panel_pixelFromPosition
(
panel
,
&
(
currentNode
->
position
)
);
Draw
CircleV
(
screenPosition
,
29
,
MAGENTA
);
Draw
Ring
(
screenPosition
,
24
.
0
,
28
.
0
,
0
.
0
,
360
.
0
,
0
.
1
,
MAGENTA
);
//DrawCircleV(screenPosition, 45, RAYWHITE);
//DrawCircleV(screenPosition, 45, RAYWHITE);
if
(
player
->
soldiers
>
0
){
if
(
player
->
soldiers
>
0
){
DrawText
(
"+1"
,
(
int
)
screenPosition
.
x
+
30
,
(
int
)
screenPosition
.
y
,
20
,
MAGENTA
);
DrawText
(
"+1"
,
(
int
)
screenPosition
.
x
+
30
,
(
int
)
screenPosition
.
y
,
20
,
MAGENTA
);
...
@@ -103,7 +103,7 @@ void Graphic_MouseHoverNodeChooseAttacker(Player * player, Vector2 mousePosition
...
@@ -103,7 +103,7 @@ void Graphic_MouseHoverNodeChooseAttacker(Player * player, Vector2 mousePosition
Node
*
currentNode
=
player
->
nodes
[
nodeIndex
];
Node
*
currentNode
=
player
->
nodes
[
nodeIndex
];
if
(
CheckCollisionPointRec
(
mousePosition
,
currentNode
->
collisionHitbox
)){
if
(
CheckCollisionPointRec
(
mousePosition
,
currentNode
->
collisionHitbox
)){
Vector2
screenPosition
=
Panel_pixelFromPosition
(
panel
,
&
(
currentNode
->
position
)
);
Vector2
screenPosition
=
Panel_pixelFromPosition
(
panel
,
&
(
currentNode
->
position
)
);
Draw
CircleV
(
screenPosition
,
29
,
GOLD
);
Draw
Ring
(
screenPosition
,
24
.
0
,
28
.
0
,
0
.
0
,
360
.
0
,
0
.
1
,
GOLD
);
//DrawCircleV(screenPosition, 45, RAYWHITE);
//DrawCircleV(screenPosition, 45, RAYWHITE);
if
(
!
player
->
hasSelectedNode
){
if
(
!
player
->
hasSelectedNode
){
DrawText
(
"attacker"
,
(
int
)
screenPosition
.
x
+
30
,
(
int
)
screenPosition
.
y
,
20
,
GOLD
);
DrawText
(
"attacker"
,
(
int
)
screenPosition
.
x
+
30
,
(
int
)
screenPosition
.
y
,
20
,
GOLD
);
...
@@ -112,16 +112,19 @@ void Graphic_MouseHoverNodeChooseAttacker(Player * player, Vector2 mousePosition
...
@@ -112,16 +112,19 @@ void Graphic_MouseHoverNodeChooseAttacker(Player * player, Vector2 mousePosition
}
}
if
(
player
->
hasSelectedNode
){
if
(
player
->
hasSelectedNode
){
Vector2
screenPosition
=
Panel_pixelFromPosition
(
panel
,
&
(
player
->
selectedNode
->
position
)
);
Vector2
screenPosition
=
Panel_pixelFromPosition
(
panel
,
&
(
player
->
selectedNode
->
position
)
);
Draw
CircleV
(
screenPosition
,
29
,
GOLD
);
Draw
Ring
(
screenPosition
,
24
.
0
,
28
.
0
,
0
.
0
,
360
.
0
,
0
.
1
,
GOLD
);
DrawText
(
"attacker"
,
(
int
)
screenPosition
.
x
+
30
,
(
int
)
screenPosition
.
y
,
20
,
GOLD
);
DrawText
(
"attacker"
,
(
int
)
screenPosition
.
x
+
30
,
(
int
)
screenPosition
.
y
,
20
,
GOLD
);
}
}
}
}
void
Graphic_MouseHoverNodeChooseTarget
(
Node
*
originNode
,
Vector2
mousePosition
,
Panel
*
panel
){
void
Graphic_MouseHoverNodeChooseTarget
(
Node
*
originNode
,
Vector2
mousePosition
,
Panel
*
panel
){
for
(
int
neighbourIndex
=
0
;
neighbourIndex
<
originNode
->
card
;
neighbourIndex
++
){
for
(
int
neighbourIndex
=
0
;
neighbourIndex
<
originNode
->
card
;
neighbourIndex
++
){
Vector2
screenPosition
=
Panel_pixelFromPosition
(
panel
,
&
(
originNode
->
edges
[
neighbourIndex
].
_target
->
position
)
);
Vector2
screenPosition
=
Panel_pixelFromPosition
(
panel
,
&
(
originNode
->
edges
[
neighbourIndex
].
_target
->
position
)
);
/* if( &(originNode->edges[neighbourIndex]._target->color) = &(originNode->color)){
if
(
&
(
originNode
->
edges
[
neighbourIndex
].
_target
->
color
)
!=
&
(
originNode
->
color
)){
DrawCircleV(screenPosition, 29, GREEN);
DrawRing
(
screenPosition
,
24
.
0
,
30
.
0
,
0
.
0
,
360
.
0
,
0
.
1
,
GREEN
);
} */
}
if
(
CheckCollisionPointRec
(
mousePosition
,
originNode
->
edges
[
neighbourIndex
].
_target
->
collisionHitbox
)
&&
&
(
originNode
->
edges
[
neighbourIndex
].
_target
->
color
)
!=
&
(
originNode
->
color
)){
DrawRing
(
screenPosition
,
30
.
0
,
33
.
0
,
0
.
0
,
360
.
0
,
0
.
1
,
MAROON
);
}
}
}
}
}
...
@@ -129,40 +132,127 @@ void Graphic_MouseHoverNodeChooseTarget(Node * originNode, Vector2 mousePosition
...
@@ -129,40 +132,127 @@ void Graphic_MouseHoverNodeChooseTarget(Node * originNode, Vector2 mousePosition
#define MAX_FRAME_SPEED 15
#define MAX_FRAME_SPEED 15
#define MIN_FRAME_SPEED 1
#define MIN_FRAME_SPEED 1
void
diceRolling
()
int
Graphic_ChooseNumberOfAttackers
(
Player
*
attacker
,
Player
*
defender
,
Node
*
originNode
,
Node
*
targetNode
,
Font
font
)
{
printf
(
"dice rolling begin
\n
"
);
// Initialization
{
// Initialization
//--------------------------------------------------------------------------------------
const
int
screenWidth
=
1700
;
const
int
screenHeight
=
800
;
bool
endAnimation
=
false
;
SetTargetFPS
(
60
);
// Set our game to run at 60 frames-per-second
Rectangle
*
nbAttackerRectangle
=
malloc
(
10
*
sizeof
(
Rectangle
));
printf
(
"number dice avail %d
\n
"
,
originNode
->
soldiersToAdd
+
originNode
->
soldiers
);
for
(
int
i
=
0
;
i
<
originNode
->
soldiersToAdd
+
originNode
->
soldiers
;
i
++
){
nbAttackerRectangle
[
i
]
=
(
Rectangle
){
200
+
(
i
-
1
)
*
250
,
screenHeight
-
500
,
150
,
70
};
printf
(
"rectangle %d position : %f %f
\n
"
,
i
,
nbAttackerRectangle
[
i
].
x
,
nbAttackerRectangle
[
i
].
y
);
}
char
*
whoseTurnToAttack
=
malloc
(
20
*
sizeof
(
char
));
sprintf
(
whoseTurnToAttack
,
"Player %d attacks "
,
attacker
->
ID
);
char
*
whoseTurnToDefend
=
malloc
(
20
*
sizeof
(
char
));
sprintf
(
whoseTurnToDefend
,
"Player %d"
,
defender
->
ID
);
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
const
int
screenWidth1
=
800
;
const
int
screenHeight1
=
450
;
InitWindow
(
screenWidth1
,
screenHeight1
,
"raylib [texture] example - texture rectangle"
);
// Main game loop
while
(
!
endAnimation
)
// Detect window close button or ESC key
{
// Draw
//----------------------------------------------------------------------------------
BeginDrawing
();
ClearBackground
(
RAYWHITE
);
Vector2
mousePosition
=
GetMousePosition
();
DrawTextEx
(
font
,
whoseTurnToAttack
,
(
Vector2
){
screenWidth
/
2
-
(
MeasureTextEx
(
font
,
whoseTurnToAttack
,
50
.
0
,
3
.
0
).
x
)
+
50
,
70
}
,
50
.
0
,
3
.
0
,
attacker
->
color
);
DrawTextEx
(
font
,
whoseTurnToDefend
,
(
Vector2
){
screenWidth
/
2
+
50
,
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
->
soldiersToAdd
+
originNode
->
soldiers
;
i
++
){
DrawRectangleRec
(
nbAttackerRectangle
[
i
],
BLACK
);
char
*
str_i
=
malloc
(
sizeof
(
int
));
sprintf
(
str_i
,
"%d"
,
i
);
DrawTextEx
(
font
,
str_i
,
(
Vector2
){
nbAttackerRectangle
[
i
].
x
+
55
,
nbAttackerRectangle
[
i
].
y
+
5
},
70
.
0
,
3
.
0
,
WHITE
);
if
(
CheckCollisionPointRec
(
mousePosition
,
nbAttackerRectangle
[
i
])){
DrawRectangleLinesEx
(
nbAttackerRectangle
[
i
],
5
,
GREEN
);
}
if
(
IsMouseButtonPressed
(
MOUSE_LEFT_BUTTON
)){
if
(
CheckCollisionPointRec
(
mousePosition
,
nbAttackerRectangle
[
i
])){
printf
(
"colision dés choix %d
\n
"
,
i
);
return
i
;
}
}
}
EndDrawing
();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
// Texture unloading
free
(
whoseTurnToAttack
);
free
(
whoseTurnToDefend
);
free
(
nbAttackerRectangle
);
//--------------------------------------------------------------------------------------
}
void
diceRolling
(
Player
*
attacker
,
Player
*
defender
,
Node
*
originNode
,
Node
*
targetNode
,
int
nbOfAttackers
,
Font
font
)
{
printf
(
"dice rolling begin
\n
"
);
// Initialization
//--------------------------------------------------------------------------------------
const
int
screenWidth
=
1700
;
const
int
screenHeight
=
800
;
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
Texture2D
diceTexture
=
LoadTexture
(
"diceRolling.png"
);
// Texture loading
Image
texture
=
LoadImage
(
"diceRolling.png"
);
ImageResize
(
&
(
texture
),
100
,
800
);
//Texture2D diceTexture = LoadTexture("diceRolling.png"); // Texture loading
Texture2D
diceTexture
=
LoadTextureFromImage
(
texture
);
Vector2
position
=
{
350
.
0
f
,
100
.
0
f
};
Rectangle
frameRec
=
{
0
.
0
f
,
0
.
0
f
,
(
float
)
diceTexture
.
width
,
(
float
)
diceTexture
.
height
/
9
};
Rectangle
frameRec
=
{
0
.
0
f
,
0
.
0
f
,
(
float
)
diceTexture
.
width
,
(
float
)
diceTexture
.
height
/
9
};
int
currentFrame
=
0
;
int
currentFrame
=
0
;
int
framesCounter
=
0
;
int
framesCounter
=
0
;
int
framesSpeed
=
10
;
int
framesSpeed
=
7
;
int
frameExit
=
0
;
// Number of spritesheet frames shown by second
int
frameExit
=
0
;
// Number of spritesheet frames shown by second
bool
endAnimation
=
false
;
bool
endAnimation
=
false
;
SetTargetFPS
(
60
);
// Set our game to run at 60 frames-per-second
SetTargetFPS
(
60
);
// Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
char
*
whoseTurnToAttack
=
malloc
(
20
*
sizeof
(
char
));
sprintf
(
whoseTurnToAttack
,
"Player %d "
,
attacker
->
ID
);
char
*
whoseTurnToDefend
=
malloc
(
20
*
sizeof
(
char
));
sprintf
(
whoseTurnToDefend
,
"Player %d "
,
defender
->
ID
);
Vector2
*
positionDiceAttacker
=
malloc
(
20
*
sizeof
(
Vector2
));
Vector2
*
positionDiceDefender
=
malloc
(
20
*
sizeof
(
Vector2
));
for
(
int
i
=
0
;
i
<
nbOfAttackers
;
i
++
){
positionDiceAttacker
[
i
]
=
(
Vector2
){
200
+
(
i
)
*
250
,
screenHeight
-
500
};
}
for
(
int
i
=
0
;
i
<
targetNode
->
soldiers
+
targetNode
->
soldiersToAdd
;
i
++
){
positionDiceDefender
[
i
]
=
(
Vector2
){
1000
+
(
i
)
*
250
,
screenHeight
-
500
};
}
// Main game loop
// Main game loop
while
(
!
WindowShouldClose
()
)
// Detect window close button or ESC key
while
(
!
endAnimation
)
// Detect window close button or ESC key
{
{
// Update
// Update
//----------------------------------------------------------------------------------
//----------------------------------------------------------------------------------
framesCounter
++
;
framesCounter
++
;
frameExit
++
;
//
frameExit++;
printf
(
"%d frame
Exit
\n
"
,
frameExit
);
//printf("%d frame before
Exit \n", frameExit);
if
(
frameExit
==
1
00
)
endAnimation
=
true
;
if
(
frameExit
==
2
00
)
endAnimation
=
true
;
if
(
framesCounter
>=
(
60
/
framesSpeed
))
if
(
framesCounter
>=
(
60
/
framesSpeed
))
{
{
framesCounter
=
0
;
framesCounter
=
0
;
...
@@ -179,11 +269,17 @@ void diceRolling()
...
@@ -179,11 +269,17 @@ void diceRolling()
BeginDrawing
();
BeginDrawing
();
ClearBackground
(
RAYWHITE
);
ClearBackground
(
RAYWHITE
);
//Vector2 * positionDiceAttacker = malloc(sizeof(Vector2)*attackerNbDice) ;
/* for(int attackerDice = 0; attackerDice < attackerNbDice ; attackerDice++){
DrawTextEx
(
font
,
whoseTurnToAttack
,
(
Vector2
){
250
,
200
}
,
30
.
0
,
3
.
0
,
attacker
->
color
);
DrawTextEx
(
font
,
whoseTurnToDefend
,
(
Vector2
){
screenWidth
-
700
,
200
},
30
.
0
,
3
.
0
,
defender
->
color
);
} */
DrawTextEx
(
font
,
" attacker"
,
(
Vector2
){
250
+
MeasureTextEx
(
font
,
"Player X "
,
30
.
0
,
3
.
0
).
x
,
210
}
,
15
.
0
,
3
.
0
,
attacker
->
color
);
DrawTextureRec
(
diceTexture
,
frameRec
,
position
,
WHITE
);
// Draw part of the texture
DrawTextEx
(
font
,
" defender"
,
(
Vector2
){
screenWidth
-
700
+
MeasureTextEx
(
font
,
"Player X "
,
30
.
0
,
3
.
0
).
x
,
210
},
15
.
0
,
3
.
0
,
defender
->
color
);
for
(
int
i
=
0
;
i
<
nbOfAttackers
;
i
++
){
DrawTextureRec
(
diceTexture
,
frameRec
,
positionDiceAttacker
[
i
],
WHITE
);
}
for
(
int
i
=
0
;
i
<
targetNode
->
soldiers
+
targetNode
->
soldiersToAdd
;
i
++
){
DrawTextureRec
(
diceTexture
,
frameRec
,
positionDiceDefender
[
i
],
WHITE
);
}
EndDrawing
();
EndDrawing
();
//----------------------------------------------------------------------------------
//----------------------------------------------------------------------------------
...
@@ -193,10 +289,11 @@ void diceRolling()
...
@@ -193,10 +289,11 @@ void diceRolling()
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
// Texture unloading
// Texture unloading
CloseWindow
();
// Close window and OpenGL context
//CloseWindow();
free
(
positionDiceAttacker
);
free
(
positionDiceDefender
);
// Close window and OpenGL context
UnloadTexture
(
diceTexture
);
UnloadTexture
(
diceTexture
);
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
}
}
src/graphical-aspect.h
View file @
a95aa518
...
@@ -17,7 +17,9 @@ Rectangle Graphic_ConfirmButton(Font font);
...
@@ -17,7 +17,9 @@ Rectangle Graphic_ConfirmButton(Font font);
void
Graphic_MouseHoverNodeRecrutement
(
Player
*
self
,
Vector2
mousePosition
,
Panel
*
panel
);
void
Graphic_MouseHoverNodeRecrutement
(
Player
*
self
,
Vector2
mousePosition
,
Panel
*
panel
);
void
Graphic_MouseHoverNodeChooseAttacker
(
Player
*
player
,
Vector2
mousePosition
,
Panel
*
panel
);
void
Graphic_MouseHoverNodeChooseAttacker
(
Player
*
player
,
Vector2
mousePosition
,
Panel
*
panel
);
void
Graphic_MouseHoverNodeChooseTarget
(
Node
*
originNode
,
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)
...
@@ -50,6 +50,7 @@ int main(int nbArg, char ** arg)
for
(
int
index
=
0
;
index
<
world
->
size
;
index
++
){
for
(
int
index
=
0
;
index
<
world
->
size
;
index
++
){
Player_add_Node
(
&
(
players
[
index
%
playerCount
]),
&
(
world
->
nodes
[
index
]));
Player_add_Node
(
&
(
players
[
index
%
playerCount
]),
&
(
world
->
nodes
[
index
]));
}
}
// Raylib Initialization
// Raylib Initialization
//----------------------
//----------------------
InitWindow
(
screenWidth
,
screenHeight
,
"NetWorld basic viewer"
);
InitWindow
(
screenWidth
,
screenHeight
,
"NetWorld basic viewer"
);
...
@@ -82,7 +83,9 @@ int main(int nbArg, char ** arg)
...
@@ -82,7 +83,9 @@ int main(int nbArg, char ** arg)
}
}
break
;
break
;
case
game_ui
:
case
game_ui
:
BeginDrawing
();
game_update
(
world
,
players
,
font
,
panel
);
game_update
(
world
,
players
,
font
,
panel
);
EndDrawing
();
default:
default:
break
;
break
;
}
}
...
@@ -107,7 +110,7 @@ void game_update(NetWorld * world, Player * players, Font font, Panel * panel)
...
@@ -107,7 +110,7 @@ void game_update(NetWorld * world, Player * players, Font font, Panel * panel)
Graphic_ShowPlayerInfo
(
currentPlayer
,
screenWidth
,
screenHeight
,
font
);
Graphic_ShowPlayerInfo
(
currentPlayer
,
screenWidth
,
screenHeight
,
font
);
Graphic_WhoseTurnIsIt
(
currentPlayer
,
screenWidth
,
screenHeight
,
font
);
Graphic_WhoseTurnIsIt
(
currentPlayer
,
screenWidth
,
screenHeight
,
font
);
int
playerCount
=
world
->
playerCount
;
int
playerCount
=
world
->
playerCount
;
Player
*
newPlayers
=
malloc
(
sizeof
(
Player
));
//
Player * newPlayers = malloc(sizeof(Player));
switch
(
currentPlayer
->
turnPhase
){
switch
(
currentPlayer
->
turnPhase
){
case
recruitment
:
case
recruitment
:
...
@@ -155,8 +158,10 @@ void game_update(NetWorld * world, Player * players, Font font, Panel * panel)
...
@@ -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
){
else
if
(
Node_are_connected
(
originNode
,
currentNode
)
&&
(
originNode
->
soldiers
>
1
)
&&
originNode
->
canAttack
){
printf
(
"Engagine attack on target Node
\n
"
);
printf
(
"Engagine attack on target Node
\n
"
);
Player_attack_Node
(
currentPlayer
,
&
(
players
[
nodePlayerID
]),
originNode
,
currentNode
);
int
nbOfAttackers
=
Graphic_ChooseNumberOfAttackers
(
currentPlayer
,
&
(
players
[
nodePlayerID
]),
originNode
,
currentNode
,
font
);
diceRolling
();
Player_attack_Node
(
currentPlayer
,
&
(
players
[
nodePlayerID
]),
originNode
,
currentNode
,
nbOfAttackers
);
//diceRolling(currentPlayer, &(players[nodePlayerID]), originNode, currentNode, nbOfAttackers ,font);
}
else
{
}
else
{
printf
(
"Failed to attack target : Origin has already attacked, nodes aren't connected or origin node has too few soldiers
\n
"
);
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){
...
@@ -155,8 +155,8 @@ void Player_confirm_recrutement(Player * self){
};
};
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
){
int
attackersCount
=
fmin
(
3
,
(
originNode
->
soldiers
-
1
))
;
int
attackersCount
=
numberOfAttackers
;
int
defendersCount
=
targetNode
->
soldiers
>=
3
?
2
:
1
;
int
defendersCount
=
targetNode
->
soldiers
>=
3
?
2
:
1
;
int
attDiceRolls
[
attackersCount
];
int
attDiceRolls
[
attackersCount
];
int
defDiceRolls
[
defendersCount
];
int
defDiceRolls
[
defendersCount
];
...
...
src/player.h
View file @
a95aa518
...
@@ -87,7 +87,7 @@ void Player_select_Node(Player * self, Vector2 mousePos);
...
@@ -87,7 +87,7 @@ void Player_select_Node(Player * self, Vector2 mousePos);
void
Player_unselect_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
);
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