Ya thats what I thought at first, but I dont see how that can be when Im passing the actual numbers 0 and 1, and also the size (0.5) is being passed properly.. heres the entire code..
Code:
#include "gemstone.h"
#include "board.h"
bool draw_gemstones(struct PacmanBoard* pcmb_p){
int Number_of_Gems=40;
struct Gemstone *gemstn_p[40];
gemstn_p[0]=(struct Gemstone*)malloc(sizeof(struct Gemstone));
init_gemstones(gemstn_p[0],pcmb_p,0.5,1,0);
draw_Polygon(gemstn_p[0]->gemstone);
destruct_Polygon(gemstn_p[0]->gemstone);
return true;
}
bool init_gemstones(struct Gemstone* gem_p,struct PacmanBoard* pcmb_p,double size,int x,int y){
construct_Polygon(&gem_p->gemstone);
gem_p->position=(struct Point*)malloc(sizeof(Point));
//get dimensions of individual cell
double cell_w = pcmb_p->width / (double)(pcmb_p->ncells_x);
double cell_h = pcmb_p->height / (double)(pcmb_p->ncells_y);
struct Point* points = (struct Point*)malloc(4*sizeof(Point));
//find center position of cell
gem_p->position->x=0;//1+(x*cell_w)+(cell_w/2);
gem_p->position->y=0;//1-(y*cell_h)+(cell_h/2);
points[0].x=gem_p->position->x-cell_w*(size/2);
points[0].y=gem_p->position->y;
points[1].x=gem_p->position->x;
points[1].y=gem_p->position->y+cell_h*(size/2);
points[2].x=points[0].x+size*cell_w;
points[2].y=points[0].y;
points[3].x=points[1].x;
points[3].y=points[1].y-size*cell_h;
init_Polygon(gem_p->gemstone, gem_p->position, 4, points, 1.0, 1.0, 1.0);
return true;
}