(no subject)

Aug. 17th, 2003 04:53 pm
symbioidlj: (Default)
[personal profile] symbioidlj


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 [livejournal.com profile] ziggurat gave me(which i think is pretty accurate, because IIRC, the page I saw used something like the Square Root of 3/2, which is in the equations he gave me. My modified code isall fucked up. It's close, but still not close enough. And the math is just wrong.

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()

Profile

symbioidlj: (Default)
symbioidlj

November 2015

S M T W T F S
1 234567
891011121314
15161718192021
22232425262728
2930     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Mar. 16th, 2026 09:05 am
Powered by Dreamwidth Studios