Computer Science Canada

need help with nity gritty of grids

Author:  Vicous [ Fri Mar 07, 2003 7:48 pm ]
Post subject:  need help with nity gritty of grids

I need to make a grid, assigning seperate variables to each square and seperating rows and columns by name( of the variable), and I need to do it in a for loop... eg.

for width:1..(width of grid)
for hight:1..(hight of grid)
var (width of grid) +","+ (hight of grid) :int
end for
end for

and I need to get back variables like (if width of grid is 5 and hight of grid is 3)
1,1 1,2 1,3 1,4 1,5
2,1 2,2 2,3 2,4 2,5
3,1 3,2 3,3 3,4 3,5

I need this in order to make a map for an rpg style game, each variable will hold a number which will identify which chip from the chipset it will hold


I invite any other ideas too, but I need to be able to let the user to set the width and hight of the map and make sane(as in not insane) names for each variable in order to identify rows and coloumns

Author:  Asok [ Fri Mar 07, 2003 8:14 pm ]
Post subject: 

Make 2 varriables, one for the hieght of the grid and one for the length of the grid. Multiply those variables, the result is the amount of slots you will need in your array that will store the grid positions.

Author:  Vicous [ Fri Mar 07, 2003 8:40 pm ]
Post subject: 

I think you missed the point, and Im not that good with arrays anyway, infact I only know the basics but anyway this program will write a file that will be read later by the actual game, and I need to find a way to name the variables so that I know what they are, not just straight numbers

Author:  Tony [ Fri Mar 07, 2003 9:06 pm ]
Post subject: 

you cant declear a variable with a name specified by user... not unless you write an if statment for every possible input.

Just use 2D arrays. You can use variables to specify the size.

You can use a search feature to find some posts on arrays. I'm sure they're explained here somewhere

Author:  Vicous [ Fri Mar 07, 2003 9:30 pm ]
Post subject:  O.K.

I get the point of arrays now, what do you mean by double array? instead of

var grid:array 1..10 of int

i declare this instead?

var grid:array 1..10,1..10 of int
and each variable is grid(x)(x)?

Author:  Tony [ Fri Mar 07, 2003 9:42 pm ]
Post subject: 

almost

you got the declaration part right

var name:array 1..10, 1..10 of int

but you call the varaible inside a single bracket

name(2,5)

Author:  Vicous [ Sat Mar 08, 2003 4:36 pm ]
Post subject:  more help

Ive also got a menu set up, how do I refresh it after i cls the screen?

Author:  Tony [ Sat Mar 08, 2003 4:58 pm ]
Post subject: 

you'd have to redraw everything after cls.

I recommend setting up a procedure for drawing each individual item, this way you can also redraw an object without clearing the whole screen.

Author:  Vicous [ Sun Mar 09, 2003 4:31 pm ]
Post subject:  GUI

how do I refresh a GUI menu?

Author:  Tony [ Sun Mar 09, 2003 5:13 pm ]
Post subject: 

what do you use to create your GUI menu?

Author:  Vicous [ Wed Mar 12, 2003 8:26 pm ]
Post subject: 

file := GUI.CreateMenu ("File")
newmap := GUI.CreateMenuItem ("New Map", makenewmap)
exitWithoutSaving := GUI.CreateMenuItem ("Quit", GUI.Quit)

Author:  Tony [ Wed Mar 12, 2003 11:03 pm ]
Post subject: 

I donno why you should need to refresh your menu... You can use Enable and Disable to turn menu items on/off (like grey links you cant click in normal programs Wink)

but if for some reason you do...

GUI.Dispose (widgetID : int)

this will get rid of your widget (menu item). Using this you can clear your whole menu and then fill it up with new menu items

Author:  Vicous [ Thu Mar 13, 2003 11:46 am ]
Post subject: 

If my program draws over the menu, or I use CLS to clear out my pictures, how would I redraw my menu without completly remaking my menu (I can't remake my menu, not the way I've got my program set up)

Author:  Tony [ Thu Mar 13, 2003 12:57 pm ]
Post subject: 

Here's whats going on. When you use cls the screen gets cleared, but the menus are still there. You can click on them and they would work Wink

You can make the menu button appear by enabling it GUI.Enable (menuID)

though you'd have to redraw the line yourself Confused


: