Go Back   Forums > Community Chatterbox > Blah, blah, blah...
Memberlist Forum Rules Today's Posts
Search Forums:
Click here to use Advanced Search

Reply
 
Thread Tools Display Modes
Old 02-12-2004, 03:22 AM   #21
Kon-Tiki
[BANNED]

 
Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
Default

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
Kon-Tiki is offline                         Send a private message to Kon-Tiki
Reply With Quote
Old 02-12-2004, 03:33 AM   #22
Rogue
10 GOSUB Abandonia
20 GOTO 10
 
Rogue's Avatar

 
Join Date: Nov 2004
Location: Afrim, Albania
Posts: 2,113
Default

Oh, I see now.

Use this line to create above function

Code:
position = row * 7 + Column
Then in the code, just call function and check if returned value is equal to playerID
Rogue is offline                         Send a private message to Rogue
Reply With Quote
Old 02-12-2004, 03:40 AM   #23
Kon-Tiki
[BANNED]

 
Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
Default

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.
Kon-Tiki is offline                         Send a private message to Kon-Tiki
Reply With Quote
Old 02-12-2004, 03:46 AM   #24
Rogue
10 GOSUB Abandonia
20 GOTO 10
 
Rogue's Avatar

 
Join Date: Nov 2004
Location: Afrim, Albania
Posts: 2,113
Default

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)
Rogue is offline                         Send a private message to Rogue
Reply With Quote
Old 02-12-2004, 03:51 AM   #25
Kon-Tiki
[BANNED]

 
Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
Default

Maybe a dumb question, but what's the syntax to return values? I've been working around it by making global vars >_>
Kon-Tiki is offline                         Send a private message to Kon-Tiki
Reply With Quote
Old 02-12-2004, 03:58 AM   #26
Rogue
10 GOSUB Abandonia
20 GOTO 10
 
Rogue's Avatar

 
Join Date: Nov 2004
Location: Afrim, Albania
Posts: 2,113
Default

add 'as type' in declaration of function

Example:

Code:
Function GRID( row, column) as Integer
 *position = row * 7 + Column
 *GRID = array( position )
Function end
Now, when you call GRID(1,2) it will return value in that cell.
Rogue is offline                         Send a private message to Rogue
Reply With Quote
Old 02-12-2004, 04:10 AM   #27
Kon-Tiki
[BANNED]

 
Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
Default

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
This one goes to row -2, then gives an error (invalid control array index)


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 >_>
Kon-Tiki is offline                         Send a private message to Kon-Tiki
Reply With Quote
Old 02-12-2004, 04:22 AM   #28
Rogue
10 GOSUB Abandonia
20 GOTO 10
 
Rogue's Avatar

 
Join Date: Nov 2004
Location: Afrim, Albania
Posts: 2,113
Default

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.
Rogue is offline                         Send a private message to Rogue
Reply With Quote
Old 02-12-2004, 04:24 AM   #29
Rogue
10 GOSUB Abandonia
20 GOTO 10
 
Rogue's Avatar

 
Join Date: Nov 2004
Location: Afrim, Albania
Posts: 2,113
Default

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
Rogue is offline                         Send a private message to Rogue
Reply With Quote
Old 02-12-2004, 04:28 AM   #30
Rogue
10 GOSUB Abandonia
20 GOTO 10
 
Rogue's Avatar

 
Join Date: Nov 2004
Location: Afrim, Albania
Posts: 2,113
Default

Why you have this line criteria in the sub line?

Code:
Sub Direction(Position, player)
Also change this code to add player id to array

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
EDIT: Add player id to Klik sub, so that you know what player's coin you need to add to array
Rogue is offline                         Send a private message to Rogue
Reply With Quote
Reply


Similar Threads
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


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump
 


The current time is 09:12 PM (GMT)

 
Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.