
That is the picture of this code:
(and this is completely fucked up code. completely. and it doesn't even work properly. I'm going to spend some more time to fix it, get structures properly implemented, probably make it in C++ so I can get classes instead of structs)
and the math is all wrong. I need to work on using the real math that
So....................... Here's the shitty code:
#include "allegro.h"
#include "math.h"
#include "stdio.h"
typedef struct point
{
int x, y;
};
typedef struct hexagon
{
int length, locx, locy;
point p1, p2, p3, p4, p5, p6;
} hex;
PALETTE pal;
int main()
{
hex h,h2;
h.length = 16;
h.locx = 158;
h.locy = 116;
h2.length = 16;
h2.locx = h.locx - (int((h2.length * 1.7)));
h2.locy = h.locy - (int((h2.length * .9)));
h.p1.x = h.locx;
h.p1.y = h.locy;
h.p2.x = h.p1.x+h.length;
h.p2.y = h.p1.y;
h.p3.x = h.locx + (int(3.12*(h.length/2)));
h.p3.y = h.locy + (int(h.length * 1.7))/2;
h.p4.x = h.locx + h.length;
h.p4.y = h.locy + (int(h.length * 1.7));
h.p5.x = h.locx;
h.p5.y = h.p4.y;
h.p6.x = h.locx - (int(h.length/2.1));
h.p6.y = h.locy + (int(h.length * 1.7))/2;
//----------
h2.p1.x = h2.locx;
h2.p1.y = h2.locy;
h2.p2.x = h2.p1.x+h2.length;
h2.p2.y = h2.p1.y;
h2.p3.x = h2.locx + (int(3.12*(h2.length/2)));
h2.p3.y = h2.locy + (int(h2.length * 1.7))/2;
h2.p4.x = h2.locx + h2.length;
h2.p4.y = h2.locy + (int(h2.length * 1.7));
h2.p5.x = h2.locx;
h2.p5.y = h2.p4.y;
h2.p6.x = h2.locx - (int(h2.length/2.1));
h2.p6.y = h2.locy + (int(h2.length * 1.7))/2;
allegro_init();
install_keyboard();
if(set_gfx_mode(GFX_AUTODETECT, 320, 240, 0, 0) < 0)
{
printf("%s\n", allegro_error);
}
clear_keybuf();
get_palette(pal);
do
{
line(screen, h.p1.x, h.p1.y, h.p2.x, h.p2.y, 4);
line(screen, h.p2.x, h.p2.y, h.p3.x, h.p3.y, 4);
line(screen, h.p3.x, h.p3.y, h.p4.x, h.p4.y, 4);
line(screen, h.p4.x, h.p4.y, h.p5.x, h.p5.y, 4);
line(screen, h.p5.x, h.p5.y, h.p6.x, h.p6.y, 4);
line(screen, h.p6.x, h.p6.y, h.p1.x, h.p1.y, 4);
line(screen, h2.p1.x, h2.p1.y, h2.p2.x, h2.p2.y, 2);
line(screen, h2.p2.x, h2.p2.y, h2.p3.x, h2.p3.y, 2);
line(screen, h2.p3.x, h2.p3.y, h2.p4.x, h2.p4.y, 2);
line(screen, h2.p4.x, h2.p4.y, h2.p5.x, h2.p5.y, 2);
line(screen, h2.p5.x, h2.p5.y, h2.p6.x, h2.p6.y, 2);
line(screen, h2.p6.x, h2.p6.y, h2.p1.x, h2.p1.y, 2);
} while(!keypressed());
save_bitmap("screen.pcx", screen, pal);
return 0;
}
END_OF_MAIN()