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

Username:   Password: 
 RegisterRegister   
 (help) forking 3 procs simutaniously
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
BRENDON, CREIGHTON




PostPosted: Sat May 02, 2009 6:10 am   Post subject: (help) forking 3 procs simutaniously

i have my house program, and i have to have all the code going at the same time, any sugestions?

Turing:
var pop,cap1, xo, m, yo,cap, col : int := 0

proc UFO
      drawfillbox  (500 + xo, 260 + yo, 505 +xo, 50 +yo, cap)
      drawfillbox  (500 + xo, 50 + yo, 505 +xo, 0 +yo, cap1)
drawfilloval (500 + xo, 270 + yo, 10, 10, col)
 
   drawfilloval (500 + xo, 260 + yo, 20, 10, pop)
   
end UFO

process UFO1
for j : 1 .. 600
    pop := 15
    col := 14
    cap := 14
    cap1 :=14
    UFO
    delay (10)
    pop := 16
    col := 16
    cap :=16
    cap1 :=0
    UFO
    xo := xo + 1

end for
end UFO1

var io, xop,  yop : int := 0

proc Person
    drawoval (496 + xop, 30 + yop, 6, 4, io)
    drawline (495 + xop, 25 + yop, 495 + xop, 18 + yop, io)
    drawline (495 + xop, 23 + yop, 506 + xop, 22 + yop, io)
    drawline (495 + xop, 23 + yop, 486 + xop, 20 + yop, io)
    drawline (495 + xop, 18 + yop, 501 + xop, 10 + yop, io)
    drawline (495 + xop, 18 + yop, 486 + xop, 10 + yop, io)
end Person

process Person1
    drawoval (496 + xop, 30 + yop, 6, 4, io)
    drawline (495 + xop, 25 + yop, 495 + xop, 18 + yop, io)
    drawline (495 + xop, 23 + yop, 506 + xop, 22 + yop, io)
    drawline (495 + xop, 23 + yop, 486 + xop, 20 + yop, io)
    drawline (495 + xop, 18 + yop, 501 + xop, 10 + yop, io)
    drawline (495 + xop, 18 + yop, 486 + xop, 10 + yop, io)
    delay (30)
end Person1

for j : 1 .. 600
    io := 16
    Person
    delay (10)
    io := 0
    Person
    xop := xop + 1
   
end for

       

var clr, c ,b, e: int := 0

proc dustball
for c : 1..100
drawfilloval(105 + (c + 2), 370 +(c + 2), 10, 10, 15)
delay(20)
drawfilloval(105 + (c + 2), 370 +(c + 2), 10, 10, 7)
end for
end dustball

process dustball1
for c : 1..100
drawfilloval(105 + (c + 2), 370 +(c + 2), 10, 10, 15)
delay(20)
drawfilloval(105 + (c + 2), 370 +(c + 2), 10, 10, 7)
end for
end dustball1

loop dustball
fork UFO1
fork Person1
end loop



Mod Edit: Remember to use syntax tags! Thanks Smile
code:
[syntax="turing"]Code Here[/syntax]
Sponsor
Sponsor
Sponsor
sponsor
Euphoracle




PostPosted: Sat May 02, 2009 7:21 am   Post subject: RE:(help) forking 3 procs simutaniously

Processes are not the way to do this; have a procedure to draw each of your object and in the same loop, increment their x or y values to move as you wish as you call the draw procedures one after one another (in the order you want them to draw).

eg,

Turing:
%draw procs
proc drawObject1 (x, y : int)
    drawfillbox (x, y, x + 50, y + 50, blue)
end drawObject1

proc drawObject2 (x, y : int)
    drawfillstar (x, y, x + 50, y + 50, yellow)
end drawObject2

proc drawObject3 (x, y : int)
    drawfillmapleleaf (x, y, x + 50, y + 50, red)
end drawObject3

%use a buffer so it doesn't flicker like mad
setscreen ("offscreenonly")
var x, y := 0
loop
    %wipe screen
    drawfillbox (0, 0, maxx, maxy, black)

    %do something with x and y, yours will be different
    x += 1
    y += 1
    if (x > maxx) then
        x := 0
    end if
    if (y > maxy) then
        y := 0
    end if

    %draw them in sequence
    drawObject1 (x, y)
    drawObject2 (x - x div 2, y + y div 4)
    drawObject3 (x + x div 4, y - y div 2)

    %view.update
    View.Update
end loop
BRENDON, CREIGHTON




PostPosted: Sat May 02, 2009 10:37 am   Post subject: Re: (help) forking 3 procs simutaniously

thats amazing thank you very much !
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  [ 3 Posts ]
Jump to:   


Style:  
Search: