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.

AppGameKit Classic Chat / Include command?

Author
Message
sovr
14
Years of Service
User Offline
Joined: 2nd Jan 2010
Location: USA
Posted: 14th Jan 2012 06:50
Hello, I have been pondering about the include command built into agk. Is this command made for adding additional files to your application? If so how do you use it? Thanks a lot

sov the game creator!
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 14th Jan 2012 08:18 Edited at: 14th Jan 2012 08:19
Quote: "Is this command made for adding additional files to your application?"

Certainly is. It allows you to 'include' multiple source code files into your project.

Quote: "If so how do you use it?"

Best done with an example. Say this is your 'main' file.



Then you have this in a separate file (which we will call 'functions'):


The #include allows the contents of the 'functions' file to be used in the 'main' file. So this will compile and run as expected.

Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 14th Jan 2012 09:13
You can also declare types and globals in included files. But not constants at moment.

=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 14th Jan 2012 19:24
@Digial Awakening:
I'm using constants in an included file and haven't had any problems with them so far.

I just tested it, in my system.agc file, I declare true and false as constants. Then in the main file, I simply printed out the value of true on screen in a loop.

It returned 1 as expected.

sovr
14
Years of Service
User Offline
Joined: 2nd Jan 2010
Location: USA
Posted: 14th Jan 2012 19:44
thanks this has really helped!

sov the game creator!
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 14th Jan 2012 21:25
A word of warning declaring types in included files, I have had problems where types stop being recognised after a project gets to a certain size. The only solution I have found is moving all UDT declaration into the main file.

=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 14th Jan 2012 22:47
@Baxslash:
Thats what I'm doing. When u say "a certain size", how big are we talking?

I've not experienced this yet either.

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 16th Jan 2012 09:38
Quote: "Thats what I'm doing. When u say "a certain size", how big are we talking?

I've not experienced this yet either."

I haven't pinned that down yet. If I could replicate it easily I would post the bug. For now it's easier in the time I have (which isn't much) to just get on with my game.

My game is getting rather large (about 6500 lines so far). I think the problem started about 3000 lines ago. I am using 7 included files to organise my code a little.

=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 16th Jan 2012 10:24
@Baxslash:
Ok, my current AppGameKit project is about 1500 lines over 7 files. I'll keep an eye out for if/when I start having issues.

Login to post a reply

Server time is: 2024-11-23 00:11:37
Your offset time is: 2024-11-23 00:11:37