Drawing tables is a good introduction to loops. Maybe someone finds it intresting. What we want to do is to draw a certain number (or uncertain number) of values, one after the other in two columns. Array works best for saving these values. 1) it can take up to 32 000 different values 2) it's a good way to separate and know what kind of value you are dealing with ... look:
value1[0] = "Value01";
value1[1] = "Value11";
value1[2] = "Value21";
value2[0] = "Value02";
value2[1] = "Value12";
value2[2] = "Value22";
Then to draw the values:
for (i=0; i<3; i+=1) {
draw_text(10,10+i*15,value1[i]);
}
for (i=0; i<3; i+=1) {
draw_text(80,10+i*15,value2[i]);
}
One loop for each column. The x value is constant, since we know where we want each column to start. Then the y value is not constant. We make it such that the space from where the above word has its y value to where the below word should have its y value is fifteen. Thats why the y value of the n:th word is i*15...
If you find this hard then you might be intrested in my article on for-loops, which you can find in the crash-course.
<b>Example:</b> http://gmtutorials.com/files/tableex.gm6
.
Users logged in:
Comments
Loading comments...