Computer Science Canada

How do you make an image rotate using Pic.Rotate and mouse controls?

Author:  mobin12 [ 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

Author:  Dreadnought [ 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).

Author:  mobin12 [ 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.

Author:  mirhagk [ 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

Author:  mobin12 [ 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.

Author:  mirhagk [ 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]

Author:  mobin12 [ 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

Author:  Dreadnought [ 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

Author:  mirhagk [ 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.


: