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...
for j = 0 to 3
game_pieces[i].smallSprite = CreateSprite(cloud_g_img)
i = i + 1
next j
for j = 0 to 3
game_pieces[i].smallSprite = CreateSprite(clover_g_img)
i = i + 1
next j
// Repeat 1000 more times...
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
["cloud", "clover", "drop"].each do |shape|
for j in 0..3 do
game_pieces[i].smallSprite = CreateSprite(instance_variable_get("@#{shape}")
i = i + 1
end
end