CodeBase - Objects - Safe and Easy 2
Return to the CodeBase listing
Category: Basic 3D
Version: 1.1
Information
Uploaded: 10th Dec 2004 23:05
Modified: 17th Jul 2005 02:01
Author: The Wendigo
Summary
Create Objects Safely and easily in Dark Basic Pro without the fear of overrunning another object.
Full Description
Again, this is example is specifically for Basic 3D object only for simplicity and can easily be adapted to sounds, images, etc... This is a more compact, simpler version.<br /> <br /> This code is very simple but allows the developer a fast and easy way to handle objects, images, sounds, etc.... The basic premise is simply to search through all valid object handles and return the first one that doesn't contain an object.<br /> <br /> Provided your code is organized and all handles to objects are neatly contained, there are no real disadvantages to the code (other than a very minor speed hit). The advantages will save you a future headache. Many times a programmer, even using Constants, will accidentally try to create an object using a handle that is already taken. This, ofcourse, leads to the infamouse object already exists error. By grabbing a handle with FreeObject() you guarantee that the next object handle received is unique and valid eliminating many errors and keeping your code tidier. I don't know how many of us have ever tried to program with objects using Constants for object handles and ended up getting mysterious overwrites, but I know I sure have. Again, this function can be easily converted to check for sounds, sprites, and most anything else requiring a handle... even Memblocks.
Comments
No comments yet.