Structure of my application
Structure of my application
Structure of my application
Structure of my application
Structure of my application
Structure of my application Structure of my application Structure of my application Structure of my application Structure of my application Structure of my application Structure of my application Structure of my application
Structure of my application Structure of my application
Structure of my application
Go Back  Xtreme Visual Basic Talk > > > Structure of my application


Reply
 
Thread Tools Display Modes
  #1  
Old 03-05-2008, 08:47 AM
LivingLegend LivingLegend is offline
Newcomer
 
Join Date: Mar 2003
Posts: 16
Default Structure of my application


Hello,

I am writing a game and so far I have structure as follows:

Sub Main () - Where the game is run and the global variables are declared eg Direct3DDevice, People, Guns

3DEngine Class - Handles all setup, initialisation, render initialisation and cleanup, FPS

3DObject Class ... Handles all 3d Objects
Person Class
Gun Class
Physics Engine Class

.. And about 5 or 6 other classes that I wont bore you with.

Anyway, I was happy with the structure until I wanted to allow multiple games to be played at once. The problem is, I can't create another instance of Sub Main for each game the user is playing, and if I create a 'game' class I can't make any of the variables global which need to be for the other classes to work. I could go to ridiculous lengths to pass all relevant variables from class to subclass etc, but given the lack of inheritance in VB this is a huge task..

Does anyone have an idea how I could structure this better? I am open to any suggestions.

Thanks in advance
Reply With Quote
  #2  
Old 03-05-2008, 08:55 AM
the master's Avatar
the master the master is offline
Tachikoma
 
Join Date: Mar 2003
Location: Mansfield, UK
Posts: 4,596
Default

Why not simply run the exe twice?

Do the values in sub main change for each game?

What about passing all the values to each sub/function as a type? That way its just like 1 variable.

You could also have an array of things in your main module and pass an index to each sub/function so they know which element in the array to work from
__________________
"That which seems simple is often overlooked" ~ me
Halloween 2014 Yard Haunt
Halloween Special FX
Reply With Quote
  #3  
Old 03-05-2008, 09:01 AM
LivingLegend LivingLegend is offline
Newcomer
 
Join Date: Mar 2003
Posts: 16
Default

Hello Master,

Thanks for your fast reply.

I was thinking about all of the above. I started indexing but thought surely there must be a more efficient way... I also created a type passing D3DDevice etc through to other classes but I found I was getting errors when I tried to set the paramaters of it, and it was taking forever to link them all together.
I could run the exe twice but instead I wanted to have 1 server class which handled all the communication and distributed it between the relevant games.

I think looking at the options so far I'll create all the objects as undefined arrays, and then redefine them as and when new games are required...

Is that the easiest (and most efficient way)?

For example : (very roughly)

Dim D3DDevice() as Direct3DDevice8

Function NewGame()
ReDim D3DDevice (NumberOfGames)
- run game class and pass the index of the 3DDevice with it
End Function

Cheers.
Reply With Quote
  #4  
Old 03-05-2008, 09:30 AM
the master's Avatar
the master the master is offline
Tachikoma
 
Join Date: Mar 2003
Location: Mansfield, UK
Posts: 4,596
Default

I take it you mean a dynamic array. That would work but depending on how much information you plan to store in it and how often you plan to add/remove elements i would consider one of 2 things

1) By default add 50 elements to the array. When a game ends you mark the element as unused to you can re-use it again later. You dont have to redim or shift any data about at all unless you get to 51 when you do need to redim. When a game ends though dont remove the element. Keep all 51 elements to save shifting data about

2) Use a collection. Ive been using a lot of these recently where it is a collection of user defined types (in a way). It works the same as dimming an array as a UDT but you can add/remove items without shifting data about or having unwanted elements. You can also assign each item a key that can be used in place of the index.

I didnt realise you were talking about the server. It makes sense now and yes i would make one server handle multiple games instead of running 2 exes
__________________
"That which seems simple is often overlooked" ~ me
Halloween 2014 Yard Haunt
Halloween Special FX
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Structure of my application
Structure of my application
Structure of my application Structure of my application
Structure of my application
Structure of my application
Structure of my application Structure of my application Structure of my application Structure of my application Structure of my application Structure of my application Structure of my application
Structure of my application
Structure of my application
 
Structure of my application
Structure of my application
 
-->