We are about to switch to a new forum software. Until then we have removed the registration on this forum.
My code loads down in a straight veins. But i am trying to make it looks like this when it loads in
float [] PlayerPoints;
float [] XColmns;
float [] YColmns;
float [] ColorR;
float [] ColorG;
float [] ColorB;
int [] TileColors;
int [] TileColorChance;
int AmountOfTiles = 1131;
void setup() {
size(975, 830);
XColmns = new float[AmountOfTiles];
YColmns = new float[AmountOfTiles];
ColorR = new float[AmountOfTiles];
ColorG = new float[AmountOfTiles];
ColorB = new float[AmountOfTiles];
TileColors = new int[AmountOfTiles];
TileColorChance = new int[AmountOfTiles];
for (int c = 0; c < 39; c++) {
if ((int)c%2==0) {
for (int N = 0; N < 29; N++) {
XColmns[N+c*29] = 31+c*24;
YColmns[N+c*29] = 30 + N * 27;
} }
else {
for (int N = 0; N < 29; N++) {
XColmns[N+c*29] = 31+c*24;
YColmns[N+c*29] = 43 + N * 27;
} } }
for (int TE = 0; TE < AmountOfTiles; TE++) {
TileColors[TE] = round(random(0, 3));
TileColorChance[TE] = round(random(0, 1));
if (TE > 1) {
if (TileColors[TE-1] == 0 && TileColorChance[TE] == 0) { TileColors[TE] = 0; }
if (TileColors[TE-1] == 1 && TileColorChance[TE] == 0) { TileColors[TE] = 1; }
if (TileColors[TE-1] == 2 && TileColorChance[TE] == 0) { TileColors[TE] = 2; }
if (TileColors[TE-1] == 3 && TileColorChance[TE] == 0) { TileColors[TE] = 3; }
}
}
}//void setup end
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
void draw() {
background(226, 185, 108);
//table
fill(89, 60, 5);
ellipse(-260, -330, 1500, 1500);
//black board
fill(0);
stroke(108, 67, 4);
strokeWeight(30);
rect(0, 0, width, height);
for (int i = 0; i < AmountOfTiles; i++) {
Hexagon(XColmns[i], YColmns[i], 14, TileColors[i]);
}
}//void draw bracket
void Hexagon (float x, float y, float gs, float ColorSelecter) {
//Ocean
if (ColorSelecter == 0) { fill(16, 0, 165); }
//Grassland
if (ColorSelecter == 1) { fill(81, 175, 14); }
//Jungle
if (ColorSelecter == 2) { fill(27, 157, 2); }
//Pond
if (ColorSelecter == 3) { fill(1, 116, 147); }
noStroke();
beginShape();
for(int i=0;i<6;i++){
float angle = i * 2 * PI / 6;
vertex(x + gs*cos(angle),y + gs*sin(angle));
}
endShape(CLOSE);
}
Answers
Please go back and edit your post
Select the code and then click the small C button in the command bar
What exactly doesn’t work...?
Thanks for the reply did i change it right now.
It’s not better
Edit your post with the gear
Empty lines before and after the code section
Select code with mouse
Hit ctrl-t
Chrisir i think i did it now. It was a bit hard to understand but i looked at post on how to set up code in processing forum and i figured it out.
Well done!
not sure what you mean, this has straight lines down too :
remember to hit ctrl-t in processing to get better indents:
see also
https://forum.processing.org/two/discussion/25944/hexagon-pattern
and, further back examples of hex discussion threads:
what i am trying to say is in the image above the forest spawned in a group and the grassland spawned in a group too in random location and in random groups but i do not know how to do that.
Yes, but they could be larger or smaller groups of hexagons.
here is a solution.
thank you for your help you solved it and did a great job. For learning wise what did you change to get it to that.
;-)
lines 65 to 99 - read the comments
also, I made 130 to 158 be an
if....else if ....
structure with error section (else)[EDITED]
lines 65 to 99 :
gotta go
Bye.
Thank you it has been the most help ever i appreciate your time helping me.
You’re welcome!
Chrisir i have a quick question where would you put in conditions on spawning. For example the blue tiles only spawn in if they are touching.
Please explain
the blue tiles only spawn in if they are touching.
Atm between line 70 and 99 just new sections of blocks (eg. a big forest) are build, overwriting and overlapping previous sections. Old colors of hexagons are not looked at at all.
You would need to change the concept of those lines a bit.
Do you need it randomly or could you just use an fixed map of ocean and trees and so on...?
Mainly i am just trying to find the best place to put an if statements about hexagons generation. The blue hexagons would only spawn in if ever blue hexagon on the map were touching this was just an example though.
So that's were you would put in more if statements for generation in groups like in my example.
Difficult at the moment because a lot of overwriting happening at the moment
Yeah sorry for the confusion i am new to coding. I was just trying to figuring out the best way to implement an if statement on changing the hexagon generation in the code you did. But not sure how i was hoping you could show me how to implement my example into it so i could learn how. Did this help you understand.
It’s simple. We just need another concept of doing the distribution
How would you explain your if-clause-idea to a friend? What results do you want to achieve?
You wrote
Not sure I understand... touching what??
You mean you place a new blue tile only next to an existing blue tile? That I already have because we go from a initial seed.
Also do you need a random effect or can the map look the same every time you run it?
I mean that all the blue tiles next to existing blue tiles. Random effect would be better. Chrisir were do you think the best place to learn code is i have learn't the basics but i am looking to go into more advanced processing coding any suggestions.
Hm. when the thing (all tiles except ocean) is an island, blue (=ocean) would only be on the outside
When blue can also mean a lake or river, it can also be on the inside. Is this what you mean? Like a network but all connected, you mean?
you could make all forests and make the ocean last and make it so that they are connected.
But that's only for blue, what other if rules are there for you?
Yes that's what i mean. Okay thanks for the tip.
??
But that's only for blue, what other if rules are there for you?
new version with more ocean distribution technology ;-)
but there is no simple if to achieve those things....
O sorry forgot that. All the other colors except blue have to be in a group larger than 5 all have to be touching their others.
Wow. Good luck with that.
Good luck with that.
I can't help you with that.
It would have been helpful to have that information initially before I put so much work in it.
Sorry about that but i do appreciate your time helping me on this it has been great.
I gave enough ideas - random walker and growing to all sights
I hope you can build on that
Problem I see is that when you make one complex shape like the ocean and then the next, you would overwrite the previous. So it has to stop when he finds a defined field instead of overwriting it. But then the first will be very complex where the others are simple blobs.
Maybe you are not fully clear what yo want
That means there are 3 or so massive blocks, they can’t be networks, they would cut each other and separate parts from their main block.
Even if you have 3 massive block and overlay the ocean at the end, it’s only allowed to go along the borders of the blocks because otherwise they would cut again fields off from their main blocks.
Youu see, it’s complicated.
Yeah i understand it takes time to do these things no problem though i had a blast talking with you. Its great to be able to talk to someone who understands me when i say things about code thank you.
Technically it would be more comfortable to have the data of the grid in a 2D array
Because at the moment when you go from one field near the top up and reach the border you just come out at the bottom. But then we have two separate blocks (one at the top, one at the bottom) of one color what we don’t want
With a 2D array we could just stop more easily
I have never seen a 2D array before how would it work in are code.
See tutorial section on processing.org
Tutorial two dimensional arrays
Okay will do. I just saw this code i never saw before yesterday it was randomSeed() its quite cool how it works here example in code.
I don’t understand, what did you change? Only the line with randomSeed?
What are the effects? Better randomness...?
if you do not understand the picture here's the link to a video exampling it.
youtube.com/watch?v=yGgEi_40fD4
This video helped me understand it.
No, better randomization.
Chrisir i wanted to see were i could add if statements. So that way i could add boxes in at random if the statements. But how could you make it were the boxes only show to if they are 8 hexagons away from another one if there is on e spawned in.
please post a runnable version without errors
why do you bring in new rules again? Are there more rules still to come?
gotta go.
I updated the coded above. Not sure i just want to check with you that this is the best way to do the code. K.
What are the relevant line numbers that are new please?