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

Username:   Password: 
 RegisterRegister   
 Manipulating the Mouse
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
waka




PostPosted: Mon Jun 25, 2007 6:29 pm   Post subject: Manipulating the Mouse

I have a program that pans a picture with the mouse and I am trying to figure out the best way to make it keep panning once the mouse hits the side of the screen. Now this is easy to do but it will continue to pan. What I want is to be able to do an endless pan but only pan when I move the mouse so "if MouseX < 0 then pan" won't do the trick. I'm quite sure Turing wont actually reset the mouse position so my question is what would be the easiest way to do an endless pan only on mouse movement. Here is the basic code.

code:
setscreen ("graphics:1280;650,offscreenonly,nocursor,nobuttonbar")
var MouseY, MouseX, MouseButton, BackgroundX, MouseXTemp, MouseYTemp, BackgroundY, PanVert : int
var Background := Pic.FileNew ("Panoramic_Photo3.jpg")
BackgroundY := 0
BackgroundX := 0
MouseX := 0
MouseY := 0
MouseXTemp := 0
MouseYTemp := 0
loop
    cls
    Pic.Draw (Background, BackgroundX, BackgroundY, picCopy)
    Mouse.Where (MouseX, MouseY, MouseButton)
    if MouseX > MouseXTemp then
        PanVert := MouseX - MouseXTemp
        BackgroundX := BackgroundX - PanVert
    end if
    if MouseX < MouseXTemp then
        PanVert := MouseXTemp - MouseX
        BackgroundX := BackgroundX + PanVert
    end if
    MouseXTemp := MouseX
    MouseYTemp := MouseY
    View.Update
end loop
[/b]
Sponsor
Sponsor
Sponsor
sponsor
Saad




PostPosted: Mon Jun 25, 2007 7:52 pm   Post subject: Re: Manipulating the Mouse

That is not possible with turing i think, but you can create a simple program to do that in another language.

You could make it move when it clicks so that the player can move his mouse back to where he wants and then click and rotates
Auraiken




PostPosted: Tue Jun 26, 2007 5:08 pm   Post subject: Re: Manipulating the Mouse

It's possible. Requires a bit of math. You'll need to create two pictures. One to be your first image that you can pan with. Second to connect the one picture with the first once you reach the end of the first. you can free the image once it is off screen and create a new one when you need to.

Also you should have the mouse offset by half the width of the window. So you aren't halfway through the pic when you are in the middle of the window.

Turing gets it's mouse position relative to the window.

if i have time i'll work out something like it.
Saad




PostPosted: Tue Jun 26, 2007 5:41 pm   Post subject: Re: Manipulating the Mouse

Ahh read the question wrong

All you need to do is compare your last x coordinate with your current x coordinate, if they arent equal then youve moved.
waka




PostPosted: Sun Jul 08, 2007 9:20 pm   Post subject: Re: Manipulating the Mouse

I think you've read my code and question wrong, I have already done the mouse panning I just cant get the picture to keep panning once my mouse has hit a side. (and the picture only pans on mouse movement so if the mouse is < 0 then pan wont work)


Thanks Auraiken, if you do find a solution I'd appreciate it.
Nick




PostPosted: Wed Aug 15, 2007 5:49 am   Post subject: RE:Manipulating the Mouse

u could make a if MouseX<=0 then MouseX:=0 same with MouseY... i think i know what u wanna do... u want the pic to move when u move the mouse right?
Aziz




PostPosted: Wed Aug 15, 2007 8:02 am   Post subject: RE:Manipulating the Mouse

He already got that part. He wants it so if the picture is panning, and the mouse hits the edge of the screen (or goes off screen), it will continue to pan.

What you could do, is set a variable that says which direction the pan is going.

code:
var dir : int % +ive for right, -ive for left


and move the picture right by dir pixels. Moving it right negative pixels will move it left. Then, you can have a specific border, where, say, if the mouse is within 5 pixels of the edge of the screen (or off the screen), then don't change the dir value. Only when you notice the mouse has stopped, change the dir value. No turing in front of me to test.
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: