Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Draggable fill boxes with random placement
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
mariomania88




PostPosted: Wed Jan 07, 2004 11:14 am   Post subject: Draggable fill boxes with random placement

How do you make draggable filled boxes that are randomly placed on the screen. I already masde the boxes randomly appear.

P.S. I am in grade 10 doing an ISP project and help would be appreciated.
Sponsor
Sponsor
Sponsor
sponsor
mariomania88




PostPosted: Wed Jan 07, 2004 11:24 am   Post subject: Code for the question

If it helps, here is my code. Can someone correct it and tell me what they fixed? Thanks.

var x, y, b : int
randint (x1, 0, maxx)
randint (y1, 0, maxy)
drawfillbox (x1, y1, x1 + 100, y1 + 100, black)
var a, c : int
a := x1
c := y1

loop
mousewhere (x, y, b)
if x >= a and x <= a + 100 and y >= c and y <= c + 100 and b = 1 then
drawfillbox (x1, y1, x1 + 100, y1 + 100, black)
a := x - 50
c := y - 50
end if
end loop
shorthair




PostPosted: Wed Jan 07, 2004 11:32 am   Post subject: (No subject)

draw a white trace behind the box to appear as if it is not leaving a trail
mariomania88




PostPosted: Wed Jan 07, 2004 11:37 am   Post subject: (No subject)

But the thing doesnt move at all
shorthair




PostPosted: Wed Jan 07, 2004 11:44 am   Post subject: (No subject)

you have to let turing know where the mouse is on the screen and if the mouse is within hte pange of the box ( a certain x,y coordinate ) then you need to tell turing that you want to move it by saying ( not real sntax)
code:

if mousex = boxx
and mousey =boxy
then
end if
mariomania88




PostPosted: Wed Jan 07, 2004 12:31 pm   Post subject: (No subject)

Can you post the entire code fixed please? Only because I dont have much time.
test123




PostPosted: Wed Jan 07, 2004 1:03 pm   Post subject: hey

Hi, i am having the same problem, please help me out too. Sad
shorthair




PostPosted: Wed Jan 07, 2004 2:26 pm   Post subject: (No subject)

tHATS NOT HOW WE DO THINGS HERE AT COMPSCI. if you need help the nwe will give it to you but we dont write programs for people especially those who dont even try looking in hte tutorials and in the book , this is your isp , if i write it for you i want my name on it and that i wrote it , that my only deal , il give you a finished .exe , otherwise you should try this on your own
mariomania88




PostPosted: Wed Jan 07, 2004 6:51 pm   Post subject: Nevermind

Sorry for bothering you, but I fixed it and it works. Now all I have to do is clear the object so it doesnt leave a trace. Thanks for your help.
shorthair




PostPosted: Wed Jan 07, 2004 6:57 pm   Post subject: (No subject)

got you an even 25 bits for trying the program on your own and getting it done , good for you im glad you managed to do it,

+ BITS
mariomania88




PostPosted: Thu Jan 08, 2004 10:17 am   Post subject: THANKS FOR THE BITS!!

Thanks a lot shorthair! And while we're discussing bits, can you tell me what they're for?
mariomania88




PostPosted: Thu Jan 08, 2004 11:27 am   Post subject: MORE HELP!!

I've ran into another problem. When I drag the boxes, they drag, BUT, the boxes dont come off of their places. The only one that does it is the small yellow box, and when I let go of the box, the box doesnt stay on the screen. Can I get some advice for making the boxes stay in the postition they're dragged to? Here is the code (below)

%This Draws the randomized boxes
var x, y, b : int
randint (x1, 0, maxx)
randint (y1, 0, maxy)
drawfillbox (x1, y1, x1 + 100, y1 + 100, black)
randint (x1, 0, maxx)
randint (y1, 0, maxy)
drawfillbox (x1, y1, x1 + 100, y1 + 100, 41)
randint (x1, 0, maxx)
randint (y1, 0, maxy)
drawfillbox (x1, y1, x1 + 20, y1 + 20, 5)
randint (x1, 0, maxx)
randint (y1, 0, maxy)
drawfillbox (x1, y1, x1 + 20, y1 + 20, 10)
randint (x1, 0, maxx)
randint (y1, 0, maxy)
drawfillbox (x1, y1, x1 + 20, y1 + 20, 14)

var a, c, d, e, f, g, h, i, j, k : int
a := x1
c := y1
d := x1
e := y1
f := x1
g := y1
h := x1
i := y1
j := x1
k := y1


loop
mousewhere (x, y, b)
if x > f and x <= (f + 20) and y >= g and y <= (g + 20) and b = 1 then
locate (23, 35)
put ""
drawfillbox (x, y, x + 20, y + 20, 5)
delay (100)
drawfillbox (x, y, x + 20, y + 20, white)
f := x - 10
g := y - 10
elsif x > h and x <= (h + 20) and y >= i and y <= (i + 20) and b = 1 then
locate (23, 35)
put ""
drawfillbox (x, y, x + 20, y + 20, 10)
delay (100)
drawfillbox (x, y, x + 20, y + 20, white)
h := x - 10
elsif x > j and x <= (j + 20) and y >= k and y <= (k + 20) and b = 1 then
locate (23, 35)
put ""
drawfillbox (x, y, x + 20, y + 20, 14)
delay (100)
drawfillbox (x, y, x + 20, y + 20, white)
j := x - 10
k := y - 10
elsif x >= a and x <= (a + 100) and y >= c and y <= (c + 100) and b = 1 then
locate (23, 35)
put ""
drawfillbox (x, y, x + 100, y + 100, black)
delay (100)
drawfillbox (x, y, x + 100, y + 100, white)
a := x - 50
c := y - 50
elsif x > d and x <= (d + 100) and y >= e and y <= (e + 100) and b = 1 then
locate (23, 35)
put ""
drawfillbox (x, y, x + 100, y + 100, 41)
delay (100)
drawfillbox (x, y, x + 100, y + 100, white)
d := x - 50
e := y - 50
else
locate (23, 35)
put "Nothing is selected"
end if

drawfillbox (280, 20, 360, 60, blue) %Draws base
drawfillbox (310, 60, 330, 100, blue) %Draws stand
drawfillarc (maxx div 2, maxy div 2 - 20, 100, 100, 180, 360, blue) %Draws weight table
drawfillbox (295, maxy div 2 - 20, 330, maxy - 20, red) %Draws the box with the lines in it
drawfillbox (x1, y1, x1 + 100, y1 + 100, black)
drawfillbox (x1, y1, x1 + 100, y1 + 100, 41)
drawfillbox (x1, y1, x1 + 20, y1 + 20, 5)
drawfillbox (x1, y1, x1 + 20, y1 + 20, 10)
drawfillbox (x1, y1, x1 + 20, y1 + 20, 14)

end loop
test123




PostPosted: Mon Jan 12, 2004 2:05 pm   Post subject: (No subject)

DUDE???? No response yet. I need help too.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 13 Posts ]
Jump to:   


Style:  
Search: