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

Username:   Password: 
 RegisterRegister   
 Help on Growing Ovals?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
JHybrid




PostPosted: Thu Apr 24, 2008 5:57 pm   Post subject: Help on Growing Ovals?

I need to make 3 ovals grow from its centre point at the same time. I tried

code:
loop
    var wFoilage1 : int := 100
    var wFoilage2 : int := 105
    var wFoilage3 : int := 85
    var hFoilage1 : int := 80
    var hFoilage2 : int := 70
    var hFoilage3 : int := 110
    drawfilloval (560, 300, wFoilage1, hFoilage1, 12)
    drawfilloval (600, 250, wFoilage2, hFoilage2, 12)
    drawfilloval (625, 280, wFoilage3, hFoilage3, 12)
    delay (10)
   
    wFoilage1 := wFoilage1+1
    wFoilage2 := wFoilage2+1
    wFoilage3 := wFoilage3+1
    hFoilage1 := hFoilage1+1
    hFoilage2 := hFoilage2+1
    hFoilage3 := hFoilage3+1
end loop


But I'm thinking that doesn't work. Can anyone help me on how i could make them grow outwards?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Apr 24, 2008 6:50 pm   Post subject: RE:Help on Growing Ovals?

Quote:

loop
var wFoilage1 : int := 100
...

what is the value of wFoilage1 after the loop has executed N times?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
JHybrid




PostPosted: Thu Apr 24, 2008 7:34 pm   Post subject: Re: Help on Growing Ovals?

ugh I think I've done something wrong. Now the code is

code:


loop

var wFoilage1,wFoilage2,wFoilage3,hFoilage1,hFoilage2,hFoilage3 : int := 1

drawfilloval (560, 300, wFoilage1, hFoilage1, 12)
drawfilloval (600, 250, wFoilage2, hFoilage2, 12)
drawfilloval (625, 280, wFoilage3, hFoilage3, 12)
delay (35)
wFoilage2 := wFoilage2 + 1
wFoilage3 := wFoilage3 + 1
hFoilage1 := wFoilage1 + 1
hFoilage2 := wFoilage2 + 1
hFoilage3 := wFoilage3 + 1
if
wFoilage1= 100 and
wFoilage2= 105 and
wFoilage3= 85 and
hFoilage1= 80 and
hFoilage2= 70 and
hFoilage3= 110
then exit
end if
end loop


What I want is 3 dots growing out to the dimensions I've specified. :[
I don't know if I've made it better or worse but this time nothing moves. Just the three dots that are supposed to grow... but don't. Am I missing something to make it move? I've quite new at this. My teacher doesn't know half a thing about Turing and he's making us learn it based on analyzing other codes. Sad
Tony




PostPosted: Thu Apr 24, 2008 8:16 pm   Post subject: RE:Help on Growing Ovals?

You still have to answer the same question.

Lets take it step by step

- the loop starts
- wFoilage1 is created with a starting value of 100
- some other things happen
- the loop comes to the end and starts again
- wFoilage1 is created...

What is the value of wFoilage1 when you drawfilloval for the second time?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
JHybrid




PostPosted: Thu Apr 24, 2008 8:32 pm   Post subject: Re: Help on Growing Ovals?

I was hoping the loop wouldn't repeat. :\

What I want to happen:
-loop begins
-wFoilage1 = 1 and starts growing along with the other variables
-wFoilage1 reaches 100
-exit
-loop ends and does not start again

I was thinking "if x = .....then exit" would stop it.

But still right now the ovals are not growing at all. ><

[Just realized I spelt "foliage" wrong the entire program..]
Tony




PostPosted: Thu Apr 24, 2008 9:00 pm   Post subject: Re: Help on Growing Ovals?

JHybrid @ Thu Apr 24, 2008 8:32 pm wrote:
I was hoping the loop wouldn't repeat. :\

Though that's the purpose of the loops - to repeat a block of code multiple times. If you don't want something repeated, put it outside of the loop.

do you want to declare variables multiple times?
do you want to draw ovals multiple times?
do you want to change values multiple times?
etc.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
TheGuardian001




PostPosted: Fri Apr 25, 2008 3:18 pm   Post subject: Re: Help on Growing Ovals?

The reason you're having the problem is the first line of the loop.

Every time the loop repeats, the variables are all reset to 1, then the ovals are drawn, so nothing happens.
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  [ 7 Posts ]
Jump to:   


Style:  
Search: