Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Minesweeper clone - demo added
#21
Nice proggie =)
Reply
#22
Quote:I have a vague understanding of the logic behind it...
If a blank tile is ever uncovered, call a sub that first checks to see if there are any more blanks around it. If yes, call that sub again. If no, uncover the tile.
Hmph.

Sounds about right. but isn't there a limit to how many times you can run a sub in a sub?

Quote:Nice proggie =)

Thankyou.
Reply
#23
Yeah, like Nath kinda said, Stack Space is a difficulty - QB doesn't have much of it.
Nath? We need your help now...re the stack space... Tongue
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#24
You can use a stack Smile

You can download my minesweeper. VB3, but BASIC after all. Check the code: http://imaginatica.us.es/~wopr2k/junkyard/LLoni.zip

Code:
Sub fill (x%, y%)
    ' Cuenta alrededor:
    StackPush x%, y%
    While sp% > 0
        StackPop x%, y%
        p% = 0
        If x% > 0 Then iniX% = -1 Else iniX% = 0
        If x% < BoardH% - 1 Then finX% = 1 Else finX% = 0
        If y% > 0 Then iniY% = -1 Else iniY% = 0
        If y% < BoardV% - 1 Then finY% = 1 Else finY% = 0
        For xx% = iniX% To finX%
            For yy% = iniY% To finY%
                If Map(x% + xx%, y% + yy%) < 3 And Map(x% + xx%, y% + yy%) <> 0 Then
                    p% = p% + 1
                End If
        Next yy%, xx%
        If p% = 0 Then
            Map%(x%, y%) = 15
            If x% > 0 Then
                If Map%(x% - 1, y%) = 0 Then StackPush x% - 1, y%
            End If
            If x% < BoardH% - 1 Then
                If Map%(x% + 1, y%) = 0 Then StackPush x% + 1, y%
            End If
            If y% > 0 Then
                If Map%(x%, y% - 1) = 0 Then StackPush x%, y% - 1
            End If
            If y% < BoardV% - 1 Then
                If Map%(x%, y% + 1) = 0 Then StackPush x%, y% + 1
            End If
            If x% > 0 And y% > 0 Then
                If Map%(x% - 1, y% - 1) = 0 Then StackPush x% - 1, y% - 1
            End If
            If x% < BoardH% - 1 And y% > 0 Then
                If Map%(x% + 1, y% - 1) = 0 Then StackPush x% + 1, y% - 1
            End If
            If x% > 0 And y% < BoardV% - 1 Then
                If Map%(x% - 1, y% + 1) = 0 Then StackPush x% - 1, y% + 1
            End If
            If x% < BoardH% - 1 And y% < BoardV% - 1 Then
                If Map%(x% + 1, y% + 1) = 0 Then StackPush x% + 1, y% + 1
            End If
        Else
            Map%(x%, y%) = 15 - p%
        End If
    Wend
End Sub

and

Code:
Type Coord
    x As Integer
    y As Integer
End Type

Dim Shared Stack(6000) As Coord
Dim Shared sp%

Sub StackInit ()
    sp% = 0
End Sub

Sub StackPop (x%, y%)
    sp% = sp% - 1
    x% = Stack(sp%).x
    y% = Stack(sp%).y
End Sub

Sub StackPush (x%, y%)
    Stack(sp%).x = x%
    Stack(sp%).y = y%
    sp% = sp% + 1
End Sub
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#25
Oooh ooh ooh! *Jumps up and down*
I made a stack structure too...check The Wall @ the QBNZ forum. Tongue
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#26
*Down boy down!*

Nath, nice code =). Too bad QB doesnt have a STL =(.
Reply
#27
And, what, may I ask, is an STL?
(Sounds Javaish.)
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#28
STL = Standard Template Library. A c++ programmer should always know hoe to use it =).
Reply
#29
Hmm thanks for the code both of you. Goes to dissect it.
Reply
#30
Quote:STL = Standard Template Library. A c++ programmer should always know hoe to use it =).
*Gets out a Martini and laughs*
I do C, not that ugly C++.
*Runs*
Big Grin
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)