2016-03-11 18:26:32

Hi.

I wan't to set properties for every field when my map is created.

 // Resize the map.
 map.resize(41);
 for(uint i=0; i<map.length(); i++) {
 map[i].resize(41);
 }
 
 // Set start position
 myX=0; myY=0;

I think i need to make a class or something
So i fx. can say:
block.getType(); // And it would return a string
saying fx. grass, stone, sand or snow?

Can someone help me :)
If you need more information just ask.

Thanks.

If you like what I do, Feel free to check me out on GitHub, or follow me on Twitter

2016-03-12 00:16:28

Hi,
There is no map class in BGT's core standard libraries. Can I freely assume that the map object is in array, a vector, or a dictionary?
If the map object is an array:
1. Resize it (I've seen that you've done that already)
2. To set all items in an array to something, do something like:

for (int i = 0; i <= map.length(); ++i)
map[i] = <value>;

To remove all values from the map array, do something like:

for (int i = 0; i <= map.length(); ++i)
map.remove_at (i);

If that fails, just reply to this thread with what happens and we'll try to come up with a different solution.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.
My Github

2016-03-12 04:18:04

ethin you are correct, there is no map object in bgt by default. Really, I wouldn't recommend arrays for this, as it scemes to make things a bit more clunky to set up. I'd recommend dictionaries.

I am a web designer, and a game developer. If you wish see me at http://www.samtupy.com

2016-03-13 02:40:41

Sam_Tupy wrote:

ethin you are correct, there is no map object in bgt by default. Really, I wouldn't recommend arrays for this, as it scemes to make things a bit more clunky to set up. I'd recommend dictionaries.

Can you show some kind of example with a dictionary?
Also i know that isn't a default map object or class in bgt.

If you like what I do, Feel free to check me out on GitHub, or follow me on Twitter

2016-03-13 02:42:25

Ethin wrote:

Hi,
There is no map class in BGT's core standard libraries. Can I freely assume that the map object is in array, a vector, or a dictionary?
If the map object is an array:
1. Resize it (I've seen that you've done that already)
2. To set all items in an array to something, do something like:

for (int i = 0; i <= map.length(); ++i)
map[i] = <value>;

To remove all values from the map array, do something like:

for (int i = 0; i <= map.length(); ++i)
map.remove_at (i);

If that fails, just reply to this thread with what happens and we'll try to come up with a different solution.


hm. Then i could set a dictionary as the value or something.
But let's say that i did that. How would i get the right data for x and y.

If you like what I do, Feel free to check me out on GitHub, or follow me on Twitter

2016-03-13 03:38:30

Very simple:
1. Create a dictionary object (let's call it "obj" for the sake of demonstration).
2. To set a key and value:
// Let's set a key called "Key1" and set Key1's value to 10000.
obj.set ("Key1", 10000);
To get a value from the dictionary named "obj", do:
int obja;
obj.get (keyname, out_variable); //replace "keyname" (excluding the quotes) with the name of the key you wish to get, and "out_variable" (excluding the quotes) with the variable to receive the value.
HTH

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.
My Github

2016-03-13 05:20:56

Ethin wrote:

Very simple:
1. Create a dictionary object (let's call it "obj" for the sake of demonstration).
2. To set a key and value:
// Let's set a key called "Key1" and set Key1's value to 10000.
obj.set ("Key1", 10000);
To get a value from the dictionary named "obj", do:
int obja;
obj.get (keyname, out_variable); //replace "keyname" (excluding the quotes) with the name of the key you wish to get, and "out_variable" (excluding the quotes) with the variable to receive the value.
HTH

Yes but when the map is created i have a array (map) how do i find the data for a coordinate.
fx. x 5 and y 7
or x 13 and y 4

I would think that the easyst way to do it would be with a map class or something like that...

If you like what I do, Feel free to check me out on GitHub, or follow me on Twitter