×

[PR]この広告は3ヶ月以上更新がないため表示されています。
ホームページを更新後24時間以内に表示されなくなります。

お絵かきロジック

お絵かきロジックというのは……ググれば色々と見つかります。

お絵かきロジック - Wikipedia

縦横の数字から推理してマス目を塗って絵を浮かび上がらせる、というようなパズルです。
Small Basicでお絵かきロジックのプログラムを作ってみます……が、性質上、まず完成した絵を作らなければなりません。
また、簡単にするために5×5マスのパズルにしました。

外見だけなら線を引いたり、文字を入れたりして簡単に作ることができます。

GraphicsWindow.Width = 600
GraphicsWindow.Height = 600
GraphicsWindow.Title = "お絵かきロジック"
GraphicsWindow.FontName = "Meiryo UI"
GraphicsWindow.FontSize = 40

GraphicsWindow.PenColor = "Black"
GraphicsWindow.BrushColor = "White"

'問題用数字のマス目
For i = 0 To 5
  GraphicsWindow.DrawLine(200 + 50 * i, 0, 200 + 50 * i, 200)
  GraphicsWindow.DrawLine(0, 200 + 50 * i, 200, 200 + 50 * i)
EndFor

'塗りつぶし用マス目
For x = 1 To 5
  For y = 1 To 5
    whitemasu[x][y] = Shapes.AddRectangle(50, 50)
    Shapes.Move(whitemasu[x][y], x * 50 + 150, y * 50 + 150)
    White[x][y] = 1
  EndFor
EndFor

'問題用数字
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.DrawText(210 + 50 * 0, 150, "1")
GraphicsWindow.DrawText(210 + 50 * 1, 150, "2")
GraphicsWindow.DrawText(210 + 50 * 2, 150, "5")
GraphicsWindow.DrawText(210 + 50 * 3, 150, "2")
GraphicsWindow.DrawText(210 + 50 * 4, 150, "1")
GraphicsWindow.DrawText(210 + 50 * 3, 100, "2")

GraphicsWindow.DrawText(160, 200 + 50 * 0, "2")
GraphicsWindow.DrawText(160, 200 + 50 * 1, "2")
GraphicsWindow.DrawText(160, 200 + 50 * 2, "1")
GraphicsWindow.DrawText(160, 200 + 50 * 3, "5")
GraphicsWindow.DrawText(160, 200 + 50 * 4, "3")

お絵かきロジック

マス目はShapes.AddRectangleで、黒い枠(GraphicsWindow.PenColorで指定)・白で塗りつぶし(GraphicsWindow.BrushColorで指定)して描いています。
White[x][y] = 1というのは、「マス目が白いかどうか」用のパラメータです。
黒く塗りつぶしたときにはWhite[x][y] = 0に変更します。
最終的に、答えと同じマスが全て塗りつぶされているかどうかを「White[x][y]」で判定するわけです。

後は、マス目を黒で塗りつぶした時のための図形と、塗りつぶさない為にマークする×を描く図形も用意しておきます。

'マス目を黒で塗った時用
For x = 1 To 5
  For y = 1 To 5
    Blackmasu[x][y] = Shapes.AddRectangle(50, 50)
    Shapes.Move(Blackmasu[x][y], x * 50 + 150, y * 50 + 150)
    Shapes.HideShape(Blackmasu[x][y])
  EndFor
EndFor

'マス目に×を付けた時用
For x = 1 To 5
  For y = 1 To 5
    Batten[x][y] = Shapes.AddText("x")
    Shapes.Move(Batten[x][y], x * 50 + 162, y * 50 + 145)
    Shapes.HideShape(Batten[x][y])
    Battennumber[x][y] = 1
  EndFor
EndFor

「×」じゃなくて「x」を描いてますが気にしないでください……w
Battennumber[x][y]で「×がついているかどうか」を判定するようにしています。
そして作られたShapesShapes.HideShapeで一度隠しています。

残るは、
「マス目を左クリックしたら黒く塗りつぶし・または白に戻す」
「マス目を右クリックしたら×を付ける・または×を消す」
というプログラムを書くのみです。
大雑把には、

GraphicsWindow.MouseDown = MouseD

Sub MouseD
  (マウスの座標を取得する)
  
  If (マウス左ボタンを押した) Then
    (マウスの座標がwhitemasu[1][1]の内部の時、White[1][1] = 1ならBlackmasu[1][1]を表示してWhite[1][1] = 0にする。White[1][1] = 0ならwhitemasu[1][1]を表示してWhite[1][1] = 1にする)
    (以降、マス目25個ぶんを繰り返す)
    If (答えと一致するWhite[x][y] = 0を全て取得した) Then
      (「完成!」と表示)
    EndIf
  EndIf
  
  If (マウス右ボタンを押した) Then
    (マウスの座標がwhitemasu[1][1]の内部の時、Battennumber[1][1] = 1ならBatten[1][1]を表示してBattennumber[1][1] = 0にする。Battennumber[1][1] = 0ならBatten[1][1]を非表示にしてBattennumber[1][1] = 1にする)
    (以降、マス目25個ぶんを繰り返す)
  EndIf

EndSub

ということになります。
「以降、マス目25個ぶんを繰り返す」と軽く書きましたがそこがめんどくさい。w
あと、正解した後は画面をクリックしてもパズルがプレイできないようにしたいので、最初にclick = 1というパラメータを入れておき、1の時だけクリックでマス目を塗ったり消したりできるようにして、正解後はclick = 0としてパズルがプレイできないようにしてみました。

GraphicsWindow.Width = 600
GraphicsWindow.Height = 600
GraphicsWindow.Title = "お絵かきロジック"
GraphicsWindow.FontName = "Meiryo UI"
GraphicsWindow.FontSize = 40

GraphicsWindow.PenColor = "Black"
GraphicsWindow.BrushColor = "White"

For i = 0 To 5
  GraphicsWindow.DrawLine(200 + 50 * i, 0, 200 + 50 * i, 200)
  GraphicsWindow.DrawLine(0, 200 + 50 * i, 200, 200 + 50 * i)
EndFor

For x = 1 To 5
  For y = 1 To 5
    whitemasu[x][y] = Shapes.AddRectangle(50, 50)
    Shapes.Move(whitemasu[x][y], x * 50 + 150, y * 50 + 150)
    White[x][y] = 1
  EndFor
EndFor

GraphicsWindow.BrushColor = "Black"
GraphicsWindow.DrawText(210 + 50 * 0, 150, "1")
GraphicsWindow.DrawText(210 + 50 * 1, 150, "2")
GraphicsWindow.DrawText(210 + 50 * 2, 150, "5")
GraphicsWindow.DrawText(210 + 50 * 3, 150, "2")
GraphicsWindow.DrawText(210 + 50 * 4, 150, "1")
GraphicsWindow.DrawText(210 + 50 * 3, 100, "2")

GraphicsWindow.DrawText(160, 200 + 50 * 0, "2")
GraphicsWindow.DrawText(160, 200 + 50 * 1, "2")
GraphicsWindow.DrawText(160, 200 + 50 * 2, "1")
GraphicsWindow.DrawText(160, 200 + 50 * 3, "5")
GraphicsWindow.DrawText(160, 200 + 50 * 4, "3")

For x = 1 To 5
  For y = 1 To 5
    Blackmasu[x][y] = Shapes.AddRectangle(50, 50)
    Shapes.Move(Blackmasu[x][y], x * 50 + 150, y * 50 + 150)
    Shapes.HideShape(Blackmasu[x][y])
  EndFor
EndFor

For x = 1 To 5
  For y = 1 To 5
    Batten[x][y] = Shapes.AddText("x")
    Shapes.Move(Batten[x][y], x * 50 + 162, y * 50 + 145)
    Shapes.HideShape(Batten[x][y])
    Battennumber[x][y] = 1
  EndFor
EndFor

click = 1
GraphicsWindow.MouseDown = MouseD

Sub MouseD
  mx = GraphicsWindow.MouseX
  my = GraphicsWindow.MouseY
  
  If Mouse.IsLeftButtonDown And click = 1 Then
    If Shapes.GetLeft(whitemasu[1][1]) <= mx And mx < Shapes.GetLeft(whitemasu[2][1]) Then
      
      If Shapes.GetTop(whitemasu[1][1]) <= my And my < Shapes.GetTop(whitemasu[1][2]) Then
        If White[1][1] = 1 Then
          Shapes.HideShape(whitemasu[1][1])
          Shapes.ShowShape(Blackmasu[1][1])
          White[1][1] = 0
        Else
          Shapes.ShowShape(whitemasu[1][1])
          Shapes.HideShape(Blackmasu[1][1])
          White[1][1] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[1][2]) <= my And my < Shapes.GetTop(whitemasu[1][3]) Then
        If White[1][2] = 1 Then
          Shapes.HideShape(whitemasu[1][2])
          Shapes.ShowShape(Blackmasu[1][2])
          White[1][2] = 0
        Else
          Shapes.ShowShape(whitemasu[1][2])
          Shapes.HideShape(Blackmasu[1][2])
          White[1][2] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[1][3]) <= my And my < Shapes.GetTop(whitemasu[1][4]) Then
        If White[1][3] = 1 Then
          Shapes.HideShape(whitemasu[1][3])
          Shapes.ShowShape(Blackmasu[1][3])
          White[1][3] = 0
        Else
          Shapes.ShowShape(whitemasu[1][3])
          Shapes.HideShape(Blackmasu[1][3])
          White[1][3] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[1][4]) <= my And my < Shapes.GetTop(whitemasu[1][5]) Then
        If White[1][4] = 1 Then
          Shapes.HideShape(whitemasu[1][4])
          Shapes.ShowShape(Blackmasu[1][4])
          White[1][4] = 0
        Else
          Shapes.ShowShape(whitemasu[1][4])
          Shapes.HideShape(Blackmasu[1][4])
          White[1][4] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[1][5]) <= my And my < Shapes.GetTop(whitemasu[1][5]) + 50 Then
        If White[1][5] = 1 Then
          Shapes.HideShape(whitemasu[1][5])
          Shapes.ShowShape(Blackmasu[1][5])
          White[1][5] = 0
        Else
          Shapes.ShowShape(whitemasu[1][5])
          Shapes.HideShape(Blackmasu[1][5])
          White[1][5] = 1
        EndIf
      EndIf
    EndIf
    
    If Shapes.GetLeft(whitemasu[2][1]) <= mx And mx < Shapes.GetLeft(whitemasu[3][1]) Then
      If Shapes.GetTop(whitemasu[2][1]) <= my And my < Shapes.GetTop(whitemasu[2][2]) Then
        If White[2][1] = 1 Then
          Shapes.HideShape(whitemasu[2][1])
          Shapes.ShowShape(Blackmasu[2][1])
          White[2][1] = 0
        Else
          Shapes.ShowShape(whitemasu[2][1])
          Shapes.HideShape(Blackmasu[2][1])
          White[2][1] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[2][2]) <= my And my < Shapes.GetTop(whitemasu[2][3]) Then
        If White[2][2] = 1 Then
          Shapes.HideShape(whitemasu[2][2])
          Shapes.ShowShape(Blackmasu[2][2])
          White[2][2] = 0
        Else
          Shapes.ShowShape(whitemasu[2][2])
          Shapes.HideShape(Blackmasu[2][2])
          White[2][2] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[2][3]) <= my And my < Shapes.GetTop(whitemasu[2][4]) Then
        If White[2][3] = 1 Then
          Shapes.HideShape(whitemasu[2][3])
          Shapes.ShowShape(Blackmasu[2][3])
          White[2][3] = 0
        Else
          Shapes.ShowShape(whitemasu[2][3])
          Shapes.HideShape(Blackmasu[2][3])
          White[2][3] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[2][4]) <= my And my < Shapes.GetTop(whitemasu[2][5]) Then
        If White[2][4] = 1 Then
          Shapes.HideShape(whitemasu[2][4])
          Shapes.ShowShape(Blackmasu[2][4])
          White[2][4] = 0
        Else
          Shapes.ShowShape(whitemasu[2][4])
          Shapes.HideShape(Blackmasu[2][4])
          White[2][4] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[2][5]) <= my And my < Shapes.GetTop(whitemasu[2][5]) + 50 Then
        If White[2][5] = 1 Then
          Shapes.HideShape(whitemasu[2][5])
          Shapes.ShowShape(Blackmasu[2][5])
          White[2][5] = 0
        Else
          Shapes.ShowShape(whitemasu[2][5])
          Shapes.HideShape(Blackmasu[2][5])
          White[2][5] = 1
        EndIf
      EndIf
    EndIf

    If Shapes.GetLeft(whitemasu[3][1]) <= mx And mx < Shapes.GetLeft(whitemasu[4][1]) Then
      If Shapes.GetTop(whitemasu[3][1]) <= my And my < Shapes.GetTop(whitemasu[3][2]) Then
        If White[3][1] = 1 Then
          Shapes.HideShape(whitemasu[3][1])
          Shapes.ShowShape(Blackmasu[3][1])
          White[3][1] = 0
        Else
          Shapes.ShowShape(whitemasu[3][1])
          Shapes.HideShape(Blackmasu[3][1])
          White[3][1] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[3][2]) <= my And my < Shapes.GetTop(whitemasu[3][3]) Then
        If White[3][2] = 1 Then
          Shapes.HideShape(whitemasu[3][2])
          Shapes.ShowShape(Blackmasu[3][2])
          White[3][2] = 0
        Else
          Shapes.ShowShape(whitemasu[3][2])
          Shapes.HideShape(Blackmasu[3][2])
          White[3][2] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[3][3]) <= my And my < Shapes.GetTop(whitemasu[3][4]) Then
        If White[3][3] = 1 Then
          Shapes.HideShape(whitemasu[3][3])
          Shapes.ShowShape(Blackmasu[3][3])
          White[3][3] = 0
        Else
          Shapes.ShowShape(whitemasu[3][3])
          Shapes.HideShape(Blackmasu[3][3])
          White[3][3] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[3][4]) <= my And my < Shapes.GetTop(whitemasu[3][5]) Then
        If White[3][4] = 1 Then
          Shapes.HideShape(whitemasu[3][4])
          Shapes.ShowShape(Blackmasu[3][4])
          White[3][4] = 0
        Else
          Shapes.ShowShape(whitemasu[3][4])
          Shapes.HideShape(Blackmasu[3][4])
          White[3][4] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[3][5]) <= my And my < Shapes.GetTop(whitemasu[3][5]) + 50 Then
        If White[3][5] = 1 Then
          Shapes.HideShape(whitemasu[3][5])
          Shapes.ShowShape(Blackmasu[3][5])
          White[3][5] = 0
        Else
          Shapes.ShowShape(whitemasu[3][5])
          Shapes.HideShape(Blackmasu[3][5])
          White[3][5] = 1
        EndIf
      EndIf
    EndIf

    If Shapes.GetLeft(whitemasu[4][1]) <= mx And mx < Shapes.GetLeft(whitemasu[5][1]) Then
      If Shapes.GetTop(whitemasu[4][1]) <= my And my < Shapes.GetTop(whitemasu[4][2]) Then
        If White[4][1] = 1 Then
          Shapes.HideShape(whitemasu[4][1])
          Shapes.ShowShape(Blackmasu[4][1])
          White[4][1] = 0
        Else
          Shapes.ShowShape(whitemasu[4][1])
          Shapes.HideShape(Blackmasu[4][1])
          White[4][1] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[4][2]) <= my And my < Shapes.GetTop(whitemasu[4][3]) Then
        If White[4][2] = 1 Then
          Shapes.HideShape(whitemasu[4][2])
          Shapes.ShowShape(Blackmasu[4][2])
          White[4][2] = 0
        Else
          Shapes.ShowShape(whitemasu[4][2])
          Shapes.HideShape(Blackmasu[4][2])
          White[4][2] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[4][3]) <= my And my < Shapes.GetTop(whitemasu[4][4]) Then
        If White[4][3] = 1 Then
          Shapes.HideShape(whitemasu[4][3])
          Shapes.ShowShape(Blackmasu[4][3])
          White[4][3] = 0
        Else
          Shapes.ShowShape(whitemasu[4][3])
          Shapes.HideShape(Blackmasu[4][3])
          White[4][3] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[4][4]) <= my And my < Shapes.GetTop(whitemasu[4][5]) Then
        If White[4][4] = 1 Then
          Shapes.HideShape(whitemasu[4][4])
          Shapes.ShowShape(Blackmasu[4][4])
          White[4][4] = 0
        Else
          Shapes.ShowShape(whitemasu[4][4])
          Shapes.HideShape(Blackmasu[4][4])
          White[4][4] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[4][5]) <= my And my < Shapes.GetTop(whitemasu[4][5]) + 50 Then
        If White[4][5] = 1 Then
          Shapes.HideShape(whitemasu[4][5])
          Shapes.ShowShape(Blackmasu[4][5])
          White[4][5] = 0
        Else
          Shapes.ShowShape(whitemasu[4][5])
          Shapes.HideShape(Blackmasu[4][5])
          White[4][5] = 1
        EndIf
      EndIf
    EndIf

    If Shapes.GetLeft(whitemasu[5][1]) <= mx And mx < Shapes.GetLeft(whitemasu[5][1]) + 50 Then
      If Shapes.GetTop(whitemasu[5][1]) <= my And my < Shapes.GetTop(whitemasu[5][2]) Then
        If White[5][1] = 1 Then
          Shapes.HideShape(whitemasu[5][1])
          Shapes.ShowShape(Blackmasu[5][1])
          White[5][1] = 0
        Else
          Shapes.ShowShape(whitemasu[5][1])
          Shapes.HideShape(Blackmasu[5][1])
          White[5][1] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[5][2]) <= my And my < Shapes.GetTop(whitemasu[5][3]) Then
        If White[5][2] = 1 Then
          Shapes.HideShape(whitemasu[5][2])
          Shapes.ShowShape(Blackmasu[5][2])
          White[5][2] = 0
        Else
          Shapes.ShowShape(whitemasu[5][2])
          Shapes.HideShape(Blackmasu[5][2])
          White[5][2] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[5][3]) <= my And my < Shapes.GetTop(whitemasu[5][4]) Then
        If White[5][3] = 1 Then
          Shapes.HideShape(whitemasu[5][3])
          Shapes.ShowShape(Blackmasu[5][3])
          White[5][3] = 0
        Else
          Shapes.ShowShape(whitemasu[5][3])
          Shapes.HideShape(Blackmasu[5][3])
          White[5][3] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[5][4]) <= my And my < Shapes.GetTop(whitemasu[5][5]) Then
        If White[5][4] = 1 Then
          Shapes.HideShape(whitemasu[5][4])
          Shapes.ShowShape(Blackmasu[5][4])
          White[5][4] = 0
        Else
          Shapes.ShowShape(whitemasu[5][4])
          Shapes.HideShape(Blackmasu[5][4])
          White[5][4] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[5][5]) <= my And my < Shapes.GetTop(whitemasu[5][5]) + 50 Then
        If White[5][5] = 1 Then
          Shapes.HideShape(whitemasu[5][5])
          Shapes.ShowShape(Blackmasu[5][5])
          White[5][5] = 0
        Else
          Shapes.ShowShape(whitemasu[5][5])
          Shapes.HideShape(Blackmasu[5][5])
          White[5][5] = 1
        EndIf
      EndIf
    EndIf
    If White[3][1] = 0 And White[4][1] = 0 And White[3][2] = 0 And White[4][2] = 0 And White[3][3] = 0 And White[1][4] = 0 And White[2][4] = 0 And White[3][4] = 0 And White[4][4] = 0 And White[5][4] = 0 And White[2][5] = 0 And White[3][5] = 0 And White[4][5] = 0 And click = 1 Then
      GraphicsWindow.DrawText(50, 500, "完成!")
      click = 0
    EndIf
  EndIf

  If Mouse.IsRightButtonDown And click = 1 Then
    If Shapes.GetLeft(whitemasu[1][1]) <= mx And mx < Shapes.GetLeft(whitemasu[2][1]) Then
      
      If Shapes.GetTop(whitemasu[1][1]) <= my And my < Shapes.GetTop(whitemasu[1][2]) Then
        If Battennumber[1][1] = 1 Then
          Shapes.HideShape(Batten[1][1])
          Shapes.ShowShape(Batten[1][1])
          Battennumber[1][1] = 0
        Else
          Shapes.ShowShape(Batten[1][1])
          Shapes.HideShape(Batten[1][1])
          Battennumber[1][1] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[1][2]) <= my And my < Shapes.GetTop(whitemasu[1][3]) Then
        If Battennumber[1][2] = 1 Then
          Shapes.HideShape(Batten[1][2])
          Shapes.ShowShape(Batten[1][2])
          Battennumber[1][2] = 0
        Else
          Shapes.ShowShape(Batten[1][2])
          Shapes.HideShape(Batten[1][2])
          Battennumber[1][2] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[1][3]) <= my And my < Shapes.GetTop(whitemasu[1][4]) Then
        If Battennumber[1][3] = 1 Then
          Shapes.HideShape(Batten[1][3])
          Shapes.ShowShape(Batten[1][3])
          Battennumber[1][3] = 0
        Else
          Shapes.ShowShape(Batten[1][3])
          Shapes.HideShape(Batten[1][3])
          Battennumber[1][3] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[1][4]) <= my And my < Shapes.GetTop(whitemasu[1][5]) Then
        If Battennumber[1][4] = 1 Then
          Shapes.HideShape(Batten[1][4])
          Shapes.ShowShape(Batten[1][4])
          Battennumber[1][4] = 0
        Else
          Shapes.ShowShape(Batten[1][4])
          Shapes.HideShape(Batten[1][4])
          Battennumber[1][4] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[1][5]) <= my And my < Shapes.GetTop(whitemasu[1][5]) + 50 Then
        If Battennumber[1][5] = 1 Then
          Shapes.HideShape(Batten[1][5])
          Shapes.ShowShape(Batten[1][5])
          Battennumber[1][5] = 0
        Else
          Shapes.ShowShape(Batten[1][5])
          Shapes.HideShape(Batten[1][5])
          Battennumber[1][5] = 1
        EndIf
      EndIf
    EndIf
    
    If Shapes.GetLeft(whitemasu[2][1]) <= mx And mx < Shapes.GetLeft(whitemasu[3][1]) Then
      If Shapes.GetTop(whitemasu[2][1]) <= my And my < Shapes.GetTop(whitemasu[2][2]) Then
        If Battennumber[2][1] = 1 Then
          Shapes.HideShape(Batten[2][1])
          Shapes.ShowShape(Batten[2][1])
          Battennumber[2][1] = 0
        Else
          Shapes.ShowShape(Batten[2][1])
          Shapes.HideShape(Batten[2][1])
          Battennumber[2][1] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[2][2]) <= my And my < Shapes.GetTop(whitemasu[2][3]) Then
        If Battennumber[2][2] = 1 Then
          Shapes.HideShape(Batten[2][2])
          Shapes.ShowShape(Batten[2][2])
          Battennumber[2][2] = 0
        Else
          Shapes.ShowShape(Batten[2][2])
          Shapes.HideShape(Batten[2][2])
          Battennumber[2][2] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[2][3]) <= my And my < Shapes.GetTop(whitemasu[2][4]) Then
        If Battennumber[2][3] = 1 Then
          Shapes.HideShape(Batten[2][3])
          Shapes.ShowShape(Batten[2][3])
          Battennumber[2][3] = 0
        Else
          Shapes.ShowShape(Batten[2][3])
          Shapes.HideShape(Batten[2][3])
          Battennumber[2][3] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[2][4]) <= my And my < Shapes.GetTop(whitemasu[2][5]) Then
        If Battennumber[2][4] = 1 Then
          Shapes.HideShape(Batten[2][4])
          Shapes.ShowShape(Batten[2][4])
          Battennumber[2][4] = 0
        Else
          Shapes.ShowShape(Batten[2][4])
          Shapes.HideShape(Batten[2][4])
          Battennumber[2][4] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[2][5]) <= my And my < Shapes.GetTop(whitemasu[2][5]) + 50 Then
        If Battennumber[2][5] = 1 Then
          Shapes.HideShape(Batten[2][5])
          Shapes.ShowShape(Batten[2][5])
          Battennumber[2][5] = 0
        Else
          Shapes.ShowShape(Batten[2][5])
          Shapes.HideShape(Batten[2][5])
          Battennumber[2][5] = 1
        EndIf
      EndIf
    EndIf

    If Shapes.GetLeft(whitemasu[3][1]) <= mx And mx < Shapes.GetLeft(whitemasu[4][1]) Then
      If Shapes.GetTop(whitemasu[3][1]) <= my And my < Shapes.GetTop(whitemasu[3][2]) Then
        If Battennumber[3][1] = 1 Then
          Shapes.HideShape(Batten[3][1])
          Shapes.ShowShape(Batten[3][1])
          Battennumber[3][1] = 0
        Else
          Shapes.ShowShape(Batten[3][1])
          Shapes.HideShape(Batten[3][1])
          Battennumber[3][1] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[3][2]) <= my And my < Shapes.GetTop(whitemasu[3][3]) Then
        If Battennumber[3][2] = 1 Then
          Shapes.HideShape(Batten[3][2])
          Shapes.ShowShape(Batten[3][2])
          Battennumber[3][2] = 0
        Else
          Shapes.ShowShape(Batten[3][2])
          Shapes.HideShape(Batten[3][2])
          Battennumber[3][2] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[3][3]) <= my And my < Shapes.GetTop(whitemasu[3][4]) Then
        If Battennumber[3][3] = 1 Then
          Shapes.HideShape(Batten[3][3])
          Shapes.ShowShape(Batten[3][3])
          Battennumber[3][3] = 0
        Else
          Shapes.ShowShape(Batten[3][3])
          Shapes.HideShape(Batten[3][3])
          Battennumber[3][3] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[3][4]) <= my And my < Shapes.GetTop(whitemasu[3][5]) Then
        If Battennumber[3][4] = 1 Then
          Shapes.HideShape(Batten[3][4])
          Shapes.ShowShape(Batten[3][4])
          Battennumber[3][4] = 0
        Else
          Shapes.ShowShape(Batten[3][4])
          Shapes.HideShape(Batten[3][4])
          Battennumber[3][4] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[3][5]) <= my And my < Shapes.GetTop(whitemasu[3][5]) + 50 Then
        If Battennumber[3][5] = 1 Then
          Shapes.HideShape(Batten[3][5])
          Shapes.ShowShape(Batten[3][5])
          Battennumber[3][5] = 0
        Else
          Shapes.ShowShape(Batten[3][5])
          Shapes.HideShape(Batten[3][5])
          Battennumber[3][5] = 1
        EndIf
      EndIf
    EndIf

    If Shapes.GetLeft(whitemasu[4][1]) <= mx And mx < Shapes.GetLeft(whitemasu[5][1]) Then
      If Shapes.GetTop(whitemasu[4][1]) <= my And my < Shapes.GetTop(whitemasu[4][2]) Then
        If Battennumber[4][1] = 1 Then
          Shapes.HideShape(Batten[4][1])
          Shapes.ShowShape(Batten[4][1])
          Battennumber[4][1] = 0
        Else
          Shapes.ShowShape(Batten[4][1])
          Shapes.HideShape(Batten[4][1])
          Battennumber[4][1] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[4][2]) <= my And my < Shapes.GetTop(whitemasu[4][3]) Then
        If Battennumber[4][2] = 1 Then
          Shapes.HideShape(Batten[4][2])
          Shapes.ShowShape(Batten[4][2])
          Battennumber[4][2] = 0
        Else
          Shapes.ShowShape(Batten[4][2])
          Shapes.HideShape(Batten[4][2])
          Battennumber[4][2] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[4][3]) <= my And my < Shapes.GetTop(whitemasu[4][4]) Then
        If Battennumber[4][3] = 1 Then
          Shapes.HideShape(Batten[4][3])
          Shapes.ShowShape(Batten[4][3])
          Battennumber[4][3] = 0
        Else
          Shapes.ShowShape(Batten[4][3])
          Shapes.HideShape(Batten[4][3])
          Battennumber[4][3] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[4][4]) <= my And my < Shapes.GetTop(whitemasu[4][5]) Then
        If Battennumber[4][4] = 1 Then
          Shapes.HideShape(Batten[4][4])
          Shapes.ShowShape(Batten[4][4])
          Battennumber[4][4] = 0
        Else
          Shapes.ShowShape(Batten[4][4])
          Shapes.HideShape(Batten[4][4])
          Battennumber[4][4] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[4][5]) <= my And my < Shapes.GetTop(whitemasu[4][5]) + 50 Then
        If Battennumber[4][5] = 1 Then
          Shapes.HideShape(Batten[4][5])
          Shapes.ShowShape(Batten[4][5])
          Battennumber[4][5] = 0
        Else
          Shapes.ShowShape(Batten[4][5])
          Shapes.HideShape(Batten[4][5])
          Battennumber[4][5] = 1
        EndIf
      EndIf
    EndIf

    If Shapes.GetLeft(whitemasu[5][1]) <= mx And mx < Shapes.GetLeft(whitemasu[5][1]) + 50 Then
      If Shapes.GetTop(whitemasu[5][1]) <= my And my < Shapes.GetTop(whitemasu[5][2]) Then
        If Battennumber[5][1] = 1 Then
          Shapes.HideShape(Batten[5][1])
          Shapes.ShowShape(Batten[5][1])
          Battennumber[5][1] = 0
        Else
          Shapes.ShowShape(Batten[5][1])
          Shapes.HideShape(Batten[5][1])
          Battennumber[5][1] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[5][2]) <= my And my < Shapes.GetTop(whitemasu[5][3]) Then
        If Battennumber[5][2] = 1 Then
          Shapes.HideShape(Batten[5][2])
          Shapes.ShowShape(Batten[5][2])
          Battennumber[5][2] = 0
        Else
          Shapes.ShowShape(Batten[5][2])
          Shapes.HideShape(Batten[5][2])
          Battennumber[5][2] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[5][3]) <= my And my < Shapes.GetTop(whitemasu[5][4]) Then
        If Battennumber[5][3] = 1 Then
          Shapes.HideShape(Batten[5][3])
          Shapes.ShowShape(Batten[5][3])
          Battennumber[5][3] = 0
        Else
          Shapes.ShowShape(Batten[5][3])
          Shapes.HideShape(Batten[5][3])
          Battennumber[5][3] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[5][4]) <= my And my < Shapes.GetTop(whitemasu[5][5]) Then
        If Battennumber[5][4] = 1 Then
          Shapes.HideShape(Batten[5][4])
          Shapes.ShowShape(Batten[5][4])
          Battennumber[5][4] = 0
        Else
          Shapes.ShowShape(Batten[5][4])
          Shapes.HideShape(Batten[5][4])
          Battennumber[5][4] = 1
        EndIf
      EndIf
      
      If Shapes.GetTop(whitemasu[5][5]) <= my And my < Shapes.GetTop(whitemasu[5][5]) + 50 Then
        If Battennumber[5][5] = 1 Then
          Shapes.HideShape(Batten[5][5])
          Shapes.ShowShape(Batten[5][5])
          Battennumber[5][5] = 0
        Else
          Shapes.ShowShape(Batten[5][5])
          Shapes.HideShape(Batten[5][5])
          Battennumber[5][5] = 1
        EndIf
      EndIf
    EndIf
    
  EndIf
  
EndSub


このプログラムのあれこれを変更すれば、マス目を増やしたり、答えを変えたりすることができますね。

お絵かきロジック

ところでこれ何? 出来上がってから疑問に思う今日このごろ。w
一応舟のつもりで書いたんですけど。w


▲TOPへ戻る