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

Username:   Password: 
 RegisterRegister   
 Forking Help!!!
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
mike200015




PostPosted: Fri Feb 04, 2005 8:57 pm   Post subject: Forking Help!!!

I made a program that draws a house and theres a sun that moves, and a garage that opens. I want to make the garage open while the sun is moving up, but i dont know how to do that. Also the black driveway flickers when the garage is going up??.. If anyone can help id appreciate it. Heres the code:
code:

var y2, x2, y4, x4 : int

%DayTime Procedure
procedure house2

    %sky
    colourback (brightblue)
    cls
    %grass
    Draw.ThickLine (0, 0, maxx, 0, 45, green)
    %grass hill
    drawfilloval (maxx div 2, 0, maxx div 2, 40, green)
    %body of house
    Draw.ThickLine (234, 39, 234, 155, 2, black)
    Draw.ThickLine (405, 39, 405, 155, 2, black)
    Draw.ThickLine (233, 155, 405, 155, 2, black)
    drawline (233, 38, 405, 38, black)
    drawfill (311, 100, red, black)
    %grass hill
    drawfilloval (maxx div 2, 0, maxx div 2, 40, green)
    %door
    drawfillbox (300, 41, 338, 94, black)
    %doorknob
    drawfilloval (309, 64, 4, 4, grey)
    %roof
    Draw.ThickLine (234, 154, 319, 240, 3, black)
    Draw.ThickLine (405, 155, 319, 240, 3, black)
    drawfill (311, 184, 138, black)
    %chimney
    Draw.ThickLine (352, 208, 352, 240, 2, black)
    Draw.ThickLine (372, 189, 372, 240, 2, black)
    Draw.ThickLine (351, 240, 372, 240, 2, black)
    drawfill (363, 223, 116, black)
    %window
    drawfillbox (248, 96, 292, 132, white)
    drawfillbox (250, 98, 268, 112, yellow)
    drawfillbox (250, 115, 268, 130, yellow)
    drawfillbox (271, 98, 290, 112, yellow)
    drawfillbox (271, 115, 290, 130, yellow)
    %garage body
    drawfillbox (132, 33, 232, 132, black)
    drawfillbox (134, 33, 232, 130, 138)
    %garage door
    drawfillbox (148, 33, 218, 102, black)
    drawfillbox (150, 33, 216, 100, grey)
    %garage door lines
    y4 := 33
    for i : 1 .. 10
        Draw.ThickLine (148, y4, 218, y4, 1, black)
        y4 += 7
    end for
    %ground
    Draw.ThickLine (0, 0, maxx, 0, 45, green)
    drawfilloval (maxx div 2, 0, maxx div 2, 40, green)
    %copy of window
    var window : array 1 .. sizepic (248, 96, 293, 132) of int
    takepic (248, 96, 293, 132, window)
    drawpic (346, 96, window, 0)
    %walkway
    drawline (300, 40, 259, 0, black)
    drawline (339, 40, 380, 0, black)
    drawfill (358, 18, grey, black)
    drawline (271, 11, 369, 11, black)
    drawline (283, 22, 357, 22, black)
    drawline (293, 33, 346, 33, black)
    %driveway
    drawline (149, 34, 108, 0, black)
    drawline (218, 39, 259, 0, black)
    drawline (149, 34, 218, 39, black)
    drawfill (184, 14, black, black)

end house2

%DayTime With Garage Door Open Procedure
procedure house3

    %sky
    colourback (brightblue)
    cls
    %grass
    Draw.ThickLine (0, 0, maxx, 0, 45, green)
    %grass hill
    drawfilloval (maxx div 2, 0, maxx div 2, 40, green)
    %body of house
    Draw.ThickLine (234, 39, 234, 155, 2, black)
    Draw.ThickLine (405, 39, 405, 155, 2, black)
    Draw.ThickLine (233, 155, 405, 155, 2, black)
    drawline (233, 38, 405, 38, black)
    drawfill (311, 100, red, black)
    %grass hill
    drawfilloval (maxx div 2, 0, maxx div 2, 40, green)
    %door
    drawfillbox (300, 41, 338, 94, black)
    %doorknob
    drawfilloval (309, 64, 4, 4, grey)
    %roof
    Draw.ThickLine (234, 154, 319, 240, 3, black)
    Draw.ThickLine (405, 155, 319, 240, 3, black)
    drawfill (311, 184, 138, black)
    %chimney
    Draw.ThickLine (352, 208, 352, 240, 2, black)
    Draw.ThickLine (372, 189, 372, 240, 2, black)
    Draw.ThickLine (351, 240, 372, 240, 2, black)
    drawfill (363, 223, 116, black)
    %window
    drawfillbox (248, 96, 292, 132, white)
    drawfillbox (250, 98, 268, 112, yellow)
    drawfillbox (250, 115, 268, 130, yellow)
    drawfillbox (271, 98, 290, 112, yellow)
    drawfillbox (271, 115, 290, 130, yellow)
    %garage body
    drawfillbox (132, 33, 232, 132, black)
    drawfillbox (134, 33, 232, 130, 138)
    %garage door
    drawfillbox (148, 33, 218, 102, black)
    %headlights
    drawfilloval (170, 52, 6, 6, yellow)
    drawfilloval (197, 52, 6, 6, yellow)
    %copy of window
    var window : array 1 .. sizepic (248, 96, 293, 132) of int
    takepic (248, 96, 293, 132, window)
    drawpic (346, 96, window, 0)
    %walkway
    drawline (300, 40, 259, 0, black)
    drawline (339, 40, 380, 0, black)
    drawfill (358, 18, grey, black)
    drawline (271, 11, 369, 11, black)
    drawline (283, 22, 357, 22, black)
    drawline (293, 33, 346, 33, black)
    %driveway
    drawline (149, 34, 108, 0, black)
    drawline (218, 39, 259, 0, black)
    drawline (149, 34, 218, 39, black)
    drawfill (184, 14, black, black)
end house3

%Garage Opening
procedure garage

    y4 := 33
    for i : 1 .. 11

        drawfillbox (150, 33, 216, y4, black)
        %ground
        Draw.ThickLine (0, 0, maxx, 0, 45, green)
        drawfilloval (maxx div 2, 0, maxx div 2, 40, green)
        %walkway
        drawline (300, 40, 259, 0, black)
        drawline (339, 40, 380, 0, black)
        drawfill (358, 18, grey, black)
        drawline (271, 11, 369, 11, black)
        drawline (283, 22, 357, 22, black)
        drawline (293, 33, 346, 33, black)
        %driveway
        drawline (149, 34, 108, 0, black)
        drawline (218, 39, 259, 0, black)
        drawline (149, 34, 218, 39, black)
        drawfill (184, 14, black, black)
        y4 += 7
        delay (300)
    end for
    %headlights
    drawfilloval (170, 52, 6, 6, yellow)
    drawfilloval (197, 52, 6, 6, yellow)
    delay (600)
end garage

x2 := 0
y2 := 40
for i : 1 .. 36
    setscreen ("offscreenonly")
    View.Update
    house2
    %fork smoke
    %sun
    drawfilloval (x2, y2, 20, 20, yellow)
    x2 += 8
    y2 += 10
    delay (300)
end for
setscreen ("nooffscreenonly")
garage
for i : 1 .. 41
    setscreen ("offscreenonly")
    View.Update
    house3
    %fork smoke
    %sun
    drawfilloval (x2, y2, 20, 20, yellow)
    %ground
    Draw.ThickLine (0, 0, maxx, 0, 45, green)
    drawfilloval (maxx div 2, 0, maxx div 2, 40, green)
    %walkway
    drawline (300, 40, 259, 0, black)
    drawline (339, 40, 380, 0, black)
    drawfill (358, 18, grey, black)
    drawline (271, 11, 369, 11, black)
    drawline (283, 22, 357, 22, black)
    drawline (293, 33, 346, 33, black)
    %driveway
    drawline (149, 34, 108, 0, black)
    drawline (218, 39, 259, 0, black)
    drawline (149, 34, 218, 39, black)
    drawfill (184, 14, black, black)
    x2 += 8
    y2 -= 10
    delay (300)
end for

Sponsor
Sponsor
Sponsor
sponsor
person




PostPosted: Fri Feb 04, 2005 9:09 pm   Post subject: (No subject)

cant u make the garage door moving up a process and then forking it?

example (oval moving up and square moving up at the same time):

process oval
for x:1..500
drawfilloval (0,0,20,20,1)
delay (20)
end for
end oval
fork oval
for x: 1..500
drawfillbox (40,40,80,80,1)
delay (20)
end for
cycro1234




PostPosted: Fri Feb 04, 2005 9:11 pm   Post subject: (No subject)

Yeah, but processes aren't the greatest. Because they will run forever, and never stop. So u'll have ur animation run non stop. Like the garage door will constantly open.
person




PostPosted: Fri Feb 04, 2005 9:24 pm   Post subject: (No subject)

try this cycro...tell me if it keeps on running

code:

process oval
    for x : 1 .. 50
        drawfilloval (0, 0 + x, 20, 20, 1)
        delay (20)
    end for
end oval
fork oval
for x : 1 .. 50
    drawfillbox (40, 40 + x, 80, 80 + x, 1)
    delay (20)
end for
cycro1234




PostPosted: Fri Feb 04, 2005 9:29 pm   Post subject: (No subject)

I don't have Turing on this computer, I can't rite now. Send it as exe Smile
mike200015




PostPosted: Fri Feb 04, 2005 9:43 pm   Post subject: (No subject)

i tried forking it and having the garage as a process, but it doesnt work 2 well, because when u hav a process it doesnt go at the same time or in any order, it tries to , but it actually goes randomly, and it looks really bad
person




PostPosted: Fri Feb 04, 2005 9:56 pm   Post subject: (No subject)

define randomly....b/c a process runs when it is called by using fork
the starting point of a process is the exact moment it is called...so how is it random?
md




PostPosted: Fri Feb 04, 2005 10:34 pm   Post subject: (No subject)

The new process doesn't actually have to start running right away, and it doesn't run until completion... it's run in small parts. It's also easy to end a process, all you need is for it to return...

I don't have much experience with graphics in turing, but in other languages I ususally used a animation counter for each thing that was being animated; each frame you update all the counters, and draw the image for the new value.
Sponsor
Sponsor
Sponsor
sponsor
Carino




PostPosted: Sat Feb 05, 2005 6:59 am   Post subject: (No subject)

Yea, use a counter for the animatations and not a process. It will be much easier this way. Both the sun and garage will move together at the same speed or can be adjusted really easily.
Cervantes




PostPosted: Sat Feb 05, 2005 9:46 am   Post subject: (No subject)

mike200015 wrote:
i tried forking it and having the garage as a process, but it doesnt work 2 well, because when u hav a process it doesnt go at the same time or in any order, it tries to , but it actually goes randomly, and it looks really bad

A beacon of light! in these dark times when so many are falling prey to the process.
+10 bits

Person, if you insist on using processes, fine. But can you try to avoid bringing others to use processes?
mike200015




PostPosted: Sat Feb 05, 2005 11:09 am   Post subject: (No subject)

Carino wrote:
Yea, use a counter for the animatations and not a process. It will be much easier this way. Both the sun and garage will move together at the same speed or can be adjusted really easily.

What do you mean by that Carino?.. how would i do that instead of a process? Can u give me an example code of it plz
alvini




PostPosted: Fri Dec 16, 2005 4:33 pm   Post subject: Garage help

hey i have this
code:
var y:int
procedure sun
y:=35 
         
var y1 := 0
        var Start, End : int
        Start := 0
        End := maxx
        for x1 : Start .. End



            View.Set ("offscreenonly")
            y1 := (-1 * ((x1 - maxx div 2) ** 2)) div 800 + 370
            house
            delay (10)
            drawfilloval (x1, y1, 22, 22, yellow)

            drawfilloval (x1, y1, 22, 22, yellow)
            exit when x1 = maxx
            View.Update


end for
end sun

and i am trying to put this into it so that they both work at the same time.
code:


for y : 32 .. 102
    drawfillbox (148, y , 218, y, black)
    delay (20)
end for
    %headlights
    drawfilloval (170, 52, 6, 6, yellow)
    drawfilloval (197, 52, 6, 6, yellow)
    delay (600)


Geminias




PostPosted: Fri Dec 16, 2005 6:32 pm   Post subject: (No subject)

find a way to use them both in the same for loop...
alvini




PostPosted: Fri Dec 16, 2005 6:48 pm   Post subject: help

Geminias wrote:
find a way to use them both in the same for loop...


i tried every way that i know and it din't work
Cervantes




PostPosted: Fri Dec 16, 2005 7:27 pm   Post subject: Re: help

alvini wrote:

i tried every way that i know and it din't work

Then you didn't try hard enough. Wink

We're going to create pseudo-objects here. They won't be built off classes, but they'll have their own properties. We'll throw all their properties into a pot, and manually keep them apart, since that's the best you can do for now.

Let's just say the sun moves horizontally.
code:
var sun_vx := 1

The x velocity of the sun is 1 pixel per loop cycle.
To move the sun:
code:
sun_x += sun_vx

Now, we can create another pseduo-object. Let's make it a person. We'll give him an x position and an x velocity. (For simplicity, pretend we live in a one dimensional universe.)
code:
var person_x, person_vx : real
person_x := 100
person_vx := -2

Now we can move the person by
code:
person_x += person_vx

We can combine these two pseudo-objects into the same loop so that each of their properties work simultaneously, without the need for processes.
code:

loop
  sun_x += sun_vx
  person_x += person_vx
  %draw them
end loop



Lastly, read.
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 2  [ 20 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: