Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Gridlines?!?

Status
Not open for further replies.

cyprus106

Programmer
Apr 30, 2001
654
OK, I've been beating my brains out trying to create a simple grid in BCB. I can create a regular vertical grid, (tic-tac-toe style - looking straight down on it) with bevel lines, but that's not what I need. I need a grid that is viewed at an angle, making the rectangles more like diamonds, almost.

I can't use a string grid or a draw grid, that's not really the type of grid I'm looking for. Really, what I'm trying to do is just create a simple line that is drawn at something like a 30 degree angle. From there, I can probably handle creating the rest.

I can't just draw a line in Microsoft Paint or something and then put it in a TImage on BCB, because it has that rectangular border, which I can't have.
Once I create this grid, I'll need to find out how to access the individual cells that they create. Right now, though, I just need to be able to create that simple grid!

Thanks a whole lot. This issue is killing me and I can't continue my work without it. Cyprus
 
I think I saw an article at . James P. Cottingham

When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity.
[tab][tab]Albert Einstein explaining his Theory of Relativity to a group of journalists.
 
I just came from there. Got a lead on drawing a line but absolutely nothing about the grid im trying to create. Cyprus
 
Why not create a custom component. Use the canvas draw property, eg: lineTo() ect.. To draw the grid. Then use Text boxes (assuming you want to insert text), and line them up with your grid cells? It needs a little polish, but the basic idea should work.
 
That's what it looks like I'm going to have to do, but I need some way to be able to know what cell I'm within. I can draw the lines on the canvas. That's not a huge problem, but being able to click and know what cell I'm within is a different story. I don't know how to access lines on the Canvas after they've been drawn. I'm not too skilled at the canvas because I usually don't work with graphics or the frontend.

I probably should have mentioned this earlier: I'm using the grid as a base for a class I'm teaching. The grid is going to be the skeleton for a game they're going to produce. I'm assuming most will be like SimCity or something to that extent. I don't need any hills or anything like that. It's just the basic lines.
Then they'll be working with AI, images, threads, arrays, etc. on top of the grid I furnish.
The reason I'm doing the grid and not them is just this problem... It's difficult to make. If I made them do it, I'd need to add weeks on to the assignment. Can't do that. So now maybe someone knows how to find out where the lines are or something?

Thanks a WHOLE lot. I appreciate it. Cyprus
 
I might not have understood the problem correctly BUT the way i see it is that You are able to draw the grid with LineTo() and such and whenever you click the canvas catch the "OnClick"-event, get the mouse X-Y and calculate the cell! If You can draw it You can calculate it! Totte
 
Well the problem was that I drew an array of lines that made up a grid. I didn't draw each cell individually. I think I know how to access the individual cells now, however. I made an equation to read each of the outside lines and not let anything last them. I just take the equation of the line and check from there. The problem is doing each of the cells, which is going to take more than it's share of time, but what can you do? Anyways, I think I've got it down.

Thanks a lot, I appreciate it. Cyprus
 
What i meant was that if You know that a line exists at a certain Y1 and the next line comes at Y2 you can look if((Current_Y > Y1) && (Current_Y < Y2)) that will show you if it's within that Y. Another approach is: Assuming that the lines are separated with a step of 17, both X and Y.
Then the cell would be Cell[X=Mouse_X/17][Y=Mouse_Y/17], if You have skeved lines it's a little more tricky but in no way impossible. Totte
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top