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

Username:   Password: 
 RegisterRegister   
 how do i make the arrow move?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
DBZ




PostPosted: Wed Nov 19, 2003 3:22 pm   Post subject: how do i make the arrow move?

i am having difficulty making an arrow move which i will describe at the bottom. everytime i try to make the arrow move, a part of it disappears. If you have a program similar to this, please send it to me.

the arrow is suppose to move from left bottom to right bottom and the move from right bottom to top right corner. then it moves from top left corner to top right corner and then it moves from top right corner to bottom right corner diagonaly.

Thanx! i appreciate it!
Sponsor
Sponsor
Sponsor
sponsor
Blade




PostPosted: Wed Nov 19, 2003 3:29 pm   Post subject: (No subject)

why don't you attach your code and we can help you with the problem
thoughtful




PostPosted: Wed Nov 19, 2003 7:12 pm   Post subject: (No subject)

basically u can either you sin an cos functions, that will make it easy to turn it on any angle. Or if u want a simple program u can jus draw 2 or 3 arrow positions and then move them according to their positions.
DBZ




PostPosted: Wed Nov 19, 2003 8:13 pm   Post subject: (No subject)

There is a problem with attatching my code. A friend of mine accidently overwrote on my disc and saved his stuff on my disc so now everytime i open the disc, it opens my friend's files . i am trying to find a way to recover that but if u know how to fix it then please tell me.
thanx!
Tony




PostPosted: Wed Nov 19, 2003 8:49 pm   Post subject: (No subject)

you should really specify your problems Confused what do you mean a part of it disappears? If so, then you're drawing over it for w/e reason Thinking
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
thoughtful




PostPosted: Thu Nov 20, 2003 12:20 am   Post subject: (No subject)

Well i found something in my old programs and i modified it to make a procedure which will make the arrow move. I jus did this to show u how all this works don;t pass this on as your program, let your teacher know if u use this procedure to draw ur arrow, and put my name + www.compsci.ca in the credits.

code:


View.Set ("offscreenonly")
View.Set ("Title:Thoughtful's arrow mover")
procedure drawmovearrow (x1_temp : int, y1_temp : int, x2_temp : int, y2_temp : int, lengthd : int, NumOfTimeForAnimation : int, colord : int)
    var slope, ang, ang1 : real

    var x1, x2, y1, y2, xspd, yspd : real
    x1 := x1_temp
    x2 := x2_temp
    y1 := y1_temp
    y2 := y2_temp
    const arrowwide := 40
    if (x2 = x1) then
        x2 += 0.001
    end if
    if not (x2 = x1) then
        slope := (y2 - y1) / (x2 - x1)
    end if
    if not (x2 = x1) then
        if slope >= 0 then
            ang := arctand (abs (slope))
        end if

    end if
    if not (x2 = x1) then
        if slope <= 0 then
            ang := 90 - (arctand (abs (slope)))
        end if
    end if


    if (x2 = x1) and y2 - y1 > 0 then
        ang := 90
    elsif (x2 = x1) and y2 - y1 < 0 then
        ang := 270
    end if
    if y2 - y1 > 0 and x2 - x1 < 0 then
        ang := ang + 90
    end if
    if y2 - y1 = 0 and x2 - x1 < 0 then
        ang := ang + 180
    end if

    if y2 - y1 < 0 and x2 - x1 < 0 then
        ang := ang + 180
    end if
    if y2 - y1 < 0 and x2 - x1 > 0 then
        ang := ang + 270
    end if

    ang1 := 90 - ang
    if slope = 0 and x2 - x1 < 0 then
        ang1 := -90
    end if
    if slope = 0 and x2 - x1 > 0 then
        ang1 := -270
    end if
    ang1 += 180

    xspd := (x2 - x1) / NumOfTimeForAnimation
    yspd := (y2 - y1) / NumOfTimeForAnimation


    for i : 1 .. NumOfTimeForAnimation
        drawline (round (x1), round (y1), round (x1 + lengthd * sind (ang1)), round (y1 + lengthd * cosd (ang1)), colord)
        drawline (round (x1), round (y1), round (x1 + lengthd div 3 * sind (ang1 - arrowwide)), round (y1 + lengthd div 3 * cosd (ang1 - arrowwide)), colord)
        drawline (round (x1), round (y1), round (x1 + lengthd div 3 * sind (ang1 + arrowwide)), round (y1 + lengthd div 3 * cosd (ang1 + arrowwide)), colord)
        x1 += xspd
        y1 += yspd
        delay (50)
        View.Update
        cls

    end for
end drawmovearrow

drawmovearrow (100, 100, 100, 350, 30, 50, red)
% syntax: drawmovearrow (arrow start x, arrow start y, arrow finish x, arrow finish y, arrow length, number of times the loop will execute in the procedure(greater=slow speed), red)
Tendulkar




PostPosted: Tue Nov 25, 2003 11:07 pm   Post subject: Re: how do i make the arrow move?

% HERE IS YOUR CODE:
setscreen ("offscreenonly")
for i : 1 .. maxx
drawline (i, 20, i + 30, 20, brightgreen)
drawline (i + 30, 20, i + 25, 23, brightgreen)
drawline (i + 30, 20, i + 25, 17, brightgreen)
View.Update
drawfillbox (0, 0, maxx, maxy, black)
end for
Tendulkar




PostPosted: Thu Dec 04, 2003 10:23 pm   Post subject: Re: how do i make the arrow move?

Here is what you need for your program! Laughing


Arrow.t
 Description:

Download
 Filename:  Arrow.t
 Filesize:  10.66 KB
 Downloaded:  91 Time(s)

Tendulkar




PostPosted: Thu Dec 04, 2003 10:25 pm   Post subject: Re: how do i make the arrow move?

Here is what you need for your program! Laughing


Arrow.t
 Description:

Download
 Filename:  Arrow.t
 Filesize:  10.66 KB
 Downloaded:  135 Time(s)

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: