Post

 Resources 

Console


RE: Class modules Adam Hoult (1 reply, 0 views) (2000-Apr-8)
-
Hi carl, Right well classes are certainly not useless, they are the lifeblood of pretty much any game, for example say you had a class called enemy and this enemy class contained variables for it's position, it's health, it's state etc. You may say ok, thats cool but i can do that with a type. Yes you could, but in classes you can have functions/subs too. For example If you had an array of enemy classes like this Dim MyEnemies(40) as new Enemy Now you could store each enemies positions simply by setting the class variables like this MyEnemies(12).XPos = 32 MyEnemies(12).YPos = 46 etc Now as I mentioned before, you can have functions inside classes, so for example you could do something simple like this MyEnemies(12).DrawEnemy or MyEnemies(12).UpdateAI things like that. Yes this can all be achieved by using types and arrays, and functions which access arrays, but Classes can be dynamically destroyed and created etc. Now classes in VB (in my experience) are slightly slower than using arrays but not by much, it depends on how easy you want your coding to be =) Take a look on <http://www.vbexplorer.com> im pretty sure there is an article on classes there. HTH Adam


-
Up One Level | Back to Forum

Thanks Adam. *nt Carl (0 replies) (2000-Apr-8)

Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.
There have been 27 visitors within the last 20 minutes
RSS News Feed