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 / New to AGK can it use arrays for co-ordinates for example ?

Author
Message
DemonHill
16
Years of Service
User Offline
Joined: 20th Mar 2008
Location:
Posted: 8th Sep 2013 18:24
I have been using Darkbasic pro for many years and have down loaded the AppGameKit Trail version to try.

Can you use arrays in AppGameKit , as I want to create a race track and store the coordinates in arrays ?

How might I do this and is the basic language quite a bit different from DB pro ? Thx

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 8th Sep 2013 18:55
The arrays in AppGameKit are very similar to DBPro, you just use [] square brackets instead of () ordinary parenthesis.

IE.

You can also use UDTs and multi-dimensional arrays just like DBPro

"Everything should be made as simple as possible, but not simpler."
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 8th Sep 2013 19:29
The only thing you can't do at the moment are the dynamic lists/arrays that DBP can do. That will be available in v2.

Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 8th Sep 2013 21:20
I think arrays in agk are better than in dbpro. I don't use lists so don't need those commands.

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 8th Sep 2013 23:06
You can use dynamic arrays in AGK. Just resize the array as you need to, I always start my arrays:

...and when I need to make it bigger I just re-dim to make it bigger. Unless you're doing it hundreds of times per frame it's plenty quick enough too.

"Everything should be made as simple as possible, but not simpler."
Zwarteziel
13
Years of Service
User Offline
Joined: 22nd Jan 2011
Location: Netherlands
Posted: 9th Sep 2013 00:25
Quote: "You can use dynamic arrays in AGK. Just resize the array as you need to"


This is indeed a fine method. However, I've had some trouble with re-dimming arrays from within functions in the past. Do you happen to know if this has been fixed? (Not at a PC at the moment, so I can't test it myself)
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 9th Sep 2013 00:50
I haven't had any problems re-dimming from within functions but I don't use multi-dimensional arrays much. Works fine for single dimension UDT or standard type arrays for me.

"Everything should be made as simple as possible, but not simpler."
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 9th Sep 2013 01:29
There is a posted and confirmed issue with re-dimming multi-dimensional arrays. And I don't think anything has been deliberately done to fix it. I haven't tested it lately.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 9th Sep 2013 15:49
Quote: "You can use dynamic arrays in AGK. Just resize the array as you need to, I always start my arrays:"


I would approach it slightly differently. Lists in java (and probably other languages) size an array for more than what you currently need but just use an internal variable to point to the maximum element index. The extra empty elements aren't counted in the total but are still set aside to reserve space for future additions to the list. Once the limit is reached, the next addition will expand the array by 10 or more. This way, the array isn't being swapped with every addition.

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 9th Sep 2013 16:10
Actually I do something similar if it's an array I'm accessing a lot, for example I often take that approach for my particle systems, particularly if I have a game that's not running very fast but if it's something that's not changed very often you don't need to. It's probably better practice to do it your way though.

As I said:
Quote: "Unless you're doing it hundreds of times per frame it's plenty quick enough"


I guess as usual it depends on the game.

"Everything should be made as simple as possible, but not simpler."

Login to post a reply

Server time is: 2024-11-24 19:57:00
Your offset time is: 2024-11-24 19:57:00