Post

 Resources 

Console

Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VBGamer
 VBGamer
 static members

Note: You must be registered in order to post a reply.

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List Spell Checker
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

   Insert an File
Check here to include your profile signature.
Check here to subscribe to this topic.
    

T O P I C    R E V I E W
Sr. Guapo Posted - Jul 12 2004 : 02:24:18 AM
I know it's late, but it's summer vacation!!!

Anyway, I am playing around and making various game frameworks. In my current one, there is a "Enemy" class that will contain all the info I need about that enemy. However, I currently have it so it stores a mesh for each instance of the class (ditto for textures, animations, etc.). I only need ONE copy of each mesh for all the instances of the class (there will only be a few types of enemies, but more than one of each type at a time).

Remembering my OO knowledge in CS1, I decided to make a static variable to hold the mesh. However, VB.NET is throwing an error at me. From what I can tell fom F1, you cannot create a static variable at class level (only block/method level). This doen't make any sense to me. Is there another type declarator (is that a word?) that I should be using?

PS - I want to avoid any global vars as well, so don't try to suggest those. Thanks.
5   L A T E S T    R E P L I E S    (Newest First)
Sr. Guapo Posted - Jul 12 2004 : 1:22:36 PM
OK, that seems reasonable. The main reason I want to avoid globals is so if I ever want to make a reusable engine, I don't want the driver form to have direct acces to all the DirectX stuff. Obviously the D3D Device will have to be global, since multiple classes must have access to it. However, the only class that needs the models and textures is the enemy class.

So VB's static keyword is different from C++ and Java? I know in those languages, a staic variable will just store a single instance for all instances of the class, however it seems to be different in VB. Whatever, your solution seems to work. Thanks.
Eric Coleman Posted - Jul 12 2004 : 1:16:21 PM
Or
Dim G as New GraphicsClass, H as New GraphicsClass
G.LoadFile("file.graphics")
H.LoadFile("file2.graphics")

Set clsEnemy1.Graphics = G
Set clsEnemy2.Graphics = G
Set clsEnemy3.Graphics = H
VBBR Posted - Jul 12 2004 : 09:56:15 AM
Oh yeah, now I remembered, that's exactly what I'm doing
Just use a "graphics database" class and reference the model with a number. Then call GraphicsDB.Load(Number), GraphicsDB.Copy(Number) or something like that.
Eric Coleman Posted - Jul 12 2004 : 09:08:09 AM
Instead of having the class keep a copy of the geometry, create a graphics class that can hold the model. Then all instances of the Enemy class can reference a single instance of the geometry associated with that instance.
VBBR Posted - Jul 12 2004 : 06:32:46 AM
Uh... well... for me global vars are the only (or better) option...

VBGamer © Go To Top Of Page
This page was generated in 0.08 seconds. Snitz Forums 2000

Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.