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

Username:   Password: 
 RegisterRegister   
 Battleship - SIMPLE DRAG + DROP HELP
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
hez




PostPosted: Sat May 31, 2003 6:32 pm   Post subject: Battleship - SIMPLE DRAG + DROP HELP

in this part of my prog i want to drag the "minesweeper image" then i will figure out the rest

can someone please tell me how to use drag and drop on an iamge in turing so i can figure out how to and where to place the ships



thnx alot



2-Player LAN BATTLESHIP.zip
 Description:

Download
 Filename:  2-Player LAN BATTLESHIP.zip
 Filesize:  9.81 KB
 Downloaded:  455 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sat May 31, 2003 6:36 pm   Post subject: (No subject)

well while dragging you're just making the picture follow the mouse
code:

loop
Mouse.Where(x,y,b)
Pic.Draw(picID,x,y,picMerge)
exit when b=1
end loop


now once you exit the loop (press the button) you find nearest cell.
code:

round(X/10)


that should result in the closest cell if each is 10 pixels in size. Ex: X=100, then its 10th cell.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
hez




PostPosted: Sat May 31, 2003 6:40 pm   Post subject: (No subject)

i'll see if it works thnx



ummm exactky were amm i suppsoed to put it in my prog?
Tony




PostPosted: Sat May 31, 2003 7:13 pm   Post subject: (No subject)

while and after you drag
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
hez




PostPosted: Sat May 31, 2003 10:46 pm   Post subject: (No subject)

lol that drag mouse thing is hell so i just used the arrow keys (don't midn me plz).......

thnx
Blade




PostPosted: Sun Jun 01, 2003 12:40 am   Post subject: (No subject)

well. i kinda whipped up an example that you could use. its fully documented... so heh..
code:
var x, y, b : int %the x,y coordinates for the mouse, and b for button
var pic : int := Pic.FileNew ("c:/sites/images/avatars&sigs/blademoon.jpg") %import pic
var sx, sy : int := 100 %the co-ordinates of x,y
View.Set ("Graphics:600;600,nobuttonbar,offscreenonly")


loop %loop to keep checking
    Mouse.Where (x, y, b)     %checking to see where the mouse is, and if the button's been clicked
    Pic.Draw (pic, sx, sy, picMerge)     %continuing to draw the picture
    if (x > sx & x < sx + Pic.Width(pic) & y > sy & y < sy + Pic.Height(pic) & b = 1) then     %check to see if the image has been clicked on
        loop     %loop to move the image
            Mouse.Where (x, y, b)     %checking if you've moved the mouse
            Pic.Draw (pic, sx, sy, picMerge)         %must draw the picture while moving
            sx := x - Pic.Width(pic) div 2     %set the new co-ordinates of the picture to where the mouse is
            sy := y - Pic.Height(pic) div 2    %same with x, but on the y axis
            exit when b = 0     %exits the movement of the picture when you let go of the mouse button
            View.Update
            cls     %clear the screen
        end loop
    end if
    View.Update
    cls %clear again..
end loop
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  [ 6 Posts ]
Jump to:   


Style:  
Search: