
-----------------------------------
leu_raz
Wed Jan 07, 2004 11:23 am

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... :idea:

-----------------------------------
Dan
Wed Jan 07, 2004 9:51 pm


-----------------------------------
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.

-----------------------------------
leu_raz
Thu Jan 08, 2004 5:35 pm


-----------------------------------
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 = d and y = e and x = f and y = g and x = h and y = i and x = j and y  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.
 :D

-----------------------------------
leu_raz
Fri Jan 09, 2004 5:52 pm


-----------------------------------
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) :oops:

-----------------------------------
DanShadow
Fri Jan 09, 2004 7:13 pm


-----------------------------------
For different sizes, expand the (x,y) co-ordinates in this part of the 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

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
Fri Jan 09, 2004 8:39 pm


-----------------------------------
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
Sat Jan 10, 2004 1:35 pm


-----------------------------------
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?

-----------------------------------
santabruzer
Sat Jan 10, 2004 1:39 pm


-----------------------------------
techincally it is.. but you could probalby read his code, learn from it.. and use another.. that's the point of giving examples
