Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK .NET / Object3D instancing

Author
Message
Commodore VIC 20
10
Years of Service
User Offline
Joined: 14th Feb 2012
Location:
Posted: 16th Feb 2012 23:27 Edited at: 17th Feb 2012 15:48
Hi,

I received the "Your message appears to contain bad language, please edit it out." error when I tried to post this, but have no idea why. I have attempted to include it as an attachment. Here is the original post. The code and log output are contained in the attachment. Thanks.
---------
Hi,

I have written the following program that creates two teams, each containing three copies of the sample ColonelX animation. Each one is an instance of Object3D, as inherited by the Character class. This class has a Team and Num property, set to TeamA[0-2] and TeamB[0-2] in the GameLoop subroutine. When I run the program, it behaves as expected on the screen, but the log output reports that every Character is "Team B Character 2". This suggests that the logging instance of Character is always this one, rather than the succession of Characters that I would expect.

Question: How can I create a separate instance of Character for each of the elements in TeamA and TeamB? Any other comments about architecture or coding practice would be appreciated.

Bonus Question: Why does TeamA always win?

Attachments

Login to view attachments
Creating Game
13
Years of Service
User Offline
Joined: 21st Oct 2008
Location:
Posted: 17th Feb 2012 22:57
here the error

Private Shared msTeam As String = ""

Private Shared miNum As Integer = 0

using Shared attribute means those field are common to every instance of the class. Cause "Team B" and 2 are the last assigned value to those field every objects report to be Team B num 2
Commodore VIC 20
10
Years of Service
User Offline
Joined: 14th Feb 2012
Location:
Posted: 1st Mar 2012 02:34
YES! Thanks!

Login to post a reply

Server time is: 2022-08-07 16:57:15
Your offset time is: 2022-08-07 16:57:15