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
107305b1
Commit
107305b1
authored
Apr 20, 2021
by
ewen.madec
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new graphical aspects
parent
5063ae63
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
258 additions
and
20 deletions
+258
-20
CMakeLists.txt
CMakeLists.txt
+1
-1
GAMERIA.ttf
GAMERIA.ttf
+0
-0
diceRolling.png
diceRolling.png
+0
-0
graphical-aspect.c
src/graphical-aspect.c
+202
-0
graphical-aspect.h
src/graphical-aspect.h
+24
-0
main-viewer.c
src/main-viewer.c
+31
-19
No files found.
CMakeLists.txt
View file @
107305b1
...
@@ -18,7 +18,7 @@ include_directories(${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/src)
...
@@ -18,7 +18,7 @@ include_directories(${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/src)
include_directories
(
${
PROJECT_SOURCE_DIR
}
/dpd/include
)
include_directories
(
${
PROJECT_SOURCE_DIR
}
/dpd/include
)
link_directories
(
${
PROJECT_SOURCE_DIR
}
/dpd
)
link_directories
(
${
PROJECT_SOURCE_DIR
}
/dpd
)
add_executable
(
nw-viewer src/main-viewer.c src/networld.c src/controlpanel.c src/entity.c src/player.c src/random-map.c
)
add_executable
(
nw-viewer src/main-viewer.c src/networld.c src/controlpanel.c src/entity.c src/player.c src/random-map.c
src/graphical-aspect.c
)
target_link_libraries
(
nw-viewer raylib pthread dl rt X11 m
)
target_link_libraries
(
nw-viewer raylib pthread dl rt X11 m
)
#without cmake package...
#without cmake package...
...
...
GAMERIA.ttf
0 → 100644
View file @
107305b1
File added
diceRolling.png
0 → 100644
View file @
107305b1
208 KB
src/graphical-aspect.c
0 → 100644
View file @
107305b1
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include "graphical-aspect.h"
#include "networld.h"
#include "controlpanel.h"
#include "player.h"
#include "raylib.h"
void
Graphic_ShowPlayerInfo
(
Player
*
player
,
int
screenWidth
,
int
screenHeight
,
Font
font
){
Rectangle
rec
=
{
0
,
screenHeight
-
250
,
250
,
250
};
DrawRectangleLinesEx
(
rec
,
10
,
player
->
color
);
//Font font = LoadFont("Game On_PersonalUseOnly.ttf");
char
*
playerNumber
=
malloc
(
20
*
sizeof
(
char
));
sprintf
(
playerNumber
,
"Player %d"
,
player
->
ID
);
DrawTextEx
(
font
,
playerNumber
,
(
Vector2
){
35
,
screenHeight
-
240
},
30
.
0
,
3
.
0
,
player
->
color
);
char
*
soldierNumber
=
malloc
(
40
*
sizeof
(
char
));
sprintf
(
soldierNumber
,
"Soldiers left %d"
,
player
->
soldiers
);
DrawTextEx
(
font
,
soldierNumber
,
(
Vector2
){
15
,
screenHeight
-
180
},
24
.
0
,
3
.
0
,
player
->
color
);
int
totalTroops
=
0
;
for
(
int
i
=
0
;
i
<
player
->
nodeCount
;
i
++
){
totalTroops
+=
player
->
nodes
[
i
]
->
soldiers
;
}
char
*
str_totalTroops
=
malloc
(
40
*
sizeof
(
char
));
sprintf
(
str_totalTroops
,
"Total Troops %d"
,
totalTroops
);
DrawTextEx
(
font
,
str_totalTroops
,
(
Vector2
){
15
,
screenHeight
-
150
},
24
.
0
,
3
.
0
,
player
->
color
);
char
*
str_nodeCount
=
malloc
(
40
*
sizeof
(
char
));
sprintf
(
str_nodeCount
,
"Nodes owned %d"
,
player
->
nodeCount
);
DrawTextEx
(
font
,
str_nodeCount
,
(
Vector2
){
15
,
screenHeight
-
120
},
24
.
0
,
3
.
0
,
player
->
color
);
free
(
playerNumber
);
free
(
soldierNumber
);
free
(
str_totalTroops
);
free
(
str_nodeCount
);
}
void
Graphic_RecrutementPhase
(
Player
*
player
,
int
screenWidth
,
int
screenHeight
,
Font
font
){
Rectangle
rec
=
{
screenWidth
-
300
,
100
,
300
,
400
};
DrawRectangleLinesEx
(
rec
,
10
,
player
->
color
);
DrawTextEx
(
font
,
"Recrutement Phase"
,(
Vector2
){
screenWidth
-
275
,
120
},
23
.
0
,
3
.
0
,
player
->
color
);
DrawTextRec
(
font
,
" LEFT click on one of your node to recruit a soldier"
,
(
Rectangle
){
screenWidth
-
285
,
175
,
270
,
100
},
20
.
0
,
3
.
0
,
true
,
player
->
color
);
DrawTextRec
(
font
,
" RIGHT click on the same node to remove the soldier"
,
(
Rectangle
){
screenWidth
-
285
,
295
,
270
,
100
},
20
.
0
,
3
.
0
,
true
,
player
->
color
);
DrawTextRec
(
font
,
" click Confirm once finished"
,
(
Rectangle
){
screenWidth
-
285
,
415
,
270
,
100
},
20
.
0
,
3
.
0
,
true
,
player
->
color
);
}
void
Graphic_AttackPhase
(
Player
*
player
,
int
screenWidth
,
int
screenHeight
,
Font
font
){
Rectangle
rec
=
{
screenWidth
-
300
,
100
,
300
,
400
};
DrawRectangleLinesEx
(
rec
,
10
,
player
->
color
);
DrawTextEx
(
font
,
"Attack Phase"
,(
Vector2
){
screenWidth
-
265
,
120
},
23
.
0
,
3
.
0
,
player
->
color
);
DrawTextRec
(
font
,
" FIRST click on the node you want to attack from"
,
(
Rectangle
){
screenWidth
-
285
,
175
,
270
,
100
},
20
.
0
,
3
.
0
,
true
,
player
->
color
);
DrawTextRec
(
font
,
" THEN click on one of neighbouring node you want to attack"
,
(
Rectangle
){
screenWidth
-
285
,
295
,
270
,
100
},
20
.
0
,
3
.
0
,
true
,
player
->
color
);
DrawTextRec
(
font
,
" click Next Turn once finished"
,
(
Rectangle
){
screenWidth
-
285
,
415
,
270
,
100
},
20
.
0
,
3
.
0
,
true
,
player
->
color
);
}
void
Graphic_WhoseTurnIsIt
(
Player
*
player
,
int
screenWidth
,
int
screenHeight
,
Font
font
){
//Rectangle rec = {0, screenHeight - 250, 250, 250};
//DrawRectangleLinesEx(rec, 10, player->color);
//Font font = LoadFont("Game On_PersonalUseOnly.ttf");
char
*
whoseTurn
=
malloc
(
20
*
sizeof
(
char
));
sprintf
(
whoseTurn
,
"Player %d Turn"
,
player
->
ID
);
DrawTextEx
(
font
,
whoseTurn
,
(
Vector2
){
screenWidth
/
2
-
(
MeasureTextEx
(
font
,
whoseTurn
,
50
.
0
,
3
.
0
).
x
)
/
2
,
30
}
,
50
.
0
,
3
.
0
,
player
->
color
);
free
(
whoseTurn
);
}
Rectangle
Graphic_ConfirmButton
(
Font
font
)
{
Rectangle
nextPhase
=
{
200
,
200
,
220
,
55
};
DrawRectangleRec
(
nextPhase
,
GREEN
);
DrawTextEx
(
font
,
"Confirm"
,(
Vector2
){
220
,
210
}
,
40
.
0
,
3
.
0
,
BLACK
);
return
nextPhase
;
}
void
Graphic_MouseHoverNodeRecrutement
(
Player
*
player
,
Vector2
mousePosition
,
Panel
*
panel
){
for
(
int
nodeIndex
=
0
;
nodeIndex
<
player
->
nodeCount
;
nodeIndex
++
){
Node
*
currentNode
=
player
->
nodes
[
nodeIndex
];
if
(
CheckCollisionPointRec
(
mousePosition
,
currentNode
->
collisionHitbox
)){
//printf("collision noeud !\n");
Vector2
screenPosition
=
Panel_pixelFromPosition
(
panel
,
&
(
currentNode
->
position
)
);
DrawCircleV
(
screenPosition
,
29
,
MAGENTA
);
//DrawCircleV(screenPosition, 45, RAYWHITE);
if
(
player
->
soldiers
>
0
){
DrawText
(
"+1"
,
(
int
)
screenPosition
.
x
+
30
,
(
int
)
screenPosition
.
y
,
20
,
MAGENTA
);
}
}
}
}
void
Graphic_MouseHoverNodeChooseAttacker
(
Player
*
player
,
Vector2
mousePosition
,
Panel
*
panel
){
for
(
int
nodeIndex
=
0
;
nodeIndex
<
player
->
nodeCount
;
nodeIndex
++
){
Node
*
currentNode
=
player
->
nodes
[
nodeIndex
];
if
(
CheckCollisionPointRec
(
mousePosition
,
currentNode
->
collisionHitbox
)){
Vector2
screenPosition
=
Panel_pixelFromPosition
(
panel
,
&
(
currentNode
->
position
)
);
DrawCircleV
(
screenPosition
,
29
,
GOLD
);
//DrawCircleV(screenPosition, 45, RAYWHITE);
if
(
!
player
->
hasSelectedNode
){
DrawText
(
"attacker"
,
(
int
)
screenPosition
.
x
+
30
,
(
int
)
screenPosition
.
y
,
20
,
GOLD
);
}
}
}
if
(
player
->
hasSelectedNode
){
Vector2
screenPosition
=
Panel_pixelFromPosition
(
panel
,
&
(
player
->
selectedNode
->
position
)
);
DrawCircleV
(
screenPosition
,
29
,
GOLD
);
DrawText
(
"attacker"
,
(
int
)
screenPosition
.
x
+
30
,
(
int
)
screenPosition
.
y
,
20
,
GOLD
);
}
}
void
Graphic_MouseHoverNodeChooseTarget
(
Node
*
originNode
,
Vector2
mousePosition
,
Panel
*
panel
){
for
(
int
neighbourIndex
=
0
;
neighbourIndex
<
originNode
->
card
;
neighbourIndex
++
){
Vector2
screenPosition
=
Panel_pixelFromPosition
(
panel
,
&
(
originNode
->
edges
[
neighbourIndex
].
_target
->
position
)
);
/* if( &(originNode->edges[neighbourIndex]._target->color) = &(originNode->color)){
DrawCircleV(screenPosition, 29, GREEN);
} */
}
}
#define MAX_FRAME_SPEED 15
#define MIN_FRAME_SPEED 1
void
diceRolling
()
{
printf
(
"dice rolling begin
\n
"
);
// Initialization
//--------------------------------------------------------------------------------------
const
int
screenWidth1
=
800
;
const
int
screenHeight1
=
450
;
InitWindow
(
screenWidth1
,
screenHeight1
,
"raylib [texture] example - texture rectangle"
);
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
Texture2D
diceTexture
=
LoadTexture
(
"diceRolling.png"
);
// Texture loading
Vector2
position
=
{
350
.
0
f
,
100
.
0
f
};
Rectangle
frameRec
=
{
0
.
0
f
,
0
.
0
f
,
(
float
)
diceTexture
.
width
,
(
float
)
diceTexture
.
height
/
9
};
int
currentFrame
=
0
;
int
framesCounter
=
0
;
int
framesSpeed
=
10
;
int
frameExit
=
0
;
// Number of spritesheet frames shown by second
bool
endAnimation
=
false
;
SetTargetFPS
(
60
);
// Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while
(
!
WindowShouldClose
()
)
// Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
framesCounter
++
;
frameExit
++
;
printf
(
"%d frameExit
\n
"
,
frameExit
);
if
(
frameExit
==
100
)
endAnimation
=
true
;
if
(
framesCounter
>=
(
60
/
framesSpeed
))
{
framesCounter
=
0
;
currentFrame
++
;
if
(
currentFrame
>
8
)
currentFrame
=
0
;
frameRec
.
y
=
(
float
)
currentFrame
*
(
float
)
diceTexture
.
height
/
9
;
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing
();
ClearBackground
(
RAYWHITE
);
//Vector2 * positionDiceAttacker = malloc(sizeof(Vector2)*attackerNbDice) ;
/* for(int attackerDice = 0; attackerDice < attackerNbDice ; attackerDice++){
} */
DrawTextureRec
(
diceTexture
,
frameRec
,
position
,
WHITE
);
// Draw part of the texture
EndDrawing
();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
// Texture unloading
CloseWindow
();
// Close window and OpenGL context
UnloadTexture
(
diceTexture
);
//--------------------------------------------------------------------------------------
}
src/graphical-aspect.h
0 → 100644
View file @
107305b1
#ifndef GRAPHICALASPECT_H
#define GRAPHICALASPECT_H
#include "raylib.h"
#include "networld.h"
#include "player.h"
#include "controlpanel.h"
//Graphical view
void
Graphic_ShowPlayerInfo
(
Player
*
player
,
int
screenWidth
,
int
screenHeight
,
Font
font
);
void
Graphic_RecrutementPhase
(
Player
*
player
,
int
screenWidth
,
int
screenHeight
,
Font
font
);
void
Graphic_AttackPhase
(
Player
*
player
,
int
screenWidth
,
int
screenHeight
,
Font
font
);
void
Graphic_WhoseTurnIsIt
(
Player
*
player
,
int
screenWidth
,
int
screenHeight
,
Font
font
);
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
();
#endif
\ No newline at end of file
src/main-viewer.c
View file @
107305b1
...
@@ -15,14 +15,15 @@
...
@@ -15,14 +15,15 @@
#include "player.h"
#include "player.h"
#include "controlpanel.h"
#include "controlpanel.h"
#include "random-map.h"
#include "random-map.h"
#include "graphical-aspect.h"
// Program attributes
// Program attributes
//-------------------
//-------------------
const
int
screenWidth
=
8
00
;
const
int
screenWidth
=
17
00
;
const
int
screenHeight
=
6
00
;
const
int
screenHeight
=
8
00
;
const
int
targetFPS
=
60
;
const
int
targetFPS
=
60
;
void
game_update
(
NetWorld
*
world
,
Player
*
players
);
void
game_update
(
NetWorld
*
world
,
Player
*
players
,
Font
font
,
Panel
*
panel
);
// Game attributes
// Game attributes
//-----------------
//-----------------
...
@@ -30,7 +31,7 @@ bool game_end;
...
@@ -30,7 +31,7 @@ bool game_end;
int
main
(
int
nbArg
,
char
**
arg
)
int
main
(
int
nbArg
,
char
**
arg
)
{
{
int
nodeCount
=
5
;
int
nodeCount
=
10
;
int
playerCount
=
3
;
int
playerCount
=
3
;
NetWorld
*
world
=
NetWorld_new
(
nodeCount
,
playerCount
);
NetWorld
*
world
=
NetWorld_new
(
nodeCount
,
playerCount
);
Random_map
(
world
);
Random_map
(
world
);
...
@@ -41,7 +42,7 @@ int main(int nbArg, char ** arg)
...
@@ -41,7 +42,7 @@ int main(int nbArg, char ** arg)
printf
(
"positionY %f
\n
"
,
world
->
nodes
[
0
].
position
.
y
);
printf
(
"positionY %f
\n
"
,
world
->
nodes
[
0
].
position
.
y
);
printf
(
"positionX %f
\n
"
,
world
->
nodes
[
1
].
position
.
x
);
printf
(
"positionX %f
\n
"
,
world
->
nodes
[
1
].
position
.
x
);
printf
(
"positionY %f
\n
"
,
world
->
nodes
[
1
].
position
.
y
);
printf
(
"positionY %f
\n
"
,
world
->
nodes
[
1
].
position
.
y
);
printf
(
"distXY %f
\n
"
,
dist
(
world
->
nodes
[
0
],
world
->
nodes
[
1
]));
printf
(
"distXY %f
\n
"
,
dist
Node
(
world
->
nodes
[
0
],
world
->
nodes
[
1
]));
// Game Initialization
// Game Initialization
...
@@ -60,6 +61,7 @@ int main(int nbArg, char ** arg)
...
@@ -60,6 +61,7 @@ int main(int nbArg, char ** arg)
//----------------------
//----------------------
InitWindow
(
screenWidth
,
screenHeight
,
"NetWorld basic viewer"
);
InitWindow
(
screenWidth
,
screenHeight
,
"NetWorld basic viewer"
);
SetTargetFPS
(
targetFPS
);
SetTargetFPS
(
targetFPS
);
Font
font
=
LoadFont
(
"GAMERIA.ttf"
);
// Main game loop
// Main game loop
world
->
currentPlayer
=
0
;
world
->
currentPlayer
=
0
;
...
@@ -73,37 +75,45 @@ int main(int nbArg, char ** arg)
...
@@ -73,37 +75,45 @@ int main(int nbArg, char ** arg)
world
->
nodes
[
index
].
collisionHitbox
.
y
=
screenPosition
.
y
-
24
;
world
->
nodes
[
index
].
collisionHitbox
.
y
=
screenPosition
.
y
-
24
;
}
}
Panel_control
(
panel
);
Panel_control
(
panel
);
game_update
(
world
,
players
);
game_update
(
world
,
players
,
font
,
panel
);
Panel_draw
(
panel
);
Panel_draw
(
panel
);
}
}
// proper closing
// proper closing
//---------------
//---------------
NetWorld_delete
(
world
);
NetWorld_delete
(
world
);
Player_delete
(
players
);
Player_delete
(
players
);
UnloadFont
(
font
);
CloseWindow
();
// Close window and OpenGL context
CloseWindow
();
// Close window and OpenGL context
return
0
;
return
0
;
}
}
void
game_update
(
NetWorld
*
world
,
Player
*
players
)
void
game_update
(
NetWorld
*
world
,
Player
*
players
,
Font
font
,
Panel
*
panel
)
{
{
Vector2
mousePosition
=
{
0
.
0
f
,
0
.
0
f
};
mousePosition
=
GetMousePosition
();
Player
*
currentPlayer
=
&
(
players
[
world
->
currentPlayer
]);
Player
*
currentPlayer
=
&
(
players
[
world
->
currentPlayer
]);
Graphic_ShowPlayerInfo
(
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
1
:
case
1
:
Graphic_RecrutementPhase
(
currentPlayer
,
screenWidth
,
screenHeight
,
font
);
Graphic_MouseHoverNodeRecrutement
(
currentPlayer
,
mousePosition
,
panel
);
if
(
currentPlayer
->
soldiers
>
0
){
if
(
currentPlayer
->
soldiers
>
0
){
if
(
IsMouseButtonPressed
(
MOUSE_LEFT_BUTTON
)){
if
(
IsMouseButtonPressed
(
MOUSE_LEFT_BUTTON
)){
Vector2
mousePosition
=
GetMousePosition
();
Player_add_soldier
(
currentPlayer
,
mousePosition
);
Player_add_soldier
(
currentPlayer
,
mousePosition
);
}
}
}
else
{
}
else
{
Rectangle
nextPhase
=
{
screenWidth
-
48
,
screenHeight
-
48
,
48
,
48
};
Rectangle
nextPhaseButton
=
Graphic_ConfirmButton
(
font
);
DrawRectangleRec
(
nextPhase
,
GREEN
);
if
(
IsMouseButtonPressed
(
MOUSE_LEFT_BUTTON
)){
if
(
IsMouseButtonPressed
(
MOUSE_LEFT_BUTTON
)){
Vector2
mousePosition
=
GetMousePosition
();
if
(
CheckCollisionPointRec
(
mousePosition
,
nextPhaseButton
)){
if
(
CheckCollisionPointRec
(
mousePosition
,
nextPhase
)){
Player_confirm_recrutement
(
currentPlayer
);
Player_confirm_recrutement
(
currentPlayer
);
printf
(
"Recrutement confirmed
\n
"
);
printf
(
"Recrutement confirmed
\n
"
);
currentPlayer
->
turnPhase
=
2
;
currentPlayer
->
turnPhase
=
2
;
...
@@ -112,18 +122,20 @@ void game_update(NetWorld * world, Player * players)
...
@@ -112,18 +122,20 @@ void game_update(NetWorld * world, Player * players)
}
}
}
}
if
(
IsMouseButtonPressed
(
MOUSE_RIGHT_BUTTON
)){
if
(
IsMouseButtonPressed
(
MOUSE_RIGHT_BUTTON
)){
Vector2
mousePosition
=
GetMousePosition
();
Player_remove_soldier
(
currentPlayer
,
mousePosition
);
Player_remove_soldier
(
currentPlayer
,
mousePosition
);
}
}
break
;
break
;
case
2
:
case
2
:
Graphic_AttackPhase
(
currentPlayer
,
screenWidth
,
screenHeight
,
font
);
Graphic_MouseHoverNodeChooseAttacker
(
currentPlayer
,
mousePosition
,
panel
);
if
(
currentPlayer
->
hasSelectedNode
){
if
(
currentPlayer
->
hasSelectedNode
){
Graphic_MouseHoverNodeChooseTarget
(
currentPlayer
->
selectedNode
,
mousePosition
,
panel
);
if
(
IsMouseButtonPressed
(
MOUSE_RIGHT_BUTTON
)){
if
(
IsMouseButtonPressed
(
MOUSE_RIGHT_BUTTON
)){
Vector2
mousePosition
=
GetMousePosition
();
Player_unselect_Node
(
currentPlayer
,
mousePosition
);
Player_unselect_Node
(
currentPlayer
,
mousePosition
);
}
}
if
(
IsMouseButtonPressed
(
MOUSE_LEFT_BUTTON
)){
if
(
IsMouseButtonPressed
(
MOUSE_LEFT_BUTTON
)){
Vector2
mousePosition
=
GetMousePosition
();
Node
*
originNode
=
currentPlayer
->
selectedNode
;
Node
*
originNode
=
currentPlayer
->
selectedNode
;
for
(
int
nodeIndex
=
0
;
nodeIndex
<
world
->
size
;
nodeIndex
++
){
for
(
int
nodeIndex
=
0
;
nodeIndex
<
world
->
size
;
nodeIndex
++
){
...
@@ -138,6 +150,7 @@ void game_update(NetWorld * world, Player * players)
...
@@ -138,6 +150,7 @@ void game_update(NetWorld * world, Player * players)
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
);
Player_attack_Node
(
currentPlayer
,
&
(
players
[
nodePlayerID
]),
originNode
,
currentNode
);
diceRolling
();
}
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
"
);
}
}
...
@@ -146,14 +159,13 @@ void game_update(NetWorld * world, Player * players)
...
@@ -146,14 +159,13 @@ void game_update(NetWorld * world, Player * players)
}
}
}
else
{
}
else
{
if
(
IsMouseButtonPressed
(
MOUSE_LEFT_BUTTON
)){
if
(
IsMouseButtonPressed
(
MOUSE_LEFT_BUTTON
)){
Vector2
mousePosition
=
GetMousePosition
();
Player_select_Node
(
currentPlayer
,
mousePosition
);
Player_select_Node
(
currentPlayer
,
mousePosition
);
}
}
}
}
Rectangle
nextPhase
=
{
screenWidth
-
48
,
screenHeight
-
48
,
48
,
48
};
Rectangle
nextPhase
=
{
200
,
200
,
270
,
55
};
DrawRectangleRec
(
nextPhase
,
GREEN
);
DrawRectangleRec
(
nextPhase
,
GREEN
);
DrawTextEx
(
font
,
"Next Turn"
,(
Vector2
){
220
,
210
}
,
40
.
0
,
3
.
0
,
BLACK
);
if
(
IsMouseButtonPressed
(
MOUSE_LEFT_BUTTON
)){
if
(
IsMouseButtonPressed
(
MOUSE_LEFT_BUTTON
)){
Vector2
mousePosition
=
GetMousePosition
();
if
(
CheckCollisionPointRec
(
mousePosition
,
nextPhase
)){
if
(
CheckCollisionPointRec
(
mousePosition
,
nextPhase
)){
printf
(
"Attack phase ended
\n
"
);
printf
(
"Attack phase ended
\n
"
);
currentPlayer
->
turnPhase
=
-
1
;
currentPlayer
->
turnPhase
=
-
1
;
...
...
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