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

Username:   Password: 
 RegisterRegister   
 dragging words
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
air_force91




PostPosted: Wed Jan 14, 2004 6:44 pm   Post subject: dragging words

i have a code for dragging boxes on the screen but how can i drag words and place them on the correct place on the screen?

code:

var bxx, bxy : array 1 .. 8 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
bxx (5) := 100
bxy (5) := 150
bxx (6) := 200
bxy (6) := 250
bxx (7) :=300
bxy (7) :=340
bxx (8) :=200
bxy (8) :=250
var x3, y3, b3 : int := 0

var afontID : int:=Font.New ("Arial:8:bold")
loop
    setscreen ("offscreenonly")
    View.Update
    mousewhere (x3, y3, b3)
    Draw.FillBox (0, 0, maxx, maxy,0)
    Font.Draw ("RAM", 50, 100, afontID, yellow)
    for i : 1 .. 8
        Draw.FillBox (bxx (i) - 10, bxy (i) - 10, bxx (i) + 10, bxy (i) + 10, i)
    end for
    if (b3 = 1) then
        for i : 1 .. 8
            if (x3 > bxx (i) - 11 and x3 < bxx (i) + 11) and (y3 > bxy (i) - 11 and y3 < bxy (i) + 11) then
                loop
                    setscreen ("offscreenonly")
                    View.Update
                    mousewhere (x3, y3, b3)
                    Draw.FillBox (0, 0, maxx, maxy, 0)
                    for j : 1 .. 8
                        Draw.FillBox (bxx (j) - 10, bxy (j) - 10, bxx (j) + 10, bxy (j) + 10, j)
                    end for
                    bxx (i) := x3
                    bxy (i) := y3
                    Draw.FillBox (bxx (i) - 10, bxy (i) - 10, bxx (i) + 10, bxy (i) + 10, 14)
                    exit when b3 not= 1
                end loop
            end if
        end for
    end if
end loop



someone on this website posted this code...im refering to it for my project...ofcourse i can't copy it...
Sponsor
Sponsor
Sponsor
sponsor
CjGaughan




PostPosted: Thu Jan 15, 2004 9:08 am   Post subject: (No subject)

how about putting the words on the boxes (or any graphic for that matter).

Just use seperate pictures/graphics (make them in paint or anything), and move them around like you are doing the boxes.

There is probably a way to make the word move (as it is actually a graphic, like the boxes are).

Probably somewhere in the code has a flaw, and is only meant for a box? No time to look over your code in depth right now...maybe someone else can give a better solution?
AsianSensation




PostPosted: Thu Jan 15, 2004 7:24 pm   Post subject: (No subject)

easiest way is probably mathematics manipulation with Pic.Width and Pic.Height.

save whatever you drew as a picture (not a physical file, just in the memory), and then use Pic.Height and Pic.Width to return to height and width of the picture. Since you already know the starting position of the picture (because you need it to draw it), then it's basicly moving a box with left bottom corner some coordinate, with width Pic.Width, and height Pic.Height of that picture. So you can then just drag that box. No need with whatdotcolor or any color checking stuff.
DanShadow




PostPosted: Thu Jan 15, 2004 10:13 pm   Post subject: (No subject)

Hello again air_force91...I see your still finding use for my "box moving" code...well, im here to help again. Very Happy It's actually extremely similar to the box moving code.
code:

%font is the font style, (tx,ty) are the texts' x and y values....
%...(mx,my,mb) are the mouses' x,y and button values
var font, tx, ty, mx, my, mb : int := 200
font := Font.New ("serif:12")


loop
    setscreen ("offscreenonly")
    View.Update
    Draw.FillBox (0, 0, maxx, maxy, 0)
    Draw.Text ("This is moving font", tx, ty, font, 255)
    mousewhere (mx, my, mb)
    if (mb = 1) and (mx > tx and my > ty and my < ty + 10) then
        loop
            setscreen ("offscreenonly")
            View.Update
            Draw.FillBox (0, 0, maxx, maxy, 0)
            Draw.Text ("This is moving font", tx, ty, font, 255)
            mousewhere (mx, my, mb)
            tx := mx
            ty := my
            exit when mb not= 1
        end loop
    end if
end loop

When you click around the text area, the text will follow your cursor while your button is down. (Man...for all the help I give in Turing, I should also be a Turing Mod. Very Happy)
AsianSensation




PostPosted: Thu Jan 15, 2004 10:26 pm   Post subject: (No subject)

getting a bit ambitious now aren't we?
Homer_simpson




PostPosted: Sat Jan 17, 2004 2:03 pm   Post subject: (No subject)

one thing u should do for better performance... setscreen outside the loop!
the_short1




PostPosted: Tue Jan 20, 2004 8:30 pm   Post subject: (No subject)

if you have MS WORD... make some wordart and select it.. press copy... and paste it into a image program... that would work too... instead of complicated code... you could use box code... granted... need bbunch of pics with program.... i going to use that drag box code for my Text Twist game.... hopefullly to have a first internet Beta before end of Feb...
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  [ 7 Posts ]
Jump to:   


Style:  
Search: