Need Help with drag command!
Author 
Message 
leu_raz

Posted: 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... 





Sponsor Sponsor



Dan

Posted: Wed Jan 07, 2004 9:51 pm Post subject: (No 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. 
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! 




leu_raz

Posted: Thu Jan 08, 2004 5:35 pm Post subject: (No 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 





DanShadow

Posted: Thu Jan 08, 2004 8:59 pm Post subject: (No subject) 


hm...sorry to give the answer away...but here:
code: 
var bxx, bxy : array 1 .. 4 of int
bxx (1) := 200
bxy (1) := 200
bxx (2) := 50
bxy (2) := 100
bxx (3) := 300
bxy (3) := 340
bxx (4) := 500
bxy (4) := 100
var x, y, b : int := 0
loop
setscreen ("offscreenonly")
View.Update
mousewhere (x, y, b)
Draw.FillBox (0, 0, maxx, maxy, 0)
for i : 1 .. 4
Draw.FillBox (bxx (i)  10, bxy (i)  10, bxx (i) + 10, bxy (i) + 10, i)
end for
if (b = 1) then
for i : 1 .. 4
if (x > bxx (i)  11 and x < bxx (i) + 11) and (y > bxy (i)  11 and y < bxy (i) + 11) then
loop
setscreen ("offscreenonly")
View.Update
mousewhere (x, y, b)
Draw.FillBox (0, 0, maxx, maxy, 0)
for j : 1 .. 4
Draw.FillBox (bxx (j)  10, bxy (j)  10, bxx (j) + 10, bxy (j) + 10, j)
end for
bxx (i) := x
bxy (i) := y
Draw.FillBox (bxx (i)  10, bxy (i)  10, bxx (i) + 10, bxy (i) + 10, 14)
exit when b not= 1
end loop
end if
end for
end if
end loop

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.






leu_raz

Posted: Fri Jan 09, 2004 5:52 pm Post subject: (No 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) 





DanShadow

Posted: Fri Jan 09, 2004 7:13 pm Post subject: (No subject) 


For different sizes, expand the (x,y) coordinates in this part of the code:
code: 
var bxx, bxy : array 1 .. 4 of int
bxx (1) := 200
bxy (1) := 200
bxx (2) := 50
bxy (2) := 100
bxx (3) := 300
bxy (3) := 340
bxx (4) := 500
bxy (4) := 100

and to change color, just instead of the 'i', put the color...like
code: 
var c:int:=1
for i : 1 .. 4
if i=1 then
c:=1
elsif i=2 then
c:=2
elsif i=3 then
c:=12
elsif i=4 then
c:=14
end if
Draw.FillBox (bxx (i)  10, bxy (i)  10, bxx (i) + 10, bxy (i) + 10,c)
end for







leu_raz

Posted: Fri Jan 09, 2004 8:39 pm Post subject: (No 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 





air_force91

Posted: Sat Jan 10, 2004 1:35 pm Post subject: (No 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? 





Sponsor Sponsor



santabruzer

Posted: Sat Jan 10, 2004 1:39 pm Post subject: (No subject) 


techincally it is.. but you could probalby read his code, learn from it.. and use another.. that's the point of giving examples 






