Commit 53ec150b authored by Timothy LAIRD's avatar Timothy LAIRD

Changements nodes

parent 135e2887
......@@ -6,6 +6,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
// Tools
void printVector2( Vector2 v )
......@@ -86,7 +87,10 @@ void Panel_drawNode(Panel * self, Node * n)
Vector2 screenPosition= Panel_pixelFromPosition(self, &(n->position) );
DrawCircleV(screenPosition, 24, n->color);
DrawCircleV(screenPosition, 20, RAYWHITE);
DrawText(n->name, (int)(screenPosition.x), (int)(screenPosition.y), 20, n->color);
char * soldierText;
soldierText= malloc(sizeof(int));
  • Je ne suis pas convaincu par ce malloc (je pense que la taille allouée n'est pas terrible) De plus tu ne fais pas de free -> fuite mémoire en perspective

Please register or sign in to reply
sprintf(soldierText, "%d", n->soldiers);
DrawText(soldierText, (int)(screenPosition.x), (int)(screenPosition.y), 20, n->color);
}
void Panel_drawEdge(Panel * self, Edge * e)
......
......@@ -16,6 +16,9 @@ void Node_construct(Node * self)
self->card= 0;
self->edges= Edge_newArray( 0 );
self->name= malloc( sizeof(char)*32 );
self->continent= malloc( sizeof(char)*32 );
  • Ne pas oublier d'ajouter dans la fonction delete_node de liberer la memoire allouee au char*.

Please register or sign in to reply
self->soldiers= 1;
strcpy(self->continent, "None");
strcpy( self->name, "Node" );
}
......
......@@ -3,12 +3,19 @@
#include "raylib.h"
struct Str_Player{
int id;
};
typedef struct Str_Player Player;
//-----------------------------------//
//-- Node --//
//-----------------------------------//
struct Str_Edge;
struct Str_Node {
//! position (x, y) of the node
Vector2 position;
......@@ -20,6 +27,9 @@ struct Str_Node {
// Content:
//! name of the node
char* name;
int soldiers;
char* continent;
Player player;
};
/**
......
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