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
Fatus
NetWorld
Commits
712826ad
Commit
712826ad
authored
Oct 15, 2020
by
guillaume
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
control camera
parent
d9a22835
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
5 deletions
+31
-5
CMakeLists.txt
CMakeLists.txt
+2
-2
controlpanel.c
src/controlpanel.c
+24
-3
controlpanel.h
src/controlpanel.h
+4
-0
main-viewer.c
src/main-viewer.c
+1
-0
No files found.
CMakeLists.txt
View file @
712826ad
...
@@ -15,10 +15,10 @@ find_package(raylib 3.0 REQUIRED)
...
@@ -15,10 +15,10 @@ find_package(raylib 3.0 REQUIRED)
#set(raylib_VERBOSE 1)
#set(raylib_VERBOSE 1)
add_executable
(
nw-hello src/main-hello.c
)
add_executable
(
nw-hello src/main-hello.c
)
target_link_libraries
(
nw-hello raylib
)
target_link_libraries
(
nw-hello raylib
m
)
add_executable
(
nw-viewer src/main-viewer.c src/networld.c src/controlpanel.c
)
add_executable
(
nw-viewer src/main-viewer.c src/networld.c src/controlpanel.c
)
target_link_libraries
(
nw-viewer raylib
)
target_link_libraries
(
nw-viewer raylib
m
)
#without cmake package...
#without cmake package...
#include_directories(${PROJECT_SOURCE_DIR}/raylib/src)
#include_directories(${PROJECT_SOURCE_DIR}/raylib/src)
...
...
src/controlpanel.c
View file @
712826ad
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <math.h>
// Constructor / Destructor
// Constructor / Destructor
Panel
*
Panel_new
()
Panel
*
Panel_new
()
...
@@ -52,13 +53,15 @@ void Panel_draw(Panel * self)
...
@@ -52,13 +53,15 @@ void Panel_draw(Panel * self)
void
Panel_drawBasis
(
Panel
*
self
)
void
Panel_drawBasis
(
Panel
*
self
)
{
{
Vector2
screen00
=
{
0
.
f
,
0
.
f
};
screen00
=
Panel_pixelFromPosition
(
self
,
&
(
screen00
)
);
Vector2
screen10
=
{
1
.
f
,
0
.
f
};
Vector2
screen10
=
{
1
.
f
,
0
.
f
};
screen10
=
Panel_pixelFromPosition
(
self
,
&
(
screen10
)
);
screen10
=
Panel_pixelFromPosition
(
self
,
&
(
screen10
)
);
Vector2
screen01
=
{
0
.
f
,
1
.
f
};
Vector2
screen01
=
{
0
.
f
,
1
.
f
};
screen01
=
Panel_pixelFromPosition
(
self
,
&
(
screen01
)
);
screen01
=
Panel_pixelFromPosition
(
self
,
&
(
screen01
)
);
DrawCircleV
(
s
elf
->
screenCenter
,
4
,
BLUE
);
DrawCircleV
(
s
creen00
,
4
,
BLUE
);
DrawLineV
(
s
elf
->
screenCenter
,
screen10
,
RED
);
DrawLineV
(
s
creen00
,
screen10
,
RED
);
DrawLineV
(
s
elf
->
screenCenter
,
screen01
,
BLUE
);
DrawLineV
(
s
creen00
,
screen01
,
BLUE
);
}
}
void
Panel_drawNode
(
Panel
*
self
,
Node
*
n
)
void
Panel_drawNode
(
Panel
*
self
,
Node
*
n
)
...
@@ -82,3 +85,21 @@ Vector2 Panel_positionFromPixel(Panel * self, Vector2 * p)
...
@@ -82,3 +85,21 @@ Vector2 Panel_positionFromPixel(Panel * self, Vector2 * p)
Vector2
position
=
{
p
->
x
,
p
->
y
};
Vector2
position
=
{
p
->
x
,
p
->
y
};
return
position
;
return
position
;
}
}
void
Panel_control
(
Panel
*
self
)
{
Panel_controlCamera
(
self
);
}
void
Panel_controlCamera
(
Panel
*
self
)
{
// KEYBOARD Control:
float
step
=
3
.
0
f
/
self
->
scale
;
if
(
IsKeyDown
(
KEY_RIGHT
))
self
->
camera
.
x
+=
step
;
if
(
IsKeyDown
(
KEY_LEFT
))
self
->
camera
.
x
-=
step
;
if
(
IsKeyDown
(
KEY_UP
))
self
->
camera
.
y
+=
step
;
if
(
IsKeyDown
(
KEY_DOWN
))
self
->
camera
.
y
-=
step
;
self
->
scale
+=
(
GetMouseWheelMove
()
*
1
.
f
);
self
->
scale
=
fmaxf
(
self
->
scale
,
0
.
001
f
);
}
\ No newline at end of file
src/controlpanel.h
View file @
712826ad
...
@@ -28,4 +28,8 @@ void Panel_drawNode(Panel * self, Node * n);
...
@@ -28,4 +28,8 @@ void Panel_drawNode(Panel * self, Node * n);
Vector2
Panel_pixelFromPosition
(
Panel
*
self
,
Vector2
*
p
);
Vector2
Panel_pixelFromPosition
(
Panel
*
self
,
Vector2
*
p
);
Vector2
Panel_positionFromPixel
(
Panel
*
self
,
Vector2
*
p
);
Vector2
Panel_positionFromPixel
(
Panel
*
self
,
Vector2
*
p
);
// Control
void
Panel_control
(
Panel
*
self
);
void
Panel_controlCamera
(
Panel
*
self
);
#endif //CONTROLPANEL_H
#endif //CONTROLPANEL_H
\ No newline at end of file
src/main-viewer.c
View file @
712826ad
...
@@ -56,6 +56,7 @@ int main(int nbArg, char ** arg)
...
@@ -56,6 +56,7 @@ int main(int nbArg, char ** arg)
// Main game loop
// Main game loop
while
(
!
game_end
&&
!
WindowShouldClose
())
// Detect window close button or ESC key
while
(
!
game_end
&&
!
WindowShouldClose
())
// Detect window close button or ESC key
{
{
Panel_control
(
panel
);
game_update
(
world
);
game_update
(
world
);
Panel_draw
(
panel
);
Panel_draw
(
panel
);
}
}
...
...
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