Help "How to make button and put letter in the box?&
| Author |
Message |
Dogdemon
|
Posted: Wed Apr 28, 2004 4:45 pm Post subject: Help "How to make button and put letter in the box?& |
|
|
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 |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Paul

|
Posted: Wed Apr 28, 2004 4:52 pm Post subject: (No subject) |
|
|
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.
| code: |
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
|
Posted: Wed Apr 28, 2004 5:01 pm Post subject: (No subject) |
|
|
| 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

|
Posted: Wed Apr 28, 2004 5:06 pm Post subject: (No subject) |
|
|
| 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
|
Posted: Wed Apr 28, 2004 5:10 pm Post subject: (No subject) |
|
|
| do i use a 2d array? |
|
|
|
|
 |
Paul

|
Posted: Wed Apr 28, 2004 5:12 pm Post subject: (No subject) |
|
|
| 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
|
Posted: Wed Apr 28, 2004 5:14 pm Post subject: (No subject) |
|
|
| which way the faster way? also, can u make one button for me to see? |
|
|
|
|
 |
Dogdemon
|
Posted: Wed Apr 28, 2004 9:21 pm Post subject: (No subject) |
|
|
| i been at it for 1 hour and i still cant figure how to make the button.... |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
AsianSensation
|
Posted: Fri Apr 30, 2004 5:20 pm Post subject: (No subject) |
|
|
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
|
Posted: Sun May 02, 2004 11:30 am Post subject: (No subject) |
|
|
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 <= 140 and y >= 155 and y <= 200 and z = 1 then
beenhit := true
getch (key)
Draw.Text (key, 105, 170, font, 10)
else
beenhit := false
end if
end loop |
|
|
|
|
 |
Dogdemon
|
Posted: Tue May 04, 2004 1:43 pm Post subject: (No subject) |
|
|
| can someone help plz? i need it for tommorow..... |
|
|
|
|
 |
Dogdemon
|
Posted: Tue May 04, 2004 3:12 pm Post subject: (No subject) |
|
|
ok i understand how to get the letter in each box but when i loop another one it doesnt work... but when i delete my first one for my other loop it will work on the other box how can i get multiple loop going on the ame time?
loop
mousewhere (x, y, z)
if x >= 95 and x <= 140 and y >= 155 and y <= 200 and z = 1 then
beenhit := true
getch (key)
Draw.Text (key, 105, 170, font, 10)
else
beenhit := false
end if
end loop
loop
mousewhere (x, y, z)
if x >= 95 and x <= 140 and y >= 205 and y <= 250 and z = 1 then
beenhit := true
getch (key)
Draw.Text (key, 105, 220, font, 10)
else
beenhit := false
end if
end loop
| code: |
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 <= 140 and y >= 155 and y <= 200 and z = 1 then
beenhit := true
getch (key)
Draw.Text (key, 105, 170, font, 10)
else
beenhit := false
end if
end loop
loop
mousewhere (x, y, z)
if x >= 95 and x <= 140 and y >= 205 and y <= 250 and z = 1 then
beenhit := true
getch (key)
Draw.Text (key, 105, 220, font, 10)
else
beenhit := false
end if
end loop
|
|
|
|
|
|
 |
|
|