Sign in to follow this  
newborn

Unity VB.NET: Module or Class ?

Recommended Posts

Hello community! I'm a self thought hobbyist programmer and I'm currently debating something. English ain' my first language, so please bare with me :) I need your opinions (pro/cons) to have a wider vision on this. I'm currently using VB.Net and a 3D engine (Truevision3D) which takes care of the models loading, textures loading, bsp loading, DirectX stuff like rendering, etc etc etc. (A very complete engine to say the least). Anyways, the point I'm debating is this: should i use calls from a module or should I wrap the whole engine under a class and then create another layer over DirectX calls? ie, at the loop sequence, we should get something like this: Do clsPlayer.Update clsWorld.Update clsEngine.Update clsEngine.Render Loop I know there are some CPU/FPS consequences to wrap everything under a class (ie: game.load, game.render, game.quit). I'm not sure whats the difference in overhead of calling a class member vs a global member (module)... [Edited by - newborn on August 17, 2004 2:09:03 PM]

Share this post


Link to post
Share on other sites
Usually you will want to avoid global variables, but that is not always neccesary. Just use whichever seems more comfortable. If you prefer to use the OO approach (classes) and like the idea of objects controlling the game, use them. If you just want to get the code out of you form code and don't like the class, then use a module. I think I woiuld go for a class, but that is just my opinion.

You really ahould not be worrying about speed yet. Worry about that when you finish the game and it only runs at 5 FPS. Get it working first. It is always good advice, but it is often hard to follow (I know it is for me). Just write the code that works, no matter how ugly, then clean it up once you finish. I realize it sounds like extra work, but it will definately pay off.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
If you're writing a game, I'd worry about at least making it somewhat efficient as you go.... you don't want to code the whole thing then find out you have to change 20000 lines of code to make it stop crawling at that 5fps you mentioned.... what ever happened to the days of optimization? Has all code really gotten THAT sloppy?! I'd optimize it class by class/function by function if I were you... just a thought... optimized code can make you... sloppy code WILL break you....

Share this post


Link to post
Share on other sites
I am not saying to write sloppy code. I said that you should do optimization last. If you have good code design and good planning, you game will probably run fine without optimizations. Sorry about the confusion...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this