Note to news posters
I do not permit this Lua code snippet to be placed on ANY news page unless it is posted with the following quote:
2006-07-15This is just a small code snippet for Lua beginners/developers. This is not a release, game or application. Do not treat it as such.
Here is a code library for a vector storage container as well as two demos to show how to use it. PM me if there are any errors in the library. It is basically a high level wrapper round the Lua table functions with bounds checking.
It should also be memory efficent and contain no memory leaks.
Demo 1 shows how and the effects of the functions.
Demo 2 shows how you can use it to draw all your objects in a scene (this one has 100).
Todo
Stack, Queue, Map structures ?
What is a Vector Storage Class?
It is a container that *should* hold multiple objects of one type (eg, a sprite or a number). This makes management of objects in an application much easier to handle and process.
For example, here is the code to draw 100 objects in Demo 2.
Demo 1-- Draw the sprites (Notice how small the code is to draw 100 objects is)
for i = 1, VectorOfHackedSprites:Size() do
screen:blit (
VectorOfHackedSprites:Get(i).Int_XPosition,
VectorOfHackedSprites:Get(i).Int_YPosition,
VectorOfHackedSprites:Get(i).Img_Image
);
end
Demo 2
![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks