Commit 159ce2ba authored by guillaume's avatar guillaume

initialization ControlPanel

parent 3aac5b13
......@@ -17,7 +17,7 @@ find_package(raylib 3.0 REQUIRED)
add_executable(nw-hello src/main-hello.c)
target_link_libraries(nw-hello raylib)
add_executable(nw-viewer src/main-viewer.c src/networld.c)
add_executable(nw-viewer src/main-viewer.c src/networld.c src/controlpanel.c)
target_link_libraries(nw-viewer raylib)
#without cmake package...
......
#include "controlpanel.h"
#include <stdio.h>
#include <stdlib.h>
// Constructor / Destructor
Panel * Panel_new()
{
Panel * p = malloc( sizeof(Panel) );
return p;
}
void Panel_delete(Panel * self)
{
free(self);
}
// Initialization
void Panel_initialize(Panel * self, NetWorld * world)
{
self->world= world;
self->camerax= 0;
self->cameray= 0;
self->scale= 1;
}
// To String
void Panel_print(Panel * self)
{
printf("Panel camera(x-%f, y-%f, scale-%f)\n", self->camerax, self->cameray, self->scale);
}
#ifndef CONTROLPANEL_H
#define CONTROLPANEL_H
#include "networld.h"
struct Str_Panel {
double camerax, cameray;
double scale;
NetWorld * world;
};
typedef struct Str_Panel Panel;
// Constructor / Destructor
Panel * Panel_new();
void Panel_delete(Panel * self);
// Initialization
void Panel_initialize(Panel * self, NetWorld * world);
// To String
void Panel_print(Panel * self);
#endif //CONTROLPANEL_H
\ No newline at end of file
......@@ -5,11 +5,14 @@
*
********************************************************************************************/
#include "networld.h"
#include "raylib.h"
#include <stdlib.h>
#include <stdio.h>
#include "networld.h"
#include "controlpanel.h"
// Program attributes
//-------------------
const int screenWidth = 800;
......@@ -33,6 +36,9 @@ int main(int nbArg, char ** arg)
NetWorld_initNodePosition( world, 1, 110.4, 52.8 );
NetWorld_initNodePosition( world, 2, 384.5, 422.2 );
Panel * panel= Panel_new();
Panel_initialize(panel, world);
// Raylib Initialization
//----------------------
InitWindow(screenWidth, screenHeight, "NetWorld basic viewer");
......@@ -43,6 +49,7 @@ int main(int nbArg, char ** arg)
puts("world variable:");
NetWorld_print(world);
puts("world expected:\n[10.4, 12.8]\n[110.4, 52.8]\n[384.5, 422.2]");
Panel_print(panel);
// Main game loop
while (!game_end && !WindowShouldClose()) // Detect window close button or ESC key
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment