Jump to content

2D Polygon library


IvanK
 Share

Recommended Posts

Hello,

 

let me introduce you my new open-source library  PolyK - http://polyk.ivank.net . It is written in pure JavaScript, without any bindings to DOM, CSS or anything else.

 

It is a set of several functions, which take an array of numbers and process it. It my be useful for some games, but you can use it even for non-graphical computation. 

 

I have several ideas for games, which may use that library. I don't have a time to make them, but maybe you will :)

  • you click on some button in the middle of labyrinth (polygon) and you have to get mouse cursor out without touching the polygon. (PolyK.ContainsPoint)
  • using PolyK.ClosestEdge you can test intersection with polygon and circle. You can make balls bouncing inside the polygon and then a character, which should go throught the polygon avoiding those balls.
  • You can make car racing. Real physical models (Box2D, Bullet) are usually bad for car racing. With PolyK you can make pseudo-physical model. If you attach Z coordinate to road points and interpolate it, you can make 3D racing with jumping above the road, just like Need for speed :)
  • With raycasting, you can test visibility between 2 points throught polygon. You can make your secret agent character run through the map while avoiding guards.
  • Using Slice function, you can do something like Fruit ninja, but with multiple slicing and much interesting shapes.

Link to comment
Share on other sites

@rich: yes, I was thinking about adding support for affine transformations, but nobody needed it yet. But I can add it in version 0.3 . One can come up with lots of operations on polygons, but I think it is a bad idea to add them, until somebody needs it.

BTW. set operations on polygon would be cool (intersection, difference). With difference, you can "cut" polygons from polygon and e.g. make destroyable terrain, like in Worms.

Link to comment
Share on other sites

For me I would consider a transform (or at the very least just rotation) to be much more essential than destroyable terrain :)

 

(but far less fun I guess!)

 

Then you could map a polygon to a sprite and use it in a game, which would be extremely neat!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...