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

Username:   Password: 
 RegisterRegister   
 Why You Should Avoid Processes
Index -> Programming, Turing -> Turing Tutorials
Goto page Previous  1, 2, 3, 4, 5, 6, 7
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Insectoid




PostPosted: Fri Jan 28, 2011 5:57 pm   Post subject: RE:Why You Should Avoid Processes

Did you even read the thread? Turing's processes are purest evil, at least because it prevents students from learning consecutive programming.
Sponsor
Sponsor
Sponsor
sponsor
goroyoshi




PostPosted: Wed May 11, 2011 6:45 pm   Post subject: (No subject)

jamonathin @ Tue Feb 22, 2005 8:13 pm wrote:
You have to give the bullet's their own variables. 'x' and 'y' are already used by the "shooter" and so by adding to the y-value, you're changing where the shooter is. This is what i came up with. .
code:

View.Set ("offscreenonly")

var chars : array char of boolean
var x, y, bullety, bulletx : int := 100
var shot : int := 0
forward proc movement

proc shoot
    loop
        shot := 1
        bullety += 1
        exit when bullety + 20 > maxy
        movement
    end loop
    shot := 0
end shoot

body proc movement
    Input.KeyDown (chars)
    if chars (KEY_UP_ARROW) and y + 64 < maxy then
        y := y + 1
    elsif chars (KEY_DOWN_ARROW) and y > 0 then
        y := y - 1
    elsif chars (KEY_LEFT_ARROW) and x > 0 then
        x := x - 1
    elsif chars (KEY_RIGHT_ARROW) and x + 64 < maxx then
        x := x + 1
    end if
    if chars (KEY_CTRL) and shot = 0 then
        bullety := y
        bulletx := x
        shoot
    end if
    cls
    if shot = 1 then
        drawoval (bulletx + 35, bullety - 1, 10, 10, 0)
        drawoval (bulletx + 35, bullety, 10, 10, 7)
        drawoval (bulletx - 35, bullety - 1, 10, 10, 0)
        drawoval (bulletx - 35, bullety, 10, 10, 7)
    end if
    drawfilloval (x, y, 20, 20, 7)
    View.Update
end movement

loop
    movement
end loop

The shooter moves a little slower while the bullets are being fired however. If you want, you can have a variable represent the displacement of the shoot (y + 1 to y + dif), and when the ball is being fired, dif will equal 2, but outside the loop, dif will equal 1, your choice. Confused

I see a problem with this code, if you want to put a delay in it then all gets slowed (prove me wrong, I tried to to that) what if the bullets are supposed to be faster than the person shooting them
Tony




PostPosted: Wed May 11, 2011 6:57 pm   Post subject: (No subject)

goroyoshi @ Wed May 11, 2011 6:45 pm wrote:
what if the bullets are supposed to be faster than the person shooting them

Then you set a faster per-frame velocity.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
goroyoshi




PostPosted: Sun Jun 19, 2011 9:24 am   Post subject: RE:Why You Should Avoid Processes

my friend's ISP for grade 9 (actually a grade 10 course) was a jigsaw puzzle, he told me that he had to use processes
Insectoid




PostPosted: Sun Jun 19, 2011 10:43 am   Post subject: RE:Why You Should Avoid Processes

He did it wrong then.
Raknarg




PostPosted: Thu Jun 23, 2011 10:27 am   Post subject: RE:Why You Should Avoid Processes

This has probably been said already, but i don't want to read....

Procedures can do the literally the EXACT SAME THING as processes, but without all the unpredictability.
andrew.




PostPosted: Thu Jun 23, 2011 6:49 pm   Post subject: RE:Why You Should Avoid Processes

Not literally the exact same thing. Processes are supposed to work concurrently, while procedures are supposed to be...well..procedural. The implementation in Turing isn't that good though so processes are horrible and unpredictable.
Tony




PostPosted: Thu Jun 23, 2011 7:35 pm   Post subject: RE:Why You Should Avoid Processes

Of course you can't possibly get true concurrency on a single CPU; only switch between threads. In Turing, for the most part, you are better off writing your own "thread switching". It guarantees better scheduling, and much more importantly -- synchronization of cls and View.Update.

The only problem are blocking calls; but those could be gotten around by using non-blocking I/O methods.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
Gadd




PostPosted: Thu Mar 15, 2012 11:33 am   Post subject: RE:Why You Should Avoid Processes

Although... you can tell a procedure when to be used. So why not use a procedure instead?
code:

procedure p_input
%The input of the user
end p_input

procedure p_process
%The processing of the program
end p_process

procedure p_output
%All of the output in the program
%Just an example
end p_output

p_input
p_process
p_output
%where all of these are displayed in the order %you tell them to be
Display posts from previous:   
   Index -> Programming, Turing -> Turing Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 7 of 7  [ 99 Posts ]
Goto page Previous  1, 2, 3, 4, 5, 6, 7
Jump to:   


Style:  
Search: