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 / Use a string as a variable name?

Author
Message
bigtunacan
9
Years of Service
User Offline
Joined: 24th Jul 2015
Location:
Posted: 22nd Jan 2017 19:43
Is there a way to use a string as a variable name?

I'm trying to load up large sets of tiles that use a standard naming convention so I end up doing something like this...



In some languages I am able to build a string and use that as a variable name which reduces the work a lot.

In Ruby I could do something like

damothegreat
User Banned
Posted: 22nd Jan 2017 20:19 Edited at: 22nd Jan 2017 20:26
Maybe something like



or something along those lines

Damo
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 22nd Jan 2017 21:12
like this?

AGK (Steam) V2017.01.09 : Windows 10 Pro 64 Bit : AMD (16.12.1) Radeon R7 265 : Mac mini OS Sierra (10.12.2)
MikeHart
AGK Bronze Backer
21
Years of Service
User Offline
Joined: 9th Jun 2003
Location:
Posted: 23rd Jan 2017 11:39 Edited at: 23rd Jan 2017 11:41
@damothegreat: In your example



you are loading the 3 images in total 1000 times and so create 1000 images internally. I wouldn't be surprised if you run out of memory in some point.

Or is AGK2 so smart to return the previously returned index of an image that was already loaded before? If yes, that could be sometimes an unwanted feature.
Running Windows 7 Home, 64 bit, 8 GB ram, Athlon II X2 255, ATI Radeon HD 4200. Using AGK2 Tier 1.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 23rd Jan 2017 11:55
You would get 1,000 copies of the same image.
This method is only recommended for a one-off load. For example, a background image that will exist throughout the whole game (including menus, repeat games etc)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
damothegreat
User Banned
Posted: 23rd Jan 2017 13:24
I suppose we can use any technique depending on the nature of the game requirement


Login to post a reply

Server time is: 2024-11-24 20:46:15
Your offset time is: 2024-11-24 20:46:15