
-----------------------------------
Dogdemon
Wed Apr 28, 2004 4:45 pm

Help &quot;How to make button and put letter in the box?&amp
-----------------------------------
Can somebody help me edit my program so i can click on the boxes in my 10 by 10 grid and then input a letteR in a box?
or show me how? thanx

setscreen ("graphics:1000;650")
var fx : array 1..10, 1..10 of boolean
var ax, bx : array 1..11 of int
var x, y, z: int

for i : 1 .. 10
    for j : 1 .. 10
        fx (i, j) := false
    end for
end for

for i: 1..10
    ax(i) := 0
    bx(i) := 0
end for

for b : 1 .. 10
    for a : 1 .. 10
        %10 by 10 grid
        drawfillbox (90 + ax (a), 150 + bx (b), 145 + ax (a), 205+ bx (b), white)
        drawfillbox (95 + ax (a), 155 + bx (b), 140 + ax (a), 200+ bx (b), 7)
        drawbox (90 + ax (a), 150+ bx (b), 140 + ax (a), 205+ bx (b), 7)

        ax (a + 1) := a * 50
    end for
    bx (b + 1) := b*50
end for

-----------------------------------
Paul
Wed Apr 28, 2004 4:52 pm


-----------------------------------
Something like this?
THis is rough and not bugproof, but it works.... for now.
You can make it so that it centers the letter in the box by ur self.

setscreen ("graphics:1000;650") 
var font := Font.New ("serif:24")
var fx : array 1..10, 1..10 of boolean 
var ax, bx : array 1..11 of int 
var x, y, z, btx, bye, btn: int 
var key: string (1)

for i : 1 .. 10 
for j : 1 .. 10 
fx (i, j) := false 
end for 
end for 

for i: 1..10 
ax(i) := 0 
bx(i) := 0 
end for 

for b : 1 .. 10 
for a : 1 .. 10 
%10 by 10 grid 
drawfillbox (90 + ax (a), 150 + bx (b), 145 + ax (a), 205+ bx (b), white) 
drawfillbox (95 + ax (a), 155 + bx (b), 140 + ax (a), 200+ bx (b), 7) 
drawbox (90 + ax (a), 150+ bx (b), 140 + ax (a), 205+ bx (b), 7) 

ax (a + 1) := a * 50 
end for 
bx (b + 1) := b*50 
end for
loop
Mouse.Where (btx, bye, btn)
if btn = 1 then
getch (key)
Draw.Text (key, btx, bye, font, 12)
delay (100)
end if
end loop


-----------------------------------
Dogdemon
Wed Apr 28, 2004 5:01 pm


-----------------------------------
i want all my boxes to be buttons (The black area) . Also, when i click on a box, i want to put a letter in it center. Thanks for the help by the way. I been trying so long to make boxes for my grid and put a letter in the center of it for a long time and i have no clue what to do. Im not so great in turing

-----------------------------------
Paul
Wed Apr 28, 2004 5:06 pm


-----------------------------------
There's nothing simple that I can think of, right now I would get the coordinates of the squares using an array, then whenever a click lands in one of the squares, it gets the coordinates for that square and prints out the letter there.

-----------------------------------
Dogdemon
Wed Apr 28, 2004 5:10 pm


-----------------------------------
do i use a 2d array?

-----------------------------------
Paul
Wed Apr 28, 2004 5:12 pm


-----------------------------------
You don't have to if you don't wish to. 2D arrays arn't neccessary, unless ur manipulating information in  a chart and stuff like that. I suppose u can use one if you want.

-----------------------------------
Dogdemon
Wed Apr 28, 2004 5:14 pm


-----------------------------------
which way the faster way? also, can u make one button for me to see?

-----------------------------------
Dogdemon
Wed Apr 28, 2004 9:21 pm


-----------------------------------
i been at it for 1 hour and i still cant figure how to make the button....

-----------------------------------
AsianSensation
Fri Apr 30, 2004 5:20 pm


-----------------------------------
ok, alfter looking through the code, I think the size for each black square is 45 and each white square is 60. So you can just get the x and y position of your mouse by using Mouse.Where. Then, subtract from the x 90, because you start at 90. Then divide that number by 60, the resulting number, truncated, should be the horizontal index, do the samething for the y coordinate, except subtract from it 150 first, then div by 60

As a added insurance, do a whatdotcolor check for white or black to see which part of the square you clicked on.

-----------------------------------
Dogdemon
Sun May 02, 2004 11:30 am


-----------------------------------
ok i got the bottom left corner to work but i dont understand how to get the rest to work if someon could do this part for me i would be grateful. 



setscreen ("graphics:1000;650")
var font := Font.New ("serif:24")
var fx : array 1 .. 10, 1 .. 10 of boolean
var ax, bx : array 1 .. 11 of int
var x, y, z, btx, bye, btn : int
var key : string (1)

for i : 1 .. 10
    for j : 1 .. 10
        fx (i, j) := false
    end for
end for

for i : 1 .. 10
    ax (i) := 0
    bx (i) := 0
end for

for b : 1 .. 10
    for a : 1 .. 10
        %10 by 10 grid
        drawfillbox (90 + ax (a), 150 + bx (b), 140 + ax (a), 200 + bx (b), white)
        drawfillbox (95 + ax (a), 155 + bx (b), 140 + ax (a), 200 + bx (b), 7)
        drawbox (90 + ax (a), 150 + bx (b), 140 + ax (a), 200 + bx (b), 7)

        ax (a + 1) := a * 50
    end for
    bx (b + 1) := b * 50
end for


var beenhit : boolean

loop
    mousewhere (x, y, z)
    if x >= 95 and x = 155 and y = 95 and x = 155 and y = 95 and x = 205 and y = 95 and x = 155 and y = 95 and x = 205 and y 