Computer Science Canada Need Help with drag command! |
Author: | leu_raz [ Wed Jan 07, 2004 11:23 am ] |
Post subject: | Need Help with drag command! |
Hy i need help with the drag command.I have my ISP due in about one week and my project is that i am hired by a grade 1 teacher and i am to test the ability of kids to put 5 blocks in order from the smallest to the largest.My question is:How do you make the blocks move?But move not leaving tracks behind.???And my other question is how does the computer know when all the blocks are in the right order?That's it thank you very much if you cna help... ![]() |
Author: | Dan [ Wed Jan 07, 2004 9:51 pm ] |
Post subject: | |
well you dont realy need to have them drag the blocks, you could just have numbers under them and have the kid hit a number then another number to rep where it should go. but if you whont to the drag way you will have clear the screen then redraw it to stop it from leaving a trail. or you could make a pic of the box and save it some format like bmp and then uses the pic comands to draw it then undraw and draw it in a new place. to tell when it is in the right place you whould have to use closione dection that whould only go off when the mouse bottion has been let go of. the clostion dection whould be cheking wheter the draged box is in the destation box and if the mouse buttion is still down. this could be done with math (the right way) or with whatdotcolor (the cheap way). there is more info a the mouse, colosion dection and moving stuff on the screen in the tutorail section. |
Author: | leu_raz [ Thu Jan 08, 2004 5:35 pm ] |
Post subject: | |
Yo thanks for the help but i still need it.Unfortunately i can't use the method you recommended.For the second part(how does Turing know when..)i haven't tried it yet cuz i haven't finished this part yet.SO i need another way to solve it.Here's my code so far: %Declare Variables var c := 10 var d := 10 var x, y, b : int var e := 60 var f := 60 var answer : string var g := 150 var h := 100 var i := 400 var j := 200 %Welcome Note colorback (blue) Text.Color (white) put "" : 20, "Hello and welcome to THE TEST" put " You must drag the boxes in their specified place." put "The perfect score can be taken if you arrange the boxes..." put "from the smallest to the largest" put "Welcome to the test!You must put each box in it's predefined place." put "If you want to continue input next." put "If you wish to quit just say esc." get answer for p : 0 .. 1 if answer = "next" then cls colorback (101) Text.Color (105) put "" .. put "Well put the boxes in the right order" elsif answer = "esc" then exit end if end for %BOXES drawbox (150, 30, 180, 60, black) drawfillbox (10, 10, 50, 50, blue) drawfillbox (60, 60, 120, 120, red) drawfillbox (150, 100, 250, 200, black) drawfillbox (400, 200, 440, 240, green) loop mousewhere (x, y, b) if x >= c and x <= (c + 40) and y >= d and y <= (d + 40) and b = 1 then drawfillbox (x, y, (c + 40), (d + 40), blue) delay (1) drawfillbox (x, y, (c + 40), (d + 40), 101) c := x - 20 d := y - 20 drawfillbox (x, y, (c + 40), (d + 40), blue) elsif x >= e and x <= (e + 60) and y >= f and y <= (f + 60) and b = 1 then drawfillbox (x, y, (e + 60), (f + 60), red) delay (1) drawfillbox (x, y, (e + 60), (f + 60), 101) e := x - 30 f := y - 30 drawfillbox (x, y, (e + 60), (f + 60), red) elsif x >= g and x <= (g + 80) and y >= h and y <= (h + 80) and b = 1 then drawfillbox (x, y, (g + 100), (h + 100), black) delay (1) drawfillbox (x, y, (g + 100), (h + 100), 101) g := x - 50 h := y - 50 drawfillbox (x, y, (g + 100), (h + 100), black) elsif x >= i and x <= (i + 40) and y >= j and y <= (j + 40) and b = 1 then drawfillbox (x, y, (i + 40), (j + 40), green) delay (1) drawfillbox (x, y, (i + 40), (j + 40), 101) i := x - 20 j := y - 20 drawfillbox (x, y, i + 40, j + 40, green) end if drawbox (150, 30, 180, 60, black) drawfillbox (10, 10, 50, 50, blue) drawfillbox (60, 60, 120, 120, red) drawfillbox (150, 100, 250, 200, black) drawfillbox (400, 200, 440, 240, green) end loop THXXX ![]() |
Author: | DanShadow [ Thu Jan 08, 2004 8:59 pm ] | ||
Post subject: | |||
hm...sorry to give the answer away...but here:
This should help you ALOT...there are for boxes, when a player clicks inside a box, the box follows his cursor until the player lets go of the 'click' button on his/her mouse. ![]() |
Author: | leu_raz [ Fri Jan 09, 2004 5:52 pm ] |
Post subject: | |
Well thankx alot man i owe u money or smtng .Anyway the program works i just need to spice it up a little.My next question is how do you make'em different sizes?Cuz i need five different boxes.(diff. color and diff.size) ![]() |
Author: | DanShadow [ Fri Jan 09, 2004 7:13 pm ] | ||||
Post subject: | |||||
For different sizes, expand the (x,y) co-ordinates in this part of the code:
and to change color, just instead of the 'i', put the color...like
|
Author: | leu_raz [ Fri Jan 09, 2004 8:39 pm ] |
Post subject: | |
Yo man thanks for the color it works but for the size it didn't work.Here's my code: var bxx, bxy : array 1 .. 5 of int bxx (1) := 190 bxy (1) := 200 bxx (2) := 50 bxy (2) := 70 bxx (3) := 300 bxy (3) := 330 bxx (4) := 100 bxy (4) := 140 bxx (5) := 120 bxy (5) := 200 |
Author: | air_force91 [ Sat Jan 10, 2004 1:35 pm ] |
Post subject: | |
im making a game in which the user will drag a bunch of boxes and place them in the correct place on the screen...my question is...do u think it's plagrarism if i refer to ur code for the drag part but make the size of the boxes according to which i want and include some other stuff in the code? |
Author: | santabruzer [ Sat Jan 10, 2004 1:39 pm ] |
Post subject: | |
techincally it is.. but you could probalby read his code, learn from it.. and use another.. that's the point of giving examples |