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

Username:   Password: 
 RegisterRegister   
 Simple way to draw a grid for minesweeper?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
user23




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




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




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




PostPosted: 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
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
apython1992




PostPosted: 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.
Zren




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


Surprised

I was wondering how you looked that stuff up so fast. Danke.
DemonWasp




PostPosted: 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
apython1992




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




PostPosted: Sun May 01, 2011 8:18 pm   Post subject: Re: Simple way to draw a grid for minesweeper?

Yea, I'm basically just looking to understand how to draw a grid like the one used in the game in this post,
http://compsci.ca/v3/viewtopic.php?t=14409&highlight=minesweeper

While using a simple level of code.
apython1992




PostPosted: 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!
user23




PostPosted: 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
user23




PostPosted: Wed May 11, 2011 5:53 pm   Post subject: Re: Simple way to draw a grid for minesweeper?

edit
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  [ 12 Posts ]
Jump to:   


Style:  
Search: