Simple way to draw a grid for minesweeper?
Author |
Message |
user23
|
Posted: Wed Apr 27, 2011 7:01 pm Post subject: Simple way to draw a grid for minesweeper? |
|
|
Whats the simplest way to draw a grid that looks like the one in minesweeper, that can add clickable functions and all alike? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
apython1992
![](http://compsci.ca/v3/uploads/user_avatars/17001640684d87a16bb8fbb.jpg)
|
Posted: Wed Apr 27, 2011 7:06 pm Post subject: RE:Simple way to draw a grid for minesweeper? |
|
|
Turing actually has a built-in GUI library, does it not? |
|
|
|
|
![](images/spacer.gif) |
Zren
![](http://compsci.ca/v3/uploads/user_avatars/1110053965512db6185954b.png)
|
Posted: Wed Apr 27, 2011 8:42 pm Post subject: Re: RE:Simple way to draw a grid for minesweeper? |
|
|
Ooooor...Use Mouse.Where combined with some loops.
Turing: |
% make a rect type, then a getRect(col,row):rect function --> awesomeness
var r : rect
r.x1 := grid.x + col * grid.cellWidth
r.y1 := grid.y + row * grid.cellHeight
r.x2 := grid.x + col * grid.cellWidth + grid.cellWidth
r.y2 := grid.y + row * grid.cellHeight + grid.cellHeight
Mouse.Where (mouse.x, mouse.y, mouse.b )
% input/logic
var r : rect := calcRect (col, row )
if r.x1 <= mouse.x and mouse.x <= r.x2 and r.y1 <= mouse.y and mouse.y <= r.y2 then
trigger (col, row )
end if
% Drawing
var r : rect := calcRect (col, row )
Draw.FillBox (r.x1, r.y1, r.x2, r.y2, getCellColor (col, row ))
Draw.Box (r.x1, r.y1, r.x2, r.y2, black)
|
Btw, I'm using [url="http://compsci.ca/holtsoft/doc/record.html"]records[/url] heavily here (mainly because their awesome). |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Wed Apr 27, 2011 8:44 pm Post subject: RE:Simple way to draw a grid for minesweeper? |
|
|
@Zren -- you can also use [ tdoc ] tags for fast linking.
[ tdoc ] record [ / tdoc] == record |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
apython1992
![](http://compsci.ca/v3/uploads/user_avatars/17001640684d87a16bb8fbb.jpg)
|
Posted: Wed Apr 27, 2011 8:53 pm Post subject: RE:Simple way to draw a grid for minesweeper? |
|
|
I guess I was thinking with all the buttons and such. That would work too. |
|
|
|
|
![](images/spacer.gif) |
Zren
![](http://compsci.ca/v3/uploads/user_avatars/1110053965512db6185954b.png)
|
Posted: Wed Apr 27, 2011 8:58 pm Post subject: Re: RE:Simple way to draw a grid for minesweeper? |
|
|
Tony @ Wed Apr 27, 2011 8:44 pm wrote: @Zren -- you can also use [ tdoc ] tags for fast linking.
[ tdoc ] record [ / tdoc] == record
I was wondering how you looked that stuff up so fast. Danke. |
|
|
|
|
![](images/spacer.gif) |
DemonWasp
|
Posted: Thu Apr 28, 2011 10:53 am Post subject: RE:Simple way to draw a grid for minesweeper? |
|
|
I wish there was a way to automagically search for posts corresponding to what the poster wants. For example, the Tutorials section contains a pretty obvious Minesweeper tutorial that covers this topic in part 2 of 4. I would know, because I wrote it.
You can see my signature for the link to part 4 (which links the other sections), or you can go directly here: http://compsci.ca/v3/viewtopic.php?t=21647 |
|
|
|
|
![](images/spacer.gif) |
apython1992
![](http://compsci.ca/v3/uploads/user_avatars/17001640684d87a16bb8fbb.jpg)
|
Posted: Thu Apr 28, 2011 11:10 am Post subject: RE:Simple way to draw a grid for minesweeper? |
|
|
He may not be looking for help with the logic of minesweeper (though your tutorial would be great if he was). Right now it seems as though he just wants help with laying out the grid. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
user23
|
|
|
|
![](images/spacer.gif) |
apython1992
![](http://compsci.ca/v3/uploads/user_avatars/17001640684d87a16bb8fbb.jpg)
|
Posted: Sun May 01, 2011 8:41 pm Post subject: RE:Simple way to draw a grid for minesweeper? |
|
|
If you want the grid to look something like that, you can use Draw.FillBox and Mouse.Where for clicking purposes. Also, don't base your minesweeper off of that version...try to do it better! |
|
|
|
|
![](images/spacer.gif) |
user23
|
Posted: Mon May 02, 2011 3:40 pm Post subject: Re: RE:Simple way to draw a grid for minesweeper? |
|
|
apython1992 @ Sun May 01, 2011 8:41 pm wrote: If you want the grid to look something like that, you can use Draw.FillBox and Mouse.Where for clicking purposes. Also, don't base your minesweeper off of that version...try to do it better!
Yea, I was going to use a for loop to draw the grid with Draw.FillBox, but how can I contain it within the area I'd like? In my game, I don't want the grid to cover the whole screen as its a modified version.
Thanks |
|
|
|
|
![](images/spacer.gif) |
user23
|
Posted: Wed May 11, 2011 5:53 pm Post subject: Re: Simple way to draw a grid for minesweeper? |
|
|
edit |
|
|
|
|
![](images/spacer.gif) |
|
|