Computer Science Canada

Need help "mixing" two of my turing codes.

Author:  atal [ Sat Jun 11, 2011 11:37 am ]
Post subject:  Need help "mixing" two of my turing codes.

Hello,

Im new to all this programming and i have a question. For school we had to make a rocket shooting up and so i did

code:

setscreen ("graphics")
for p: 1..400
drawbox (200,p+10,250,p+100,1)
drawline (200,p+100,220,p+150,1)
drawline (250,p+100,220,p+150,1)
delay (5)
cls ()
end for


If you run it you can see that it is not very good infact no good. So i make a rocket and loaded it into turing and it show up just fine

code:

var mypic :int := Pic.FileNew ("Rocket.bmp")
Pic.Draw (mypic, maxx div 2, maxy div 2, 0)
delay (2000)
cls
Pic.Free (mypic)


How can i "mix" the two codes so that the rocket i drew flys like that boring one that i made?
Thank You in advance!


-atal

Author:  ProgrammingFun [ Sat Jun 11, 2011 11:48 am ]
Post subject:  RE:Need help "mixing" two of my turing codes.

You would create a for loop again in which you increment the y axis counter so that the pic redraws and looks as if it is rising:
Turing:

for p:1..400
var mypic :int := Pic.FileNew ("Rocket.bmp")
Pic.Draw (mypic, 0, p, 0)
delay (5)
cls
Pic.Free (mypic)
end for


This solution however, would flicker so you would need to use offscreenonly, which I'll let you figure out on your own.

Author:  Tony [ Sat Jun 11, 2011 1:43 pm ]
Post subject:  RE:Need help "mixing" two of my turing codes.

since the picture doesn't change, the Pic.FileNew and Pic.Free should be outside of the loop.

Author:  ProgrammingFun [ Sat Jun 11, 2011 1:56 pm ]
Post subject:  Re: RE:Need help "mixing" two of my turing codes.

Tony @ Sat Jun 11, 2011 1:43 pm wrote:
since the picture doesn't change, the Pic.FileNew and Pic.Free should be outside of the loop.

Oh yes...I forgot that. My bad Embarassed

Author:  atal [ Sat Jun 11, 2011 7:59 pm ]
Post subject:  Re: RE:Need help "mixing" two of my turing codes.

ProgrammingFun @ Sat Jun 11, 2011 1:56 pm wrote:
Tony @ Sat Jun 11, 2011 1:43 pm wrote:
since the picture doesn't change, the Pic.FileNew and Pic.Free should be outside of the loop.

Oh yes...I forgot that. My bad Embarassed


What do u mean that PicFileNew adn Pic.Free shou be outside the loop. When i do that then it does not work but when i do it like how u said at first it works.

Author:  Raknarg [ Sat Jun 11, 2011 8:02 pm ]
Post subject:  RE:Need help "mixing" two of my turing codes.

Pic.FileNew should be before the loop, Pic.Free should be after.


: