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

Username:   Password: 
 RegisterRegister   
 How do you make an image rotate using Pic.Rotate and mouse controls?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
mobin12




PostPosted: Mon Feb 06, 2012 8:01 pm   Post subject: How do you make an image rotate using Pic.Rotate and mouse controls?

What is it you are trying to achieve?
Want the image to rotate with the mouses position


What is the problem you are having?
can't get the image to rotate using the mouse

Turing:

setscreen ("graphics:450;300,nobuttonbar,offscreenonly")

var player : array 1 .. 2 of int
player (1) := 225
player (2) := 150
var chars : array char of boolean
%Mouse Controls
var mx, my, mb : int
%Picture File
var PlayerImage : int := Pic.FileNew ("Player.jpg")

loop
    Pic.Draw (PlayerImage, player (1), player (2), picMerge)
    Input.KeyDown (chars)
    if chars ('w') and player (2) < 282 then
        player (2) := player (2) + 1
    end if
    if chars ('s') and player (2) > 17 then
        player (2) := player (2) - 1
    end if
    if chars ('a') and player (1) > 17 then
        player (1) := player (1) - 1
    end if
    if chars ('d') and player (1) < 432 then
        player (1) := player (1) + 1
    end if
    View.Update
    Time.Delay (5)
    cls
end loop




Please specify what version of Turing you are using
Turing 1.4.1



Player.jpg
 Description:
Need Picture for code
Looks better when you run the program.
 Filesize:  11.88 KB
 Viewed:  88 Time(s)

Player.jpg


Sponsor
Sponsor
Sponsor
sponsor
Dreadnought




PostPosted: Mon Feb 06, 2012 8:54 pm   Post subject: Re: How do you make an image rotate using Pic.Rotate and mouse controls?

What have you tried? There's no evidence in the code you posted that you have tried anything.

Read the documentation on Mouse.Where and Pic.Rotate if you don't know where to start. Also, you will need some understanding of trigonometry (nothing too complicated though).
mobin12




PostPosted: Tue Feb 07, 2012 5:24 pm   Post subject: RE:How do you make an image rotate using Pic.Rotate and mouse controls?

I know trigonometry but i dont know how i would use it here.
mirhagk




PostPosted: Tue Feb 07, 2012 5:48 pm   Post subject: RE:How do you make an image rotate using Pic.Rotate and mouse controls?

You need to determine the angle that you need to rotate the picture. The x and y of your mouse, minus the x and y of the picture, makes a nice little triangle
mobin12




PostPosted: Wed Feb 08, 2012 8:22 pm   Post subject: RE:How do you make an image rotate using Pic.Rotate and mouse controls?

i dont understand. that is only two points thats not a triangle.
mirhagk




PostPosted: Wed Feb 08, 2012 9:11 pm   Post subject: Re: How do you make an image rotate using Pic.Rotate and mouse controls?

Posted Image, might have been reduced in size. Click Image to view fullscreen.

That should help you[/img]
mobin12




PostPosted: Mon Feb 13, 2012 3:32 pm   Post subject: RE:How do you make an image rotate using Pic.Rotate and mouse controls?

i cant see the image
Dreadnought




PostPosted: Mon Feb 13, 2012 4:04 pm   Post subject: Re: How do you make an image rotate using Pic.Rotate and mouse controls?

It's odd that you can't see the picture, here's my attempt at representing it in in text. Picture the '/' as a diagonal line and the 'v' and '^' as arrows.

code:
                                         v (x, y) of mouse
                                        /|
                                      /  |
                                    /    |
                                  /      | <- Length is difference between the y's
                                /        |
                              /         _|
                            /__________|_| <- Right angle
       (x, y) of character ^
                                   ^ Length is difference between the x's
Sponsor
Sponsor
Sponsor
sponsor
mirhagk




PostPosted: Mon Feb 13, 2012 4:48 pm   Post subject: RE:How do you make an image rotate using Pic.Rotate and mouse controls?

You need to look at your game like it's a cartesian plane (which it is). Draw things like this out on a sheet of graph paper, and figure it out.
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  [ 9 Posts ]
Jump to:   


Style:  
Search: