Number choosing program
Author |
Message |
TheSecretWaterBender
|
Posted: Thu Jan 06, 2011 11:41 pm Post subject: Number choosing program |
|
|
What is it you are trying to achieve?
Im trying to create a program where the user can click on six numbers and each number is displayed and stored (they can't choose the same number twice)
What is the problem you are having?
I cannot click more than once before the program ends
Describe what you have tried to solve this problem
I tried adding another for statement and have no idea as to storing (preferably in an array) or stopping a number (or range from being clicked twice) efficiently
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
Turing: |
var count: int:= 1
var x,y,b: int
var font1: int := Font.New ("Comicsans:25:bold")
for z: 0.. 6
for q: 0.. 6
Draw.Box (20+z* 60, 320-q* 50, 80+z* 60, 370-q* 50, blue)
Font.Draw(intstr(q* 7+ (z+ 1)), 35+z* 60, 335-q* 50, font1, red)
end for
end for
for z: 0.. 6
for q: 0.. 6
loop
Mouse.Where(x,y,b )
if b = 1
then
if x> 20+z* 60 and x< 80+z* 60 and y> 320-q* 50 and y< 370-q* 50
then
put q* 7+ (z+ 1)," "..
end if
end if
exit when b= 1
end loop
end for
end for
|
Please specify what version of Turing you are using
version 4.1.1 |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Tony

|
Posted: Thu Jan 06, 2011 11:44 pm Post subject: RE:Number choosing program |
|
|
Can you briefly explain what's going on inside your loop? |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
TheSecretWaterBender
|
Posted: Thu Jan 06, 2011 11:51 pm Post subject: RE:Number choosing program |
|
|
the loop posts the number clicked based on the parameters given (it's a 7x7 grid with numbers from 1-49) |
|
|
|
|
 |
TheSecretWaterBender
|
Posted: Sun Jan 09, 2011 12:40 am Post subject: Re: Number choosing program |
|
|
I actually found a temporary fix but i am having problems now with being able to click again after they click on the same number twice |
|
|
|
|
 |
Tony

|
Posted: Sun Jan 09, 2011 12:42 am Post subject: RE:Number choosing program |
|
|
Post the new code that goes along with that question. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
TheSecretWaterBender
|
Posted: Sun Jan 09, 2011 12:48 am Post subject: Re: Number choosing program |
|
|
woops http://compsci.ca/v3/images/smiles/icon_redface.gif
Turing: |
for s: 1.. 6
for z: 0.. 6
for q: 0.. 6
loop
Mouse.Where(x,y,b )
if b = 1
then
if x> 20+z* 60 and x< 80+z* 60 and y> 320-q* 50 and y< 370-q* 50
then
a (s ):=q* 7+ (z+ 1)
if s > 1 then
for p : 1 .. 5
if p not= s and p < s then
if a (s ) = a (p ) then
put "You cannot guess the same number twice"
else
end if
end if
end for
end if
Draw.FillBox(20+z* 60, 320-q* 50, 80+z* 60, 370-q* 50, blue)
end if
end if
exit when b= 1
end loop
end for
end for
delay (300)
end for
|
|
|
|
|
|
 |
|
|