Ludum Dare 31
Theme:
Entire Game on One Screen

Judging ends in:
It’s time to Play and Rate Games!

PlayRate80Star

Posts Tagged ‘drawing’

How to draw a Perfect Octagon!

Posted by (twitter: @theupgradezone)
Tuesday, November 11th, 2014 4:45 am

I did some maths while I was bored, and I calculated a way to draw a perfect octagon.
I thought this might come in useful for some of you :3

Warning! Maths ahead!

 

Maths:

Imagine a square, with side length a.

001

Our octagon will fit in this square.

We will call the length of a side of the octagon b.

002

 

Now you put a into this equation:

003

Which can also be written as:

004

And you get b.

Now, round b to the nearest number. We can’t be dealing with fractions of pixels now, can we?

Now you have b, we can draw the octagon.

 

Drawing:

For this example, our reference point will be in the center of the octagon, which is also the center of our imaginary square.

005

Our first 2 co-ordinates will be a/2 up and b/2 to either side.

006

007

For the sides, it will be a/2 to the side and b/2 up or down.

008

Then, draw lines between the co-ordinates to finish the octagon.

009

And there you have a regular octagon!

 

Pseudo code:

Initialize:

size = (length of side of square)
oct_side = round((size*sqrt(2))/(2+sqrt(2)))

Loop:

coord_1x = x – oct_side/2
coord_1y = y + size/2
coord_2x = x + oct_side/2
coord_2y = y + size/2
coord_3x = x + size/2
coord_3y = y + oct_side/2
coord_4x = x + size/2
coord_4y = y – oct_side/2
coord_5x = x + oct_side/2
coord_5y = y – size/2
coord_6x = x – oct_side/2
coord_6y = y – size/2
coord_7x = x – size/2
coord_7y = y – oct_side/2
coord_8x = x – size/2
coord_8y = y + oct_side/2

010

//draw_line(from_x,from_y,to_x,to_y)

draw_line(coord_1x,coord_1y,coord_2x,coord_2y)
draw_line(coord_2x,coord_2y,coord_3x,coord_3y)
draw_line(coord_3x,coord_3y,coord_4x,coord_4y)
draw_line(coord_4x,coord_4y,coord_5x,coord_5y)
draw_line(coord_5x,coord_5y,coord_6x,coord_6y)
draw_line(coord_6x,coord_6y,coord_7x,coord_7y)
draw_line(coord_7x,coord_7y,coord_8x,coord_8y)
draw_line(coord_8x,coord_8y,coord_1x,coord_1y)

 

And that’s how to draw a perfect octagon!

Coming soon: How to draw a perfect hexagon!

 

To those interested in the maths involved to get the equation:

Maths

 

I originally calculated this to be able to draw the Aperture Science logo by hand, but I also saw the use of it on the computer!

The rats are running away from evil scientists!

Posted by (twitter: @sirGustav)
Sunday, April 22nd, 2012 5:19 am

Finally I got a running rat that doesn’t look like shit:

Jumping scientist and running rat

Lunch: Crisp bread with ham+cucumber+cress and caviar/creamed smoked roe+cheese

Even moar rose hip soup!

now Glaucon has some artifacts to search

Posted by
Sunday, August 30th, 2009 6:56 am

yeah baby we have artifacts !! =)

g3758

Glaucon lost in the cave will have to search for some artifacts so he can open the door, and look for some enlighment at the next cave…

Sketch Contest Thing

Posted by
Wednesday, May 21st, 2008 2:16 pm

PoV told me to make shapes and make things out of them, so I did.  I also added notations of what shape made each sketch.  Pardon the complete absence of quality, this is a photo of my sketchpad.

Ham Scribbles

THE CAVES OF INSANITY!!

Posted by (twitter: @philhassey)
Sunday, December 16th, 2007 5:02 pm

Hey – here’s my final entry for LD10. THE CAVES OF INSANITY!! I had a fun time making this game, the highlight being colorinig all those fun backgrounds. Be sure to check ‘em out :) Enjoy the game, it’s pretty short-n-sweet. Download it HERE (win32). Or svn://www.imitationpickles.org/ld10/trunk or HERE (tgz source).

Here’s my wife, our hero, in this game:

philhassey-final-title.png

And here’s a shot from the final level of the game .. it’s a tricker, but this time I did test all the levels and they can all be beaten :) Good luck!

philhassey-final-play.png

[cache: storing page]