XNA Game Development Forums
2012/05/18 06:05:28 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Calendar Login Register  
Pages: [1]
  Print  
Author Topic: Loading another project in runtime  (Read 3029 times)
LucianX
Jr. Member
**
Offline Offline

Posts: 66



View Profile WWW
« on: 2007/02/20 12:40:07 »

Hello, I am programming a simple RPG in xna. I have a town project and a battle project. The battle project is at 5000+ lines of code and the town part is about 600. I would rather not combine them since the town part is written in XNA and the other part is written in C#. They both load in C# Express 2005 but Im not sure what code I have to put to be able to load the other project during runtime? When the character collides with the enemy on the map, it would exit the town part and load the battle portion. How would I be able to do this? I know how to exit the town but not load the other project. It's already added to the project just don't know the code line(s) needed.

Also,

If anyone is good with collision.. how would I make two sprites collide if they were loaded into memory from this code:

                ForegroundBatch = new SpriteBatch(graphics.GraphicsDevice);
                BackgroundBatch = new SpriteBatch(graphics.GraphicsDevice);

                MainChar[BartzFront] = content.Load<Texture2D>("./Content/Sprites/BartzFront");
                MainChar[BartzLeft] = content.Load<Texture2D>("./Content/Sprites/BartzLeft");
                MainChar[BartzRight] = content.Load<Texture2D>("./Content/Sprites/BartzRight");
                MainChar[BartzBack] = content.Load<Texture2D>("./Content/Sprites/BartzBack");

                Maps[Coneria] = content.Load<Texture2D>("./Content/Maps/Coneria");

                Enemy[Imp] = content.Load<Texture2D>("./Content/Sprites/Imp");


The animations part for the main character is right here:

        protected void CalculateDirection(SpriteBatch Batch)
        {
            if (left == true)
            {
                Batch.Draw(MainChar[BartzLeft], new Rectangle(spriteX, spriteY, 25, 25), Color.White);
            }
            if (right == true)
            {
                Batch.Draw(MainChar[BartzRight], new Rectangle(spriteX, spriteY, 25, 25), Color.White);
            }
            if (up == true)
            {
                Batch.Draw(MainChar[BartzBack], new Rectangle(spriteX, spriteY, 25, 25), Color.White);
            }
            if (down == true)
            {
                Batch.Draw(MainChar[BartzFront], new Rectangle(spriteX, spriteY, 25, 25), Color.White);
            }
        }


Thanks for your time  Smiley
Logged
Nemo Krad
Global Moderator
Hero Member
*****
Offline Offline

Posts: 512


I have seen the fnords


View Profile WWW
« Reply #1 on: 2007/02/21 01:45:12 »

Now I don't know why you have gone about your application like this so I am assuming this is a design flaw in your approach to the game.

What I would have done is to have ALL the battle functionality (in it's own project) compiled to a DLL and then reference this DLL from my Game assembly.

As far as your 2D collisions stuff goes, I have not done much in the way of 2D games, so cant help you there. If you were using mesh's then you could use the mesh's bounding spheres. Can you not check if the items over lap using there coords along with there height and widths?
Logged
LucianX
Jr. Member
**
Offline Offline

Posts: 66



View Profile WWW
« Reply #2 on: 2007/02/21 10:53:12 »

How would I load the dll from the other project?
And how do i make it into a .dll?

Me and 2 others were working on this, and I made a seperate project from theirs that we would combine when we are finished. It's not a full game but it shows some aspects of an rpg.
Logged
mikeschuld
Administrator
Sr. Member
*****
Offline Offline

Posts: 389


View Profile WWW
« Reply #3 on: 2007/02/21 11:56:15 »

You can change the project type in the properties to be a Library. As long as it is not set as a startup project when things are run (during debug etc.) that will work fine.
Logged
LucianX
Jr. Member
**
Offline Offline

Posts: 66



View Profile WWW
« Reply #4 on: 2007/02/23 09:41:47 »

Thanks.. but how do i execute this other main method during runtime?
Logged
mikeschuld
Administrator
Sr. Member
*****
Offline Offline

Posts: 389


View Profile WWW
« Reply #5 on: 2007/02/23 09:48:56 »

There is no other main method... You will have to use instances of the objects in the .dll in a function in your main project.
Logged
Nemo Krad
Global Moderator
Hero Member
*****
Offline Offline

Posts: 512


I have seen the fnords


View Profile WWW
« Reply #6 on: 2007/02/23 11:53:47 »

Basically, you need to put your Battle functionality into classes that can me used by the game project. Once they are in classes and referenced from the Game project you can create instances of the classes and use there functionality in the game assembly.
Logged
Tiago
Newbie
*
Offline Offline

Posts: 42


View Profile
« Reply #7 on: 2007/03/12 14:31:39 »

i think his problem is that he has his battle UI in the other project and im gessing it uses windows forms controlls so he cant exactly port them to XNA.

try System.Diagnostics.Process class, dont know how it works exactly but you can google it up or check MSDN documentation for that.

i do think its not good game design but hey, its your game and at least youll learn how to use processes (not fun by the way)

you might want to consider creating a Form in your town project and put your battle code there so you can just call your form (maybe as a dialog) whenever you have a battle. im not too shure that would work either but if it does it will make things a lot easier for you spacially concerning process parameter passing (not fun either)

hope that helps a bit
Logged
Pages: [1]
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Having problems with my project Hazy Mind XNA Engine Twanks 10 3678 Last post 2006/11/18 09:51:53
by mikeschuld
Cannot open project tutorial Hazy Mind XNA Engine kebaboom 9 3172 Last post 2006/11/10 19:44:33
by mikeschuld
Project Hoshimi General Discussion Nemo Krad 2 1276 Last post 2007/01/25 04:20:57
by h4rdc0m
How to update position of meshes in Hazy Mind Demo project? Hazy Mind 3D Engine Trefall 1 1974 Last post 2007/03/12 11:27:26
by Robin Sarac
Question about loading textures General Discussion nicknz 2 1957 Last post 2007/04/23 05:36:17
by EclipsE
Loading a model in runtime? General Discussion XNASorcerer 10 3303 Last post 2007/05/06 21:22:42
by XNASorcerer
BSP/PAK LOADING General Discussion Mikeske 1 1964 Last post 2008/07/26 00:50:51
by Mikeske
Powered by MySQL Powered by PHP Powered by SMF 1.1.12 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 1.375 seconds with 19 queries.