Page 1 of 1 [ 2 posts ]

 Print view Previous topic | Next topic

Author Message
 Post subject: resizable Chili-head  Posted: April 11th, 2017, 2:25 pm

Joined: September 14th, 2015, 10:58 pm
Posts: 43
Location: Jena
I took code from Legacy's homework: viewtopic.php?f=3&t=3890
So all credit to him(or her).
I made it resizable pinned to width. I might upload some more effective code here in the future if i
think of one.

Code:
int cx = 400, cy = 300, width = 400;// cx and cy are center coordinates

double inc = 1; // triangle steepness counter
for (int x = 0; x <= width/8.0; x++) //top of the crown
{
for (int y = 0; y<inc; y++)
{
gfx.PutPixel(cx + x - width/8.0,  cy - y - width*7/16.0, 0, 255, 0);
gfx.PutPixel(cx + x - width/4.0, cy - y - width*7/16.0, 0, 255, 0);
gfx.PutPixel(cx + x - width*3/8.0, cy - y - width*7/16.0, 0, 255, 0);
gfx.PutPixel(cx + x - width/2.0, cy - y - width*7/16.0, 0, 255, 0);//first triangle spike from left

gfx.PutPixel(cx - x + width / 8.0, cy - y - width*7/16.0, 0, 255, 0); //right side mirrored cause of -x
gfx.PutPixel(cx - x + width / 4.0 , cy - y - width*7/16.0, 0, 255, 0);
gfx.PutPixel(cx - x + width * 3/8.0, cy - y - width*7/16.0, 0, 255, 0);
gfx.PutPixel(cx - x + width / 2.0, cy - y - width*7/16.0, 0, 255, 0);
}
inc = inc + 2; //triangles are 2 times higher than wide
}

for (int x = 0; x <= width; x++) { // base of the crown (green rectangle)
for (int y = 0; y <= width/8.0; y++) {
gfx.PutPixel(cx  + x - width/2.0, cy + y - width*7/16.0, 0, 255, 0);
}
}

for (int x = 0; x <= width; x++) {//middle of face (white rectangle)
for (int y = 0; y <= width/2.0; y++) {
gfx.PutPixel(cx  + x - width/2.0, cy + y - width*5/16.0, 255, 255, 255);
}
}

inc = 1;
for (int x = 0; x <= width/2.0; x++) // white triangle chin
{
for (int y = 0; y<inc; y++)
{
gfx.PutPixel(cx + x - width/2.0, cy + y+width*3/16.0, 255, 255, 255); //left side
gfx.PutPixel(cx - x + width/2.0, cy + y+ width *3/16.0, 255, 255, 255);//right side
}
inc = inc + 0.85;
}

for (int x = 0; x <= width/4.0; x++) { //black rectangle eyes
for (int y = 0; y < width/10.0; y++) {
gfx.PutPixel(cx + x + width/16.0, cy + y - width/8.0, 0, 0, 0); // right eye
gfx.PutPixel(cx - x - width/16.0, cy + y - width/8.0, 0, 0, 0); //left eye
}
}

for (int x = 0; x <= width/20.0; x++) { //black rectangle beard
for (int y = 0; y <= width*6/25.0; y++) {
gfx.PutPixel(cx + x -width/40.0, cy + y + width*3/8.0, 0, 0, 0);
}
}

for (int x = 1; x <= width*7/20; x++) { // black eyebrows
for (int y = 1; y < width/16.0; y++) {
gfx.PutPixel(cx + x - width*3/8.0, cy + y - width * 9/40.0, 0, 0, 0); // left eyebrow
gfx.PutPixel(cx + x + width/40.0, cy + y - width*9/40.0, 0, 0, 0); //right eyebrow
}
}

for (int x = 0; x <= width/2.0; x++) { // beige lips
for (int y = 0; y <= width/20.0; y++) {
gfx.PutPixel(cx + x - width/4.0, cy + y + width*5/16.0, 255, 220, 220);
}
}

inc = 1;

for (int x = 0; x <= width*3/16.0; x++) //beige cheeks
{
for (int y = 0; y<inc; y++)
{
gfx.PutPixel(cx + x - width/2.0, cy + y+width*3/16.0, 255, 240, 240); //left cheek
gfx.PutPixel(cx - x + width/2.0, cy + y+ width * 3 / 16.0, 255, 240, 240); // right cheek
}
inc = inc + 0.85;
}

inc = 1;

for (int x = 1; x <= width*5/16.0; x++)//beige nose  - nose height
{
for (int y = 0; y<inc; y++)
{
gfx.PutPixel(cx  + y, cy + x-width/8.0, 255, 240, 240);//right side
gfx.PutPixel(cx - y, cy  + x-width/8.0, 255, 240, 240);//left side
}
inc = inc + 0.5;
}

for (int x = 0; x <= width/4.0; x++) { //black moustache-squares
for (int y = 1; y < width*3/80.0; y++) {
gfx.PutPixel(cx  + x - width*5/16.0, cy  + y + width/4.0, 0, 0, 0);
gfx.PutPixel(cx + x + width/16.0, cy  + y + width/4.0, 0, 0, 0);
}
}

inc = 1;

for (int x = 0; x <= width/10.0; x++)//black moustache triangles
{
for (int y = 0; y<inc; y++)
{
gfx.PutPixel(cx + y + width/40.0, cy + x+ width * 3 / 16.0, 0, 0, 0);
gfx.PutPixel(cx  - y - width/40.0, cy + x+ width * 3 / 16.0, 0, 0, 0);
}
inc = inc + 0.85;
}

Hope you can use this making games where Chili munches poo , Chili in maze games and others
Attachment:
chili_drawing.png [9.18 KiB]

_________________
Kraut

 Post subject: Re: resizable Chili-head  Posted: April 12th, 2017, 1:47 pm

Joined: December 31st, 2011, 4:53 pm
Posts: 3525
Location: Japan
Haha, this is pretty sweet Looks like it took quite some effort to pull off. Thanks for sharing bro!

_________________
Chili

Display posts from previous:  Sort by

 Page 1 of 1 [ 2 posts ]

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

 Search for: