Buttons access like an array

waspentalive
Posts: 10
Joined: Saturday 16th February 2019 5:55pm

Buttons access like an array

Post by waspentalive » Saturday 16th February 2019 6:12pm

==Newbie - programmed in visual basic for a while, Just installed Gambas3

I am writing a game where one of the elements is a 5 x 5 array. The elements in this array are placed by the player and are represented as buttons on the play field. I would like to refer to these button as field[x,y] where x and y number 1 to 5 (I will also be using x=0 for a stack of oncoming play items, so x=0 to 5 and y = 1 to 5 where x will represent distance left to right across the screen, and y= up and down:


|0,1| |1,1||2,1||3,1||4,1||5,1|
|1,2| |1,2||2,2||3,2||4,2||5,2|


Can I name my buttons field[0,1] or something like that, and be able to display something on button 1,2 with : x=1
y=2
field[x,y].text = "[$]"
Which would set the label on the button to [$]

Thanks for your help - sorry if this is not for getting help..

User avatar
Quincunxian
Posts: 93
Joined: Sunday 25th June 2017 12:14am
Location: Western Australia

Re: Buttons access like an array

Post by Quincunxian » Sunday 17th February 2019 2:22am

Hi waspentalive,
I'm a VB.net developer and came from a background of VB6 (many many years ago...)
You are going to love Gambas and the learning curve is not too steep .

The function you need is the 'Group' property that you will see in all ( I think ?) GUI components.
If you click on the 'Group' property and expand the property information display on the left hand side of the screen you will see some very basic information.

In my example , I have set a group of buttons group name to ButtonArray.
In the GUI editor; when you click on any button in this group, Gambas automatically opens the code editor and instead of the Click function for the selected button you will get the group name click function.
so.. ButtonArray_Click().
This traps the click event of any of the buttons whose group name the same so you can code your requirements for them.

To do this , you use the Last function.
Last provides the control in the group that was last activated...by a click event in this case.

The attached example shows some of the properties that are accessible.
Use the checkbox to turn off the message with the clicked button data

I've also included a sub routine that deals directly with (any) object's properties
You can GET or SET any object property with this and it is quite powerful.

Thing to Note# - The property name is case sensitive so if you write one that does not seem to work, check the name in the property for the control in the GUI editor and use the name exactly as displayed - took me a while to work that out. *sigh*

This example is to quickly prepare a form for validation after the user has entered data.
It will go through every control in a container ( normally a Frame or a Panel ) and then ensure that the identified controls are set to what I need.
The Trim(text) function is really handy as it ensures no extraneous spaces are included.
Public Sub PrepareFormForValidation(InControl As Object)

  Dim ControlElement As Control

  For Each ControlElement In InControl.Children
   ' The control may be a container so it may have children - do a recursive search
    If ControlElement Is Frame Then PrepareFormForValidation(ControlElement) 
    If ControlElement Is Panel Then PrepareFormForValidation(ControlElement) 

    If ControlElement Is Label Then Object.SetProperty(ControlElement, "ForeGround", Color.black)
    If ControlElement Is TextBox Then Object.SetProperty(ControlElement, "Text", Trim(Object.getProperty(ControlElement, "Text")))
    If ControlElement Is TextArea Then Object.SetProperty(ControlElement, "Text", Trim(Object.getProperty(ControlElement, "Text")))
    If ControlElement Is RadioButton Then Object.SetProperty(ControlElement, "ForeGround", Color.black)
    If ControlElement Is CheckBox Then Object.SetProperty(ControlElement, "ForeGround", Color.black)
  Next
Catch
  Message.Warning(Error.Text))
End
Any questions, let me know.
Attachments
ButtonArrayExample.zip
Button Array Example
(14.92 KiB) Downloaded 132 times
Cheers - Quin.
I code therefore I am

waspentalive
Posts: 10
Joined: Saturday 16th February 2019 5:55pm

Re: Buttons access like an array

Post by waspentalive » Monday 18th February 2019 1:43pm

Quinn, Thanks for your help - sorry it went way over my head - I don't get it at all :( but that's ok because the original version of my game was written using just plain buttons (with each button checking the neighbors in a hard coded way) I will just do that again.

Anyone---
I went to start my project and now I have a question already - my OS is KDE (devuan to be exact) should I choose - a gtk flavor or QT? I am not sure which KDE runs on, QT perhaps. There is also a general "graphical application" is that more general?

User avatar
cogier
Site Admin
Posts: 507
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Buttons access like an array

Post by cogier » Monday 18th February 2019 6:45pm

Welcome to the forum: -
Anyone---
I went to start my project and now I have a question already - my OS is KDE (devuan to be exact) should I choose - a gtk flavor or QT? I am not sure which KDE runs on, QT perhaps.
If you are using KDE then Gambas will default to using QT4 or 5 as KDE is built using QT. If you look at menu item Project>Properties and click on Components you will see that Gambas has selected gb.gui which will switch between QT and GTK as necessary.
There is also a general "graphical application" is that more general?
The "graphical application" is the one you will probably use most of the time, well I do anyway!

I have also put together a bit of code for your 'Field' idea, see attached.
Test2.tar.gz
(80.57 KiB) Downloaded 120 times

waspentalive
Posts: 10
Joined: Saturday 16th February 2019 5:55pm

Re: Buttons access like an array

Post by waspentalive » Monday 18th February 2019 9:25pm

Thanks all for the help so far - I used the 'graphical application" this time too..

Next question - I have looked around at the variable declarations, I will need some global variables but I don't know where to declare them - I have tried above all my 'public sub' subroutines - I have tried in each subroutine and Gambas just says "Unexpected Dim"

- hindsight note edit- I have tried both with DIM and without and both where you see it and inside the form.open...

This is my FMain.class file:
' Gambas class file

Dim Static Public GameLevel As Integer
Dim Static Public Iconstring[50] As String


Public Sub PushStack()

' add a new item to the top of the stack - dropping the bottom most away
BtnStack1.text = BtnStack2.text
BtnStack2.text = BtnStack3.text
BtnStack3.text = BtnStack4.Text
Btnstack4.text = BtnStack5.text
BtnStack5.text = Iconstring[Rand(1, GameLevel * 7)]

End




Public Sub SetupGame()


GameLevel = 1

BtnField11.text = "..."
BtnField12.text = "..."
BtnField13.text = "..."
BtnField14.text = "..."
BtnField15.text = "..."
BtnField21.text = "..."
BtnField22.text = "..."
BtnField23.text = "..."
BtnField24.text = "..."
BtnField25.text = "..."
BtnField31.text = "..."
BtnField32.text = "..."
BtnField33.text = "..."
BtnField34.text = "..."
BtnField35.text = "..."


End
Last edited by waspentalive on Monday 18th February 2019 10:45pm, edited 1 time in total.

waspentalive
Posts: 10
Joined: Saturday 16th February 2019 5:55pm

Re: Buttons access like an array

Post by waspentalive » Monday 18th February 2019 10:27pm

OH - I removed the DIM and now it seems to be working... strange.

User avatar
stevedee
Posts: 214
Joined: Monday 20th March 2017 6:06pm

Re: Buttons access like an array

Post by stevedee » Tuesday 19th February 2019 8:38am

waspentalive wrote:
Monday 18th February 2019 9:25pm
...Next question - I have looked around at the variable declarations, I will need some global variables but I don't know where to declare them - I have tried above all my 'public sub' subroutines - I have tried in each subroutine and Gambas just says "Unexpected Dim ...
Generally, you declare a Global variable outside of any routine using "Public" not "Dim" for example:-
Public myNumber As Integer
If you only need access from other routines in the same class you can use "Private". For example if you have written all your code that needs access to this variable in the FMain.class, then this will also work:-
Private myNumber As Integer
...but this Private variable will not be accessible if you create a second class unless you access it like:-
x = myClass2.myNumber
I think in VB6 you could create a static variable within a simple routine. This was handy where you wanted a local variable that was persistent. I'm not sure that this works in Gambas.

waspentalive
Posts: 10
Joined: Saturday 16th February 2019 5:55pm

Re: Buttons access like an array

Post by waspentalive » Tuesday 19th February 2019 2:34pm

Here's another one -I may hate the answer but can one pass buttons as parameters for a subroutine?
-----------------------
Public button15_click()
dobuttonclick(Button15, button10, button20)
end

Public dobuttonclick(center as button, top as button, bottom as button)

if top.text = bottom.text then
center.text = "Matches"
else
center.text = "No Match"
end if
end
-----------------------
So here there are lots of buttons, some are above others, some are below. at some point the user clicks a center button of a set of 3. The button above and the button below are compared and the text is set properly of the button in the center (the one that was pressed).

I know I will hate the answer because I have already coded a bunch of buttons in my app and this would have simplified stuff a lot, I could have one block of code that all the buttons call just referring to different buttons as references.

User avatar
cogier
Site Admin
Posts: 507
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Buttons access like an array

Post by cogier » Tuesday 19th February 2019 3:33pm

Hi waspentalive,

It might be easier to help you if you posted the code here so that we can see what you are trying to achieve.
Public button15_click()
dobuttonclick(Button15, button10, button20)
end
Yes this can be done but the other item with 'center.text' etc I'm not sure. Please post the code.

waspentalive
Posts: 10
Joined: Saturday 16th February 2019 5:55pm

Re: Buttons access like an array

Post by waspentalive » Tuesday 19th February 2019 4:43pm

-- edit Now using gb tags as pointed out below

Tiles -

This is what I have so far... I need to implement the rest of my btnfield routines

There is also my main.form - I don't know how to show that to you yet.

It's a game - you have a stack of icons you can draw from. You place these in a 5x5 grid.
When 2 adjacent elements on the grid contain the same icon - they both clear and you get points.
There are also other bonuses you can earn for more points.

You can also drop the next icon for free, but if you drop a 2nd time (or third...) it costs you 1/2 your current points.

As you progress the body of Icons in the stack grows (the number of kinds of icons) , making it harder to pair them up.

You will notice that the BtnFieldxx stanzas are all pretty much alike.

--- edit ---
Because the btnFieldxx stanzas are alike excepting which buttons they reference I was thinking it might be better to extract that code into a "DoButtonField" subroutine where the neighbor buttons are specified and which of them are edgebonus checks as well -
public sub dobuttonfield ( center as button, north as button, northedge as boolean, south as button, southedge as boolean, east as button, east edge as boolean, west as button, westedge as boolean) 

and probably some other parameters as well.. Then each button_click just calls dobuttonfield with the proper neighbors.

' Gambas class file


' Declarations for global variables 

  Static Public GameLevel As Integer
  Static Public GameScore As Integer
  Static Public Iconstring[51] As String
  Static Public field[5, 5] As Integer 
  Static Public DestroypPenalty As Boolean
  Static Public lastfilled As Integer
  Static Public ThisRound As Integer
  Static Public EdgeBonus As Integer  
  

Public Sub PushStack()
  
  ' add a new item to the top of the stack - dropping the bottom most away
  Dialog.title = GameLevel  '<-- I just noticed this - what is it doing here?
  
  BtnStack1.text = BtnStack2.text
  BtnStack2.text = BtnStack3.text
  BtnStack3.text = BtnStack4.Text
  Btnstack4.text = BtnStack5.text
  BtnStack5.text = Iconstring[Rand(1, GameLevel * 7)]
  
  ThisRound = ThisRound - 1
  If ThisRound = 0 Then
    ThisRound = 49
    GameLevel = GameLevel + 1
    txbMessage.text = "Level UP!"
    If GameLevel = 8 Then
      endgame()
    Endif
  Endif
End

Public Sub endgame()
  
  Dim reply As Integer
  
  reply = Message("game is done - Your score is " & Str(GameScore) & "Play again?", "Yes", "No") 
  Select Case reply
    Case 1
      SetupGame()
    Case 2
      Quit
  End Select
  
End




Public Sub SetupGame()
  
  
  GameLevel = 1
  GameScore = 0
  LCDScore.text = Str(GameScore)
  DestroypPenalty = False
  lastfilled = 0
  ThisRound = 49
  
  BtnField11.text = "..."
  BtnField12.text = "..."
  BtnField13.text = "..."
  BtnField14.text = "..."
  BtnField15.text = "..."
  
  BtnField21.text = "..."
  BtnField22.text = "..."
  BtnField23.text = "..."
  BtnField24.text = "..."
  BtnField25.text = "..."
  
  BtnField31.text = "..."
  BtnField32.text = "..."
  BtnField33.text = "..."
  BtnField34.text = "..."
  BtnField35.text = "..."
  
  BtnField41.text = "..."
  BtnField42.text = "..."
  BtnField43.text = "..."
  BtnField44.text = "..."
  BtnField45.text = "..."
  
  BtnField51.text = "..."
  BtnField52.text = "..."
  BtnField53.text = "..."
  BtnField54.text = "..."
  BtnField55.text = "..."
  
  PushStack()
  PushStack()
  PushStack()
  PushStack()
  PushStack()
  
  
  
End




Public Sub Form_Open()

  
  Randomize
  
  Iconstring[0] = "..."
  Iconstring[1] = "]$["
  Iconstring[2] = "]@["
  Iconstring[3] = "]#["
  Iconstring[4] = "]:["
  Iconstring[5] = "]+["
  Iconstring[6] = "]=["
  Iconstring[7] = "]-["
  
  Iconstring[8] = ")$("
  Iconstring[9] = ")@("
  Iconstring[10] = ")#("
  Iconstring[11] = "):("
  Iconstring[12] = ")+("
  Iconstring[13] = ")=("
  Iconstring[14] = ")-("
  
  Iconstring[15] = "}${"
  Iconstring[16] = "}@{"
  Iconstring[18] = "}#{"
  Iconstring[19] = "}:{"
  Iconstring[20] = "}+{"
  Iconstring[21] = "}={"
  Iconstring[22] = "}-{"
  
  Iconstring[23] = "[$]"
  Iconstring[24] = "[@]"
  Iconstring[25] = "[#]"
  Iconstring[26] = "[:]"
  Iconstring[27] = "[+]"
  Iconstring[28] = "[=]"
  Iconstring[29] = "[-]"
  
  Iconstring[30] = "($)"
  Iconstring[31] = "(@)"
  Iconstring[32] = "(#)"
  Iconstring[33] = "(:)"
  Iconstring[34] = "(+)"
  Iconstring[35] = "(=)"
  Iconstring[36] = "(-)"
  
  Iconstring[37] = "{$}"
  Iconstring[38] = "{@}"
  Iconstring[39] = "{#}"
  Iconstring[40] = "{:}"
  Iconstring[41] = "{+}"
  Iconstring[42] = "{=}"
  Iconstring[43] = "{-}"

  Iconstring[44] = "|$|"
  Iconstring[45] = "|@|"
  Iconstring[46] = "|#|"
  Iconstring[47] = "|:|"
  Iconstring[48] = "|+|"
  Iconstring[49] = "|=|"
  Iconstring[50] = "|-|"
  
  
  SetupGame()
  

End

Public Sub BtnStack1_Click()

  If DestroypPenalty Then
    GameScore = Int(GameScore / 2)
    LCDScore.text = Str(GameScore)
  Endif
  PushStack
  DestroypPenalty = True

End

Public Sub EmptyOrFull()
  
  Dim countofempty As Integer
  
  countofempty = 0
  
  If BtnField15.text = "..." Then countofempty += 1
  If BtnField14.text = "..." Then countofempty += 1
  If BtnField13.text = "..." Then countofempty += 1
  If BtnField12.text = "..." Then countofempty += 1
  If BtnField11.text = "..." Then countofempty += 1
  
  
  If BtnField25.text = "..." Then countofempty += 1
  If BtnField24.text = "..." Then countofempty += 1
  If BtnField23.text = "..." Then countofempty += 1
  If BtnField22.text = "..." Then countofempty += 1
  If BtnField21.text = "..." Then countofempty += 1
  
  
  If BtnField35.text = "..." Then countofempty += 1
  If BtnField34.text = "..." Then countofempty += 1
  If BtnField33.text = "..." Then countofempty += 1
  If BtnField32.text = "..." Then countofempty += 1
  If BtnField31.text = "..." Then countofempty += 1
  
  
  If BtnField45.text = "..." Then countofempty += 1
  If BtnField44.text = "..." Then countofempty += 1
  If BtnField43.text = "..." Then countofempty += 1
  If BtnField42.text = "..." Then countofempty += 1
  If BtnField41.text = "..." Then countofempty += 1
  
  
  If BtnField55.text = "..." Then countofempty += 1
  If BtnField54.text = "..." Then countofempty += 1
  If BtnField53.text = "..." Then countofempty += 1
  If BtnField52.text = "..." Then countofempty += 1
  If BtnField51.text = "..." Then countofempty += 1
  
  If countofempty = 25 Then
    GameScore = 2 * GameScore
    txbMessage.text = "BONUS - you cleared the board"
    LCDScore.text = Str(GameScore)
  Endif
  
  If countofempty = 0 Then
    endgame
  Endif
End


Public Sub BtnField15_Click()

  Dim MatchCount As Integer
  
  
  MatchCount = 0
  EdgeBonus = 1
  
  If BtnField15.text <> "..." Then
    txbMessage.text = "That is not empty"
  Else
  
      
    If lastfilled = 15 Then
      txbMessage.text = "Multi-Click Bonus = 100"
      GameScore = GameScore + 100
      LCDScore.text = Str(GameScore)
    Endif
  
    lastfilled = 15
  
    txbMessage.text = ""
    BtnField15.text = BtnStack1.Text
    PushStack

    MatchCount = 0
  
    'north 
    If BtnField11.text = BtnField15.Text Then
      MatchCount = MatchCount + 1
      EdgeBonus += 1
      BtnField11.text = "..."
    Endif
  
    'south
    If BtnField14.text = BtnField15.Text Then
      MatchCount = MatchCount + 1
      BtnField14.Text = "..."
    Endif
    
    'east 
    If BtnField25.text = BtnField15.Text Then
      MatchCount = MatchCount + 1
      BtnField25.Text = "..."
    Endif
  
    'west 
    If BtnField55.text = BtnField15.Text Then
      MatchCount = MatchCount + 1
      EdgeBonus += 1
      BtnField55.Text = "..."
    Endif
  
    If MatchCount > 0 Then
      txbMessage.Text = Str$(MatchCount) & " Items Matched"
      BtnField15.Text = "..."
      DestroypPenalty = False
      GameScore = GameScore + 100 * MatchCount * EdgeBonus
      LCDScore.text = Str(GameScore)
    Endif

  Endif
  EmptyOrFull
End

Public Sub BtnField14_Click()

  Dim MatchCount As Integer
  
  
  
  If BtnField14.text <> "..." Then
    txbMessage.text = "That is not empty"
  Else
  
      
    If lastfilled = 14 Then
      txbMessage.text = "Multi-Click Bonus = 100"
      GameScore = GameScore + 100
      LCDScore.text = Str(GameScore)
    Endif
  
    lastfilled = 14
  
    txbMessage.text = ""
    BtnField14.text = BtnStack1.Text
    PushStack

    MatchCount = 0
    EdgeBonus = 1
      
    'north 
    If BtnField15.text = BtnField14.Text Then
      MatchCount = MatchCount + 1
      BtnField15.text = "..."
    Endif
  
    'south
    If BtnField13.text = BtnField14.Text Then
      MatchCount = MatchCount + 1
      BtnField13.Text = "..."
    Endif
    
    'east 
    If BtnField24.text = BtnField14.Text Then
      MatchCount = MatchCount + 1
      BtnField24.Text = "..."
    Endif
  
    'west 
    If BtnField54.text = BtnField14.Text Then
      MatchCount = MatchCount + 1
      EdgeBonus += 1
      BtnField54.Text = "..."
    Endif
  
    If MatchCount > 0 Then
      txbMessage.Text = Str$(MatchCount) & " Items Matched"
      BtnField14.Text = "..."
      DestroypPenalty = False
      GameScore = GameScore + 100 * MatchCount * EdgeBonus
      LCDScore.text = Str(GameScore)
    Endif

  Endif
  EmptyOrFull
End

Public Sub BtnField13_Click()

  Dim MatchCount As Integer
  
  
  MatchCount = 0
  EdgeBonus = 1
  
  If BtnField13.text <> "..." Then
    txbMessage.text = "That is not empty"
  Else
  
      
    If lastfilled = 13 Then
      txbMessage.text = "Multi-Click Bonus = 100"
      GameScore = GameScore + 100
      LCDScore.text = Str(GameScore)
    Endif
  
    lastfilled = 13
  
    txbMessage.text = ""
    BtnField13.text = BtnStack1.Text
    PushStack

    MatchCount = 0
  
    'north 
    If BtnField14.text = BtnField13.Text Then
      MatchCount = MatchCount + 1
      BtnField14.text = "..."
    Endif
  
    'south
    If BtnField12.text = BtnField13.Text Then
      MatchCount = MatchCount + 1
      BtnField12.Text = "..."
    Endif
    
    'east 
    If BtnField23.text = BtnField13.Text Then
      MatchCount = MatchCount + 1
      BtnField23.Text = "..."
    Endif
  
    'west 
    If BtnField53.text = BtnField13.Text Then
      MatchCount = MatchCount + 1
      EdgeBonus += 1
      BtnField53.Text = "..."
    Endif
  
    If MatchCount > 0 Then
      txbMessage.Text = Str$(MatchCount) & " Items Matched"
      BtnField13.Text = "..."
      DestroypPenalty = False
      GameScore = GameScore + 100 * MatchCount * EdgeBonus
      LCDScore.text = Str(GameScore)
    Endif

  Endif
  EmptyOrFull

End



Public Sub BtnField12_Click()

  Dim MatchCount As Integer
  
  
  MatchCount = 0
  EdgeBonus = 1
  
  If BtnField12.text <> "..." Then
    txbMessage.text = "That is not empty"
  Else
  
      
    If lastfilled = 12 Then
      txbMessage.text = "Multi-Click Bonus = 100"
      GameScore = GameScore + 100
      LCDScore.text = Str(GameScore)
    Endif
  
    lastfilled = 12
  
    txbMessage.text = ""
    BtnField12.text = BtnStack1.Text
    PushStack

    MatchCount = 0
  
    'north 
    If BtnField13.text = BtnField12.Text Then
      MatchCount = MatchCount + 1
      BtnField13.text = "..."
    Endif
  
    'south
    If BtnField11.text = BtnField12.Text Then
      MatchCount = MatchCount + 1
      BtnField11.Text = "..."
    Endif
    
    'east 
    If BtnField22.text = BtnField12.Text Then
      MatchCount = MatchCount + 1
      BtnField22.Text = "..."
    Endif
  
    'west 
    If BtnField52.text = BtnField12.Text Then
      MatchCount = MatchCount + 1
      EdgeBonus += 1
      BtnField52.Text = "..."
    Endif
  
    If MatchCount > 0 Then
      txbMessage.Text = Str$(MatchCount) & " Items Matched"
      BtnField12.Text = "..."
      DestroypPenalty = False
      GameScore = GameScore + 100 * MatchCount * EdgeBonus
      LCDScore.text = Str(GameScore)
    Endif

  Endif
  EmptyOrFull

End



Public Sub BtnField11_Click()

  Dim MatchCount As Integer
  
  
  MatchCount = 0
  EdgeBonus = 1
  
  If BtnField11.text <> "..." Then
    txbMessage.text = "That is not empty"
  Else
  
      
    If lastfilled = 11 Then
      txbMessage.text = "Multi-Click Bonus = 100"
      GameScore = GameScore + 100
      LCDScore.text = Str(GameScore)
    Endif
  
    lastfilled = 11
  
    txbMessage.text = ""
    BtnField11.text = BtnStack1.Text
    PushStack

  
    'north 
    If BtnField12.text = BtnField11.Text Then
      MatchCount = MatchCount + 1
      BtnField12.text = "..."
    Endif
  
    'south
    If BtnField15.text = BtnField11.Text Then
      MatchCount = MatchCount + 1
      EdgeBonus += 1
      BtnField15.Text = "..."
    Endif
    
    'east 
    If BtnField21.text = BtnField11.Text Then
      MatchCount = MatchCount + 1
      BtnField21.Text = "..."
    Endif
  
    'west 
    If BtnField52.text = BtnField11.Text Then
      MatchCount = MatchCount + 1
      EdgeBonus += 1
      BtnField53.Text = "..."
    Endif
  
    If MatchCount > 0 Then
      txbMessage.Text = Str$(MatchCount) & " Items Matched"
      BtnField11.Text = "..."
      DestroypPenalty = False
      GameScore = GameScore + 100 * MatchCount * EdgeBonus
      LCDScore.text = Str(GameScore)
    Endif

  Endif
  EmptyOrFull

End


Public Sub BtnField25_Click()

  Dim MatchCount As Integer
  
  
  MatchCount = 0
  EdgeBonus = 1
  
  If BtnField25.text <> "..." Then
    txbMessage.text = "That is not empty"
  Else
  
      
    If lastfilled = 25 Then
      txbMessage.text = "Multi-Click Bonus = 100"
      GameScore = GameScore + 100
      LCDScore.text = Str(GameScore)
    Endif
  
    lastfilled = 25
  
    txbMessage.text = ""
    BtnField25.text = BtnStack1.Text
    PushStack

  
    'north 
    If BtnField21.text = BtnField25.Text Then
      MatchCount = MatchCount + 1
      EdgeBonus += 1
      BtnField21.text = "..."
    Endif
  
    'south
    If BtnField24.text = BtnField25.Text Then
      MatchCount = MatchCount + 1
      'EdgeBonus += 1
      BtnField24.Text = "..."
    Endif
    
    'east 
    If BtnField35.text = BtnField25.Text Then
      MatchCount = MatchCount + 1
      BtnField35.Text = "..."
    Endif
  
    'west 
    If BtnField15.text = BtnField25.Text Then
      MatchCount = MatchCount + 1
      'EdgeBonus += 1
      BtnField15.Text = "..."
    Endif
  
    If MatchCount > 0 Then
      txbMessage.Text = Str$(MatchCount) & " Items Matched"
      BtnField25.Text = "..."
      DestroypPenalty = False
      GameScore = GameScore + 100 * MatchCount * EdgeBonus
      LCDScore.text = Str(GameScore)
    Endif

  Endif
  EmptyOrFull

End


Public Sub BtnField24_Click()

  Dim MatchCount As Integer
  
  
  MatchCount = 0
  EdgeBonus = 1
  
  If BtnField24.text <> "..." Then
    txbMessage.text = "That is not empty"
  Else
  
      
    If lastfilled = 24 Then
      txbMessage.text = "Multi-Click Bonus = 100"
      GameScore = GameScore + 100
      LCDScore.text = Str(GameScore)
    Endif
  
    lastfilled = 24
  
    txbMessage.text = ""
    BtnField24.text = BtnStack1.Text
    PushStack

  
    'north 
    If BtnField25.text = BtnField24.Text Then
      MatchCount = MatchCount + 1
      'EdgeBonus += 1
      BtnField25.text = "..."
    Endif
  
    'south
    If BtnField23.text = BtnField24.Text Then
      MatchCount = MatchCount + 1
      'EdgeBonus += 1
      BtnField23.Text = "..."
    Endif
    
    'east 
    If BtnField34.text = BtnField24.Text Then
      MatchCount = MatchCount + 1
      'EdgeBonus += 1
      BtnField34.Text = "..."
    Endif
  
    'west 
    If BtnField14.text = BtnField24.Text Then
      MatchCount = MatchCount + 1
      'EdgeBonus += 1
      BtnField14.Text = "..."
    Endif
  
    If MatchCount > 0 Then
      txbMessage.Text = Str$(MatchCount) & " Items Matched"
      BtnField24.Text = "..."
      DestroypPenalty = False
      GameScore = GameScore + 100 * MatchCount * EdgeBonus
      LCDScore.text = Str(GameScore)
    Endif

  Endif
  EmptyOrFull

End


Public Sub BtnField23_Click()

  Dim MatchCount As Integer
  
  
  MatchCount = 0
  EdgeBonus = 1
  
  If BtnField23.text <> "..." Then
    txbMessage.text = "That is not empty"
  Else
  
      
    If lastfilled = 23 Then
      txbMessage.text = "Multi-Click Bonus = 100"
      GameScore = GameScore + 100
      LCDScore.text = Str(GameScore)
    Endif
  
    lastfilled = 23
  
    txbMessage.text = ""
    BtnField23.text = BtnStack1.Text
    PushStack

  
    'north 
    If BtnField24.text = BtnField23.Text Then
      MatchCount = MatchCount + 1
      'EdgeBonus += 1
      BtnField24.text = "..."
    Endif
  
    'south
    If BtnField22.text = BtnField23.Text Then
      MatchCount = MatchCount + 1
      'EdgeBonus += 1
      BtnField22.Text = "..."
    Endif
    
    'east 
    If BtnField33.text = BtnField23.Text Then
      MatchCount = MatchCount + 1
      'EdgeBonus += 1
      BtnField34.Text = "..."
    Endif
  
    'west 
    If BtnField13.text = BtnField23.Text Then
      MatchCount = MatchCount + 1
      'EdgeBonus += 1
      BtnField13.Text = "..."
    Endif
  
    If MatchCount > 0 Then
      txbMessage.Text = Str$(MatchCount) & " Items Matched"
      BtnField23.Text = "..."
      DestroypPenalty = False
      GameScore = GameScore + 100 * MatchCount * EdgeBonus
      LCDScore.text = Str(GameScore)
    Endif

  Endif
  EmptyOrFull

End

Public Sub BtnField22_Click()

  Dim MatchCount As Integer
  
  
  MatchCount = 0
  EdgeBonus = 1
  
  If BtnField22.text <> "..." Then
    txbMessage.text = "That is not empty"
  Else
  
      
    If lastfilled = 22 Then
      txbMessage.text = "Multi-Click Bonus = 100"
      GameScore = GameScore + 100
      LCDScore.text = Str(GameScore)
    Endif
  
    lastfilled = 22
  
    txbMessage.text = ""
    BtnField24.text = BtnStack1.Text
    PushStack

  
    'north 
    If BtnField23.text = BtnField22.Text Then
      MatchCount = MatchCount + 1
      'EdgeBonus += 1
      BtnField23.text = "..."
    Endif
  
    'south
    If BtnField21.text = BtnField22.Text Then
      MatchCount = MatchCount + 1
      'EdgeBonus += 1
      BtnField21.Text = "..."
    Endif
    
    'east 
    If BtnField32.text = BtnField22.Text Then
      MatchCount = MatchCount + 1
      'EdgeBonus += 1
      BtnField32.Text = "..."
    Endif
  
    'west 
    If BtnField12.text = BtnField22.Text Then
      MatchCount = MatchCount + 1
      'EdgeBonus += 1
      BtnField12.Text = "..."
    Endif
  
    If MatchCount > 0 Then
      txbMessage.Text = Str$(MatchCount) & " Items Matched"
      BtnField22.Text = "..."
      DestroypPenalty = False
      GameScore = GameScore + 100 * MatchCount * EdgeBonus
      LCDScore.text = Str(GameScore)
    Endif

  Endif
  EmptyOrFull

End

Last edited by waspentalive on Wednesday 20th February 2019 7:20pm, edited 2 times in total.

Post Reply