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

Username:   Password: 
 RegisterRegister   
 help to draw a swing
Index -> Programming, Turing -> Turing Help
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Tony




PostPosted: Tue Nov 11, 2003 7:15 pm   Post subject: (No subject)

well you were right about removing that over var pull line. It is not needed there.

Anyways, the pulling back part is buggy. Confused The simpliest way ofcourse is to replace top part with
code:

var pull:int
put "how many degrees would you like to pull your swing back?"
get pull


Laughing Otherwise I donno... you can use getch I suppose Confused
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
DAV1209




PostPosted: Wed Nov 12, 2003 8:39 pm   Post subject: (No subject)

but my assignment requires me when ever i hit the space bar button, the ball go up 1 degree and when ever i hit another button. The ball starting falling down at that time
it's not requires me to input the degree
Chimaera




PostPosted: Wed Nov 12, 2003 9:04 pm   Post subject: (No subject)

So you just use getch statements and if statements. Very easy

code:

getch key
if key = "a" then
angle := angle +1 %this isn't really the actual code to make it go up and down but it simulates what's actually supposed to be there
elsif key = "s" then
angle:= angle -1 %ditto
end if


Btw you might want to specify whether or not if you hit a button and it continuously keeps falling down or going up until a certain point or another button is it or whether it just moves a small bit then stops.
Tony




PostPosted: Wed Nov 12, 2003 11:54 pm   Post subject: (No subject)

Chimaera has the right idea.

code:

var angle:int := 0
var c:string(1)

loop
getch(c)
if c=" " then
angle +=1
else
exit
end if
end loop

put angle
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
DAV1209




PostPosted: Thu Nov 13, 2003 1:31 am   Post subject: (No subject)

i did put it together and it work fine
but when i press space i didn't see the ball go up
how to draw the ball right at time we start the program and when ever we hit the space bar button, the ball go up 1 degree and we still can see it go up
the file i attached with showed how the out put of the program

code:


var angle:int := 0
var c:string(1)

loop
getch(c)
if c=" " then
angle +=1
else
exit
end if
end loop

put angle


loop
exit when angle<=0
for decreasing i:angle .. -angle+5
Draw.FillOval(200-round(sind(i)*100),200-round(cosd(i)*100),5,5,red)

Draw.Line(200,200,200-round(sind(i)*100),200-round(cosd(i)*100),black)
delay(20)
cls
end for

for i:-angle+5 .. angle -10
Draw.FillOval(200-round(sind(i)*100),200-round(cosd(i)*100),5,5,red)

Draw.Line(200,200,200-round(sind(i)*100),200-round(cosd(i)*100),black)
delay(20)
cls
end for

angle := angle - 5

end loop
DAV1209




PostPosted: Thu Nov 13, 2003 6:30 am   Post subject: (No subject)

lol...
thanks you guy all for helping me on the assignment

i've just finished my work
here is the finished code
code:


var angle : int := 0
var space : string (1)

loop
drawline (200, 200, 100, 100, black)
drawline (200, 200, 300, 100, black)
Draw.FillOval (200 - round (sind (angle) * 100), 200 - round (cosd (angle) * 100), 5, 5, red)
Draw.Line (200, 200, 200 - round (sind (angle) * 100), 200 - round (cosd (angle) * 100), black)
put "Press Space Bar to push the swing, press another key to release the swing",
    getch (space)
    if space = " " then
        angle += 1
        cls
    else
        exit
    end if
end loop
put angle


loop
    exit when angle <= 0
    for decreasing i : angle .. -angle + 5
        drawline (200, 200, 100, 100, black)
        drawline (200, 200, 300, 100, black)

        Draw.FillOval (200 - round (sind (i) * 100), 200 - round (cosd (i) * 100), 5, 5, red)
        Draw.Line (200, 200, 200 - round (sind (i) * 100), 200 - round (cosd (i) * 100), black)
        delay (30)
        cls
    end for

    for i : -angle + 5 .. angle - 10
        drawline (200, 200, 100, 100, black)
        drawline (200, 200, 300, 100, black)

        Draw.FillOval (200 - round (sind (i) * 100), 200 - round (cosd (i) * 100), 5, 5, red)
        Draw.Line (200, 200, 200 - round (sind (i) * 100), 200 - round (cosd (i) * 100), black)
        delay (30)
        cls
    end for

    angle := angle - 5

end loop
DAV1209




PostPosted: Thu Nov 13, 2003 6:58 am   Post subject: (No subject)

i don't know what happen but the program just work but i don't know why i run the program again it cause a new error
on the getch statement
Crying or Very sad Crying or Very sad
DAV1209




PostPosted: Thu Nov 13, 2003 7:13 am   Post subject: (No subject)

i found the problem on my code
i have to take the
Quote:

put "Press Space Bar to push the swing, press another key to release the swing",

statement out
but i don't know why i can't put that put statement there
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Nov 13, 2003 10:10 am   Post subject: (No subject)

that comma (,) must be causing problems with your input.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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 2 of 2  [ 24 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: