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

Username:   Password: 
 RegisterRegister   
 Is there any way to allow more then one procedure be executed at once
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Spitfire179




PostPosted: Tue Dec 09, 2008 12:57 pm   Post subject: Is there any way to allow more then one procedure be executed at once

Ok so here is my code
Turing:

var x, y, button, left, right, middle, score : int
var smallcharge, mediumcharge, bigcharge, FontID : int
var Target, TargetX, TargetY, Color : int
Mouse.ButtonChoose ("multibutton")
setscreen ("graphics:500,500,nobuttonbar")
FontID := Font.New ("Arial:20")
Target := Pic.FileNew ("RandTarget.bmp")
var smallx : int := 0
var mediumx : int := 0
var bigx : int := 0
score := 0
Color := red
smallcharge := 10
mediumcharge := 5
bigcharge := 1
TargetX := Rand.Int (1, 400)
TargetY := Rand.Int (1, 400)
Draw.FillBox (0, 0, maxx, maxy, black)
drawfillbox (0, 445, 100, 425, white)
drawfillbox (0, 450, 100, 470, white)
drawfillbox (0, 475, 100, 495, white)
Draw.ThickLine (0, 400, 500, 400, 5, white)
Font.Draw ("Score:", 300, 450, FontID, 0)
% Font.Draw ("Alot", 380, 450, FontID, 0)
locate (3, 49)
color (white)
colorback (black)
put score ..
%---------------------TargetPlacement------------------------
proc Targetplaced
    Pic.Draw (Target, Rand.Int (1, 400), Rand.Int (1, 400), 0)
    delay (500)
    Draw.FillBox (0, 0, maxx, maxy, black)
    drawfillbox (0, 445, 100, 425, white)
    drawfillbox (0, 450, 100, 470, white)
    drawfillbox (0, 475, 100, 495, white)
    Draw.ThickLine (0, 400, 500, 400, 5, white)
    Font.Draw ("Score:", 300, 450, FontID, 0)
    locate (3, 49)
    color (white)
    colorback (black)
    put score ..
end Targetplaced
Targetplaced

%--------------------Recharging Big Shot-----------------------
proc rechargebig
    loop
        colourback (0)
        drawbox (bigx, 492, bigx + 0, 478, brightblue)
        View.Update
        delay (100)
        bigx := bigx + bigcharge
        exit when bigx = 100
    end loop
    bigx := 0
    Draw.FillBox (0, 0, maxx, maxy, black)
    drawfillbox (0, 445, 100, 425, white)
    drawfillbox (0, 450, 100, 470, white)
    drawfillbox (0, 475, 100, 495, white)
    Draw.ThickLine (0, 400, 500, 400, 5, white)
    Font.Draw ("Score:", 300, 450, FontID, 0)
    locate (3, 49)
    color (white)
    colorback (black)
    put score ..
end rechargebig

%-----------------------Recharging Medium Shot----------------------------
proc rechargemedium
    loop
        colourback (0)
        drawfillbox (mediumx, 467, mediumx + 0, 453, brightblue)
        View.Update
        delay (100)
        mediumx := mediumx + mediumcharge
        exit when mediumx = 100
    end loop
    mediumx := 0
    Draw.FillBox (0, 0, maxx, maxy, black)
    drawfillbox (0, 445, 100, 425, white)
    drawfillbox (0, 450, 100, 470, white)
    drawfillbox (0, 475, 100, 495, white)
    Draw.ThickLine (0, 400, 500, 400, 5, white)
    Font.Draw ("Score:", 300, 450, FontID, 0)
    locate (3, 49)
    color (white)
    colorback (black)
    put score ..
end rechargemedium

%-----------------Recharging Small Shot---------------------
proc rechargesmall
    loop
        colourback (0)
        drawfillbox (smallx, 442, smallx + 0, 428, brightblue)
        View.Update
        delay (100)
        smallx := smallx + smallcharge
        exit when smallx = 100
    end loop
    smallx := 0
    Draw.FillBox (0, 0, maxx, maxy, black)
    drawfillbox (0, 445, 100, 425, white)
    drawfillbox (0, 450, 100, 470, white)
    drawfillbox (0, 475, 100, 495, white)
    Draw.ThickLine (0, 400, 500, 400, 5, white)
    Font.Draw ("Score:", 300, 450, FontID, 0)
    locate (3, 49)
    color (white)
    colorback (black)
    put score ..
end rechargesmall

loop
    loop
        Mouse.Where (x, y, button)
        Targetplaced
        left := button mod 10
        middle := (button - left) mod 100
        right := button - middle - left
        if right = 100 then
            exit when y > 393
            if View.WhatDotColor (x, y) = white then
                Color := yellow
            elsif View.WhatDotColor (x, y) = black then
                Color := brightred
            elsif View.WhatDotColor (x, y) = brightred then
                score := score + 1
            elsif View.WhatDotColor (x, y) = yellow then
                score := score - 1
            end if
            drawfilloval (x, y, 25, 25, Color)
            rechargebig
        end if
        if middle = 10 then
            exit when y > 393
            if View.WhatDotColor (x, y) = white then
                Color := yellow
            elsif View.WhatDotColor (x, y) = black then
                Color := brightred
            elsif View.WhatDotColor (x, y) = brightred then
                score := score + 1
            elsif View.WhatDotColor (x, y) = yellow then
                score := score - 1
            end if
            drawfilloval (x, y, 10, 10, Color)
            rechargemedium
        end if
        if left = 1 then
            exit when y > 393
            if View.WhatDotColor (x, y) = white then
                Color := yellow
            elsif View.WhatDotColor (x, y) = black then
                Color := brightred
            elsif View.WhatDotColor (x, y) = brightred then
                score := score + 1
            elsif View.WhatDotColor (x, y) = yellow then
                score := score - 1
            end if
            drawfilloval (x, y, 3, 3, Color)
            rechargesmall
        end if
    end loop
end loop

I am trying to have the Targetplacement run while allowing the recharge shots to be executed at will any way to make that happen???


Mod Edit: There is no need for all caps and such a long subject.
Additional Mod Edit: Remember syntax tags! Thanks Smile
code:
[syntax="Turing"]Code Here[/syntax]



RandTarget.bmp
 Description:
Need this picture to have as target
 Filesize:  20.97 KB
 Viewed:  32 Time(s)

RandTarget.bmp


Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue Dec 09, 2008 1:08 pm   Post subject: RE:MY FIRST POST SOO YEH NOT ALL THAT GOOD I THINK----Is there any way to allow more then one procedure be executed at o

the proper way to set up your games is using a single main loop.

Turing:

var current_frame : int := 0
loop
   current_frame += 1
   % draw current_frame
   View.Update
   % delay since last -- framerate control
   cls
end loop


Typically you don't need loops (especially not delays or View.Update's) in procedures. You can use that single main loop to increment the internals of a procedure. A counter variable could be used for reference.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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  [ 2 Posts ]
Jump to:   


Style:  
Search: