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 / AGK multi-dimensional arrays, assigning values shorthand

Author
Message
ABlantzer
11
Years of Service
User Offline
Joined: 6th Aug 2012
Location:
Posted: 7th Aug 2012 06:36
Hi,

Not sure if this is the correct forum to post this question in, so apologies if it is not. I also searched extensively here and elsewhere for an answer to this question and couldn't turn anything up.

I was wondering if there is a shorthand way for assigning values to a multi-dimensional array.

Right now, I have an array like this:
dim Positions[4,2]
Positions[1,1] = 100
Positions[1,2] = 110
Positions[2,1] = 59
Positions[2,2] = 346
etc.

Is there a shorthand way of doing this? I tried:
dim Positions[4,2] = [[100,110],[59,346], etc ]

But this gave me a compile error. What are my options here?

Many thanks!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 7th Aug 2012 12:07
Are all of these values hard-coded as you have shown here? If they are, then I would save them in a text file and use the file reading commands to load them in, in a loop.

Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 7th Aug 2012 12:49 Edited at: 7th Aug 2012 12:51
You can do this:



Edit I should say to carefully note how the array is filled. It may not be filled how you think it is.

Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 7th Aug 2012 12:53
You can create your own function using a string. But it will be limited, easiest if you are only using a single array.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 7th Aug 2012 16:54
ABlantzer, sorry, in Tier 1 there is no shorthand for loading a multi-dimensional array (works fine in Tier 2). But try Hodgey's example and you should be able to figure out the order it gets stored in if you use a single dimension and then you'd be set.

Cheers,
Ancient Lady
AGK Community Tester
ABlantzer
11
Years of Service
User Offline
Joined: 6th Aug 2012
Location:
Posted: 7th Aug 2012 18:45
BatVink, they are hardcoded, but there are only a handful of value-pairs so I don't see any point in using an external file. I started out in Perl, so I like multi-functional lines

Hodgey, looks promising! Will try it out.

Ancient Lady, what is Tier 1 vs Tier 2? Sorry, I'm very new to AGK.
XanthorXIII
AGK Gold Backer
12
Years of Service
User Offline
Joined: 13th May 2011
Location:
Posted: 7th Aug 2012 19:52
Tier 1 is AppGameKit Basic and Tier 2 is C++. I work in Tier 2 and while its more challenging, you can do stuff that Tier 1 cannot. If you have the time to learn C++ I would highly encourage it. If you just want to get a game going Tier 1 will do the trick as well. But I still would encourage you to learn C++
ABlantzer
11
Years of Service
User Offline
Joined: 6th Aug 2012
Location:
Posted: 7th Aug 2012 23:19
I'm actually a lot better with C++ than with Basic How do I set up for using C++ in my games? I've looked here:
http://www.appgamekit.com/go-native.php

Where do I find the library agk.h? And where do I find the templates that they mention on that page?
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 8th Aug 2012 11:53
Try watching this:



3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 9th Aug 2012 01:41
I think c++ is worth buying from microsoft it cost 500 for professional and less for standard, but I use the schools version of professional which allows tuition to cover development, and it is better then buying c++. I bought 2003 version and still use it today, but finding it is getting outdated.

Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps. Developed the tiled map engine seen on the showcase. Veteran for the military.
Dar13
15
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 9th Aug 2012 03:34
Quote: "I think c++ is worth buying from microsoft it cost 500 for professional and less for standard, but I use the schools version of professional which allows tuition to cover development, and it is better then buying c++. I bought 2003 version and still use it today, but finding it is getting outdated."

Visual Studio is crazy expensive if you're not a student or a professional developer. Code::Blocks and the new Dev-C++(not the one on that old-looking site, it takes some searching) are pretty good C++ IDEs with a large user-base and good support. Plus they use GCC, which is the best C++ compiler out there(though Clang and VC++ is catching up).

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 9th Aug 2012 16:25
Quote: "I think c++ is worth buying from microsoft"

Why buy it? The Visual Studio Express edition is free and works just fine with AGK.

@Dar13, at this time AppGameKit doesn't work with other compilers for Windows compilations. It does use GCC when doing Tier 2 Android compilations.

Cheers,
Ancient Lady
AGK Community Tester

Login to post a reply

Server time is: 2024-05-06 20:19:18
Your offset time is: 2024-05-06 20:19:18