What is this?
Every LDK object and method that is not a color, rectangle or point is referenced through an object called the game object. That is, scenes, collisions, objects etc are all manipulated from here.
That is not to say that you cannot create a variable to act as a pointer to an object. The creation of that object, however, must be done through the object game.
You create a new game using this code: game=new game(); Having more than one game is pretty redundant as LDK restricts the number of scenes per page to one.

The LDK library has its own math functions, mostly because I keep on forgetting to put in the capital M in the javascript methods for math. A game can reference the following mathmatical methods:
max(a,b) - this returns the maximum of a and b
min(a,b) - take a wild guess?
diff(a,b) - This returns the distance from a to b
dist(a,b) - a and b are two points. This returns the distance between them
midI(a,b,m) - this function returns the number m% of the way between a and b. Think of a number line to get what I mean
pointsToRect(a,b) - this function returns a rectangle made up of points a and b
pointInRect(p,r) - this returns true if point p is in rectangle r
rectInRect(r1,r2) - this returns true if the two rectangles r1 and r2 overlap
rRect() - this returns a random rectangle within the confines of the screen
rSquare(s) - this returns a randomly positioned square within the confines of the screen. If you like, you can specify the size of this square with s - or ignore s, and a square from 50 to 300 pixels in size will be generated.

Is that all?
Hell no! These are just some simple math functions. Almost all the other pages have additional methods of the game object described!

Variables and the LDK library
LDK prefixes all it's variables with ldk to avoid confusion. Therefore, do not start any of your variable name with "ldk".

Last edited Dec 13, 2009 at 9:21 PM by larztheloser, version 1


No comments yet.