Commit 8b397725 authored by Ewen's avatar Ewen

génération d'un Networld random

parent 53ec150b
......@@ -12,6 +12,7 @@
#include "networld.h"
#include "controlpanel.h"
#include "randomMap.h"
// Program attributes
//-------------------
......@@ -27,17 +28,19 @@ bool game_end;
int main(int nbArg, char ** arg)
{
int n = 10;
NetWorld * world= NetWorld_new(n);
world = Random_map(world, n);
// Game Initialization
//--------------------
game_end= false;
NetWorld * world= NetWorld_new(3);
Node_set( &(world->nodes[0]), (Vector2){1.4f, 1.28f}, RED );
Node_set( &(world->nodes[1]), (Vector2){21.0f, 22.8f}, MAGENTA );
Node_set( &(world->nodes[2]), (Vector2){18.4f, -12.2f}, GRAY );
NetWorld_connect(world, 0, 1);
NetWorld_connect(world, 1, 2);
NetWorld_biconnect(world, 2, 0);
//NetWorld_connect(world, 0, 1);
//NetWorld_connect(world, 1, 2);
//NetWorld_biconnect(world, 2, 0);
Panel * panel= Panel_new();
Panel_initialize(panel, world);
......
#include "randomMap.h"
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <math.h>
#include <string.h>
#include "networld.h"
#include "controlpanel.h"
#include "raylib.h"
NetWorld * Random_map(NetWorld * world, int nbNode)
{
int i ;
float randomX, randomY;
/* Intializes random number generator */
srand(time(NULL));
/* Print 5 random numbers from 0 to 15.00 */
for( i = 0 ; i < nbNode ; i++ ) {
randomX = (rand() % 1500)/100.0;
randomY = (rand() % 1500)/100.0;
Node_set( &(world->nodes[i]), (Vector2){randomX, randomY}, RED );
printf("%f\nbNode", randomX);
printf("%f\nbNode", randomY);
if(i!= nbNode-1){
NetWorld_connect(world, i, i+1);
}
else{
NetWorld_connect(world, i, 0);
}
}
return world;
}
\ No newline at end of file
#include "raylib.h"
#include "networld.h"
NetWorld * Random_map(NetWorld * world, int nbNode);
\ No newline at end of file
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