Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 need help with nity gritty of grids
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Vicous




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Asok




PostPosted: Fri Mar 07, 2003 8:14 pm   Post subject: (No 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.
Vicous




PostPosted: Fri Mar 07, 2003 8:40 pm   Post subject: (No 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
Tony




PostPosted: Fri Mar 07, 2003 9:06 pm   Post subject: (No 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
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Vicous




PostPosted: 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)?
Tony




PostPosted: Fri Mar 07, 2003 9:42 pm   Post subject: (No 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)
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Vicous




PostPosted: 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?
Tony




PostPosted: Sat Mar 08, 2003 4:58 pm   Post subject: (No 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Vicous




PostPosted: Sun Mar 09, 2003 4:31 pm   Post subject: GUI

how do I refresh a GUI menu?
Tony




PostPosted: Sun Mar 09, 2003 5:13 pm   Post subject: (No subject)

what do you use to create your GUI menu?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Vicous




PostPosted: Wed Mar 12, 2003 8:26 pm   Post subject: (No subject)

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




PostPosted: Wed Mar 12, 2003 11:03 pm   Post subject: (No 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
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Vicous




PostPosted: Thu Mar 13, 2003 11:46 am   Post subject: (No 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)
Tony




PostPosted: Thu Mar 13, 2003 12:57 pm   Post subject: (No 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
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 14 Posts ]
Jump to:   


Style:  
Search: