![]() |
#21 | ||
![]() ![]() ![]() Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
|
![]() Done.
Code:
For Column = 0 To 3 *For row = 0 To 5 * * position = row * 7 + Column * * If Veld(position).Tag = player And Veld(position + 1).Tag = player And Veld(position + 2).Tag = player And Veld(position + 3).Tag = player Then * * * * *MsgBox "Winner!" * * * * *Call ClearField * * End If *Next row Next Column |
||
![]() ![]() |
|
![]() |
#22 | ||
![]() ![]() ![]() ![]() Join Date: Nov 2004
Location: Afrim, Albania
Posts: 2,113
|
![]() Oh, I see now.
Use this line to create above function Code:
position = row * 7 + Column |
||
![]() ![]() |
|
![]() |
#23 | ||
![]() ![]() ![]() Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
|
![]() Hmm... might be a good idea. Never thought of making a one-line function, but it's used too many times (even in the clicking of the button on top) to keep readability. Just a slight readability improvement, but it is one.
|
||
![]() ![]() |
|
![]() |
#24 | ||
![]() ![]() ![]() ![]() Join Date: Nov 2004
Location: Afrim, Albania
Posts: 2,113
|
![]() It will help you in diagonals, and it will give you back value for the box right where you need it. (It's not 1 line, as you have to return value for that position)
|
||
![]() ![]() |
|
![]() |
#25 | ||
![]() ![]() ![]() Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
|
![]() Maybe a dumb question, but what's the syntax to return values? I've been working around it by making global vars >_>
|
||
![]() ![]() |
|
![]() |
#26 | ||
![]() ![]() ![]() ![]() Join Date: Nov 2004
Location: Afrim, Albania
Posts: 2,113
|
![]() add 'as type' in declaration of function
Example: Code:
Function GRID( row, column) as Integer *position = row * 7 + Column *GRID = array( position ) Function end |
||
![]() ![]() |
|
![]() |
#27 | ||
![]() ![]() ![]() Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
|
![]() Code:
Dim Row As Integer, Column As Integer, pos As Integer Private Sub Klik_Click(Index As Integer) Column = Klik(Index).Index Row = 5 Do While Veld(pos).Tag = 0 Or Row > 0 *pos = Position(Column, Row) *Row = Row - 1 *MsgBox "Row = " & Row & "." Loop End Sub ' ***************** ' ** Horizontaal ** ' ***************** Sub Direction(Position, player) Dim Column As Integer, Row As Integer For Column = 0 To 3 *For Row = 0 To 5 * * Call Position(Column, Row) * * If Veld(Position).Tag = player And Veld(Position + 1).Tag = player And Veld(Position + 2).Tag = player And Veld(Position + 3).Tag = player Then * * * * *MsgBox "Winner!" * * * * *Call ClearField * * End If *Next Row Next Column End Sub Function Position(Column, Row) As Integer *Position = Row * 7 + Column *pos = Position End Function Edit: Nevermind. 6:30am here, so could expect such things. Changed the or to and in the loop and it works now. Edit Edit: Seems like it always ends on row 0 >_> |
||
![]() ![]() |
|
![]() |
#28 | ||
![]() ![]() ![]() ![]() Join Date: Nov 2004
Location: Afrim, Albania
Posts: 2,113
|
![]() I see, in VB you can't use functions same as in C++
Sory about that, you can change that one line for position back to main function. Just copy/paste this stuff, change criteria and you're done. |
||
![]() ![]() |
|
![]() |
#29 | ||
![]() ![]() ![]() ![]() Join Date: Nov 2004
Location: Afrim, Albania
Posts: 2,113
|
![]() Code:
Dim Row As Integer, Column As Integer, pos As Integer Private Sub Klik_Click(Index As Integer) Column = Klik(Index).Index Row = 5 Do While Veld(pos).Tag = 0 Or Row > 0 pos = Position(Column, Row) Row = Row - 1 MsgBox "Row = " & Row & "." Loop End Sub ' ***************** ' ** Horizontaal ** ' ***************** Sub Direction(Position, player) Dim Column As Integer, Row As Integer For Column = 0 To 3 For Row = 0 To 5 * *Position = Row * 7 + Column * *If Veld(Position).Tag = player And Veld(Position + 1).Tag = player And Veld(Position + 2).Tag = player And Veld(Position + 3).Tag = player Then * * * * MsgBox "Winner!" * * * * Call ClearField * *End If Next Row Next Column End Sub |
||
![]() ![]() |
|
![]() |
#30 | ||
![]() ![]() ![]() ![]() Join Date: Nov 2004
Location: Afrim, Albania
Posts: 2,113
|
![]() Why you have this line criteria in the sub line?
Code:
Sub Direction(Position, player) Code:
Private Sub Klik_Click(Index As Integer) Column = Klik(Index).Index Row = 5 Do While Veld(pos).Tag = 0 Or Row > 0 pos = Position(Column, Row) Row = Row - 1 MsgBox "Row = " & Row & "." Loop End Sub |
||
![]() ![]() |
|
![]() |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Visual problem in all dos games | rkrd | Troubleshooting | 6 | 07-12-2007 09:43 PM |
AdLib Visual Composer | crazedloon | Gaming Zone | 1 | 20-09-2007 11:30 AM |
Damn It | punch999 | Blah, blah, blah... | 2 | 01-07-2007 06:39 PM |
Visual Basic, Helpme! | hotty_green | Programming | 7 | 19-07-2006 06:39 PM |
Visual Basic | tomf | Programming | 11 | 05-03-2006 10:35 PM |
|
|
||
  |