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
952e5af5
Commit
952e5af5
authored
Sep 21, 2020
by
guillaume
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ça bug...
parent
4a468980
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
14 deletions
+61
-14
CMakeLists.txt
CMakeLists.txt
+1
-1
main-viewer.c
src/main-viewer.c
+20
-9
networld.c
src/networld.c
+23
-3
networld.h
src/networld.h
+17
-1
No files found.
CMakeLists.txt
View file @
952e5af5
...
...
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.10)
project
(
networld LANGUAGES C
)
# Activate C99 standard:
SET
(
CMAKE_C_FLAGS
"-std=c99 -Wall -Wextra"
)
SET
(
CMAKE_C_FLAGS
"-
g -
std=c99 -Wall -Wextra"
)
# RayLib:
find_package
(
raylib 2.0 REQUIRED
)
...
...
src/main-viewer.c
View file @
952e5af5
...
...
@@ -7,6 +7,7 @@
#include "networld.h"
#include "raylib.h"
#include <stdlib.h>
// Program attributes
//-------------------
...
...
@@ -14,8 +15,8 @@ const int screenWidth = 800;
const
int
screenHeight
=
450
;
const
int
targetFPS
=
60
;
void
game_update
();
void
game_draw
();
void
game_update
(
NetWorld
*
world
);
void
game_draw
(
NetWorld
*
world
);
// Game attributes
//-----------------
...
...
@@ -24,8 +25,6 @@ bool game_end;
int
main
(
int
nbArg
,
char
**
arg
)
{
test
();
// Raylib Initialization
//----------------------
InitWindow
(
screenWidth
,
screenHeight
,
"NetWorld basic viewer"
);
...
...
@@ -34,32 +33,44 @@ int main(int nbArg, char ** arg)
// Game Initialization
//--------------------
game_end
=
false
;
NetWorld
*
world
=
NetWorld_new
(
3
);
NetWorld_initNodePosition
(
world
,
0
,
10
.
4
,
12
.
8
);
NetWorld_initNodePosition
(
world
,
1
,
110
.
4
,
52
.
8
);
NetWorld_initNodePosition
(
world
,
2
,
384
.
5
,
422
.
2
);
// Main game loop
while
(
!
game_end
&&
!
WindowShouldClose
())
// Detect window close button or ESC key
{
game_update
();
game_draw
();
game_update
(
world
);
game_draw
(
world
);
}
// proper closing
//---------------
NetWorld_delete
(
world
);
CloseWindow
();
// Close window and OpenGL context
return
0
;
}
void
game_update
()
void
game_update
(
NetWorld
*
world
)
{
}
void
game_draw
()
void
game_draw
(
NetWorld
*
world
)
{
BeginDrawing
();
puts
(
"Draw...
\n
"
);
ClearBackground
(
RAYWHITE
);
DrawText
(
"Congrats! You created your first window!"
,
190
,
200
,
20
,
LIGHTGRAY
);
for
(
int
i
=
0
;
i
<
world
->
size
;
++
i
)
{
Vector2
nodePosition
=
{
world
->
nodes
[
i
].
x
,
world
->
nodes
[
i
].
y
};
printf
(
"[%f, %f]
\n
"
,
world
->
nodes
[
i
].
x
,
world
->
nodes
[
i
].
y
);
DrawCircleV
(
nodePosition
,
50
,
MAROON
);
}
EndDrawing
();
}
\ No newline at end of file
src/networld.c
View file @
952e5af5
#include "networld.h"
#include <stdio.h>
#include <stdlib.h>
int
test
(){
puts
(
"hello"
);
return
0
;
// Constructor / Destructor
NetWorld
*
NetWorld_new
(
int
size
)
{
NetWorld
*
p
=
malloc
(
sizeof
(
NetWorld
)
);
p
->
size
=
size
;
p
->
nodes
=
malloc
(
p
->
size
*
sizeof
(
Node
)
);
return
p
;
}
void
NetWorld_delete
(
NetWorld
*
self
)
{
free
(
self
->
nodes
);
free
(
self
);
}
// Initialization
void
NetWorld_initNodePosition
(
NetWorld
*
self
,
int
iNode
,
float
x
,
float
y
)
{
self
->
nodes
[
iNode
].
x
=
x
;
self
->
nodes
[
iNode
].
y
=
y
;
}
src/networld.h
View file @
952e5af5
#ifndef NETWORLD_H
#define NETWORLD_H
int
test
();
struct
Str_Node
{
float
x
,
y
;
};
typedef
struct
Str_Node
Node
;
struct
Str_NetWorld
{
int
size
;
Node
*
nodes
;
};
typedef
struct
Str_NetWorld
NetWorld
;
// Constructor / Destructor
NetWorld
*
NetWorld_new
(
int
aSize
);
void
NetWorld_delete
(
NetWorld
*
aWorld
);
// Initialization
void
NetWorld_initPosition
(
NetWorld
*
self
,
float
**
position
);
// position must be an float[size][2] array...
#endif //NETWORLD_H
\ No newline at end of file
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