May 04, 2024, 10:21:04 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


src inc and projects

Started by J B Wood (Zumwalt), May 12, 2006, 06:05:37 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

J B Wood (Zumwalt)

KICK ARSE!!!!
I got my class to work and my distance to object to work, and my targeting to work, and ... HOLY CRAP THIS IS COOL
sorry, overwhelmed, I made 1 change to my little application and now I got tracking done

Kale

Great example Paul, but i notice that you didn't have the class declaration in the src file. If i do that i get errors telling me that theres an unknown class.

Here's my example that works:

Desktop.inc:

class CDesktop
{
int Width;
int Height;
VECTOR2 Resolution;

declare GetWidth(), int;
declare GetHeight(), int;
declare GetResolution(), VECTOR2;
}


Desktop.src:

#define SM_CXSCREEN 0
#define SM_CYSCREEN 1

declare import, GetSystemMetrics(int nIndex), int;

class CDesktop
{
int Width;
int Height;
VECTOR2 Resolution;

declare GetWidth(), int;
declare GetHeight(), int;
declare GetResolution(), VECTOR2;
}

CDesktop::GetWidth(), int
{
Width = GetSystemMetrics(SM_CXSCREEN);
return Width;
}

CDesktop::GetHeight(), int
{
Height = GetSystemMetrics(SM_CYSCREEN);
return Height;
}

CDesktop::GetResolution(), VECTOR2
{
GetWidth();
GetHeight();
Resolution.x = Width;
Resolution.y = Height;
return Resolution;
}


Main.src:

#include "Desktop.inc"

global sub main()
{
CDesktop Desktop;

print("Desktop Width: " + str$(Desktop.GetWidth()));
print("Desktop Height: " + str$(Desktop.GetHeight()));
While (GetKey() = "")
{

}
}


This all works fine, but notice that the code:


class CDesktop
{
int Width;
int Height;
VECTOR2 Resolution;

declare GetWidth(), int;
declare GetHeight(), int;
declare GetResolution(), VECTOR2;
}


Appears twice. Once in the include and once in the source file. If i take it out of the source file the compilation fails. Is this correct?

J B Wood (Zumwalt)

August 11, 2006, 11:45:24 AM #27 Last Edit: August 11, 2006, 11:53:00 AM by zumwalt
You got something screwy going on then, make sure the sources are in your project, this only works for projects.

My project ONLY has the source files in it, and the src files include the #include to the inc that holds the definitions.

I'll post it up even though I am really not ready with it yet, some features not in it that will be hopefully up over the weekend, give me a little bit to update the project on the web link for the mech thingy.

edit:

Ok take a look at the blast a mech game project, its very rough, alot on paper not in it at the moment but wanted to post what I had done for this discussion.

Ionic Wind Support Team

In the desktop.src implementation file just include "desktop.inc" and you won't need it twice then. ;)
Ionic Wind Support Team

Kale

Quote from: Paul Turley on August 11, 2006, 04:59:59 PM
In the desktop.src implementation file just include "desktop.inc" and you won't need it twice then. ;)

So '#include "desktop.inc"' goes at the top of 'Desktop.src' and 'Main.src'?

J B Wood (Zumwalt)

Yes, it goes at the top of every SRC that calls one of the functions in the SRC the INC refers to.