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

Username:   Password: 
 RegisterRegister   
 Help needed with variables and Procedures.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
chimerix




PostPosted: Wed Nov 25, 2009 9:49 am   Post subject: Help needed with variables and Procedures.

What is it you are trying to achieve?
Im trying to make a game similar to space invaders except the collision isnt working. I think its because one procedure doesn't have the variable values needed to do the actual collision.


Describe what you have tried to solve this problem
I'v wrote most of the program (ITS REALLY BAD AND MESSY- beginner programmer)


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


View.Set ("graphics:300;450,nobuttonbar")

var background : int := Pic.FileNew ("background2.bmp")
Pic.Draw (background, 0, 0, picCopy)

var y, x, z, movement : int


var keys : array char of boolean


const LEFT_ARROW : char := chr (203)
const RIGHT_ARROW : char := chr (205)
const KEY_SPACE : char := chr (32)

var blank : int := Pic.FileNew ("blank.bmp")
var tankpic : int := Pic.FileNew ("tank1.bmp")
var tankpic2 : int := Pic.FileNew ("tank2.bmp")
var explosion : int := Pic.FileNew ("explosion.bmp")



process attacker
    loop
        randint (x, 1, 300)
        var pictureNumber : int := Pic.FileNew ("tank2.bmp")
        for y : 1 .. 500
            Pic.Draw (pictureNumber, x, (y * -1) + 450, picCopy)
            delay (5)
        end for
    end loop
end attacker

process collision
    if movement >= x then
        Pic.Draw (blank, x, y, picCopy)
        delay (5)
        Pic.Draw (explosion, x, y, picCopy)
    end if
end collision

procedure defender
    movement := 0

    for y : 0 .. 10000000
        Pic.Draw (tankpic, movement, 10, picCopy)
        delay (50)
        Input.KeyDown (keys)
        if keys (LEFT_ARROW) then
            movement := movement - 10
            Pic.Draw (blank, movement + 15, 10, picCopy)
            if movement = -10 then
                movement := movement + 10
            end if
        end if
        if keys (RIGHT_ARROW) then
            movement := movement + 10
            Pic.Draw (blank, (movement - 15), 10, picCopy)
            if movement = 290 then
                movement := movement - 10
            end if
        end if
        if keys (KEY_SPACE) then
            for z : 1 .. 500
                drawfilloval (movement + 10, z, 3, 3, black)
                Pic.Draw (tankpic, movement, 10, picCopy)
                delay (1)
                drawfilloval (movement + 10, z, 3, 3, 4)
           
            end for
        end if
    end for

end defender

loop
    fork attacker
    fork collision
    defender

end loop




Please specify what version of Turing you are using
4.1.1
Sponsor
Sponsor
Sponsor
sponsor
killjackin61




PostPosted: Wed Nov 25, 2009 9:51 am   Post subject: RE:Help needed with variables and Procedures.

so weak, so much for no help topics in this forum
Tony




PostPosted: Wed Nov 25, 2009 1:24 pm   Post subject: Re: Help needed with variables and Procedures.

Laughing

Please see this thread regarding your collision problems.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
chimerix




PostPosted: Wed Nov 25, 2009 3:56 pm   Post subject: RE:Help needed with variables and Procedures.

Thanks
B-Man 31




PostPosted: Wed Nov 25, 2009 8:16 pm   Post subject: RE:Help needed with variables and Procedures.

Also, you should get rid of the processes.
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  [ 5 Posts ]
Jump to:   


Style:  
Search: