Posted: 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
Posted: 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
Posted: 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
Posted: 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
Posted: 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)