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

Username:   Password: 
 RegisterRegister   
 Shoot multiple times
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
turinghelp123




PostPosted: Wed May 14, 2014 8:53 pm   Post subject: Shoot multiple times

What is it you are trying to achieve?
<Make the program shoot multiple times>


What is the problem you are having?
<You can only shoot once then you have to wait till the bullet disappears to shoot again>


Describe what you have tried to solve this problem
<I've been trying to solve this for about 1 hour, and I've been having no luck>


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


Turing:


<
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 >



Please specify what version of Turing you are using
<4.1>
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Wed May 14, 2014 9:27 pm   Post subject: RE:Shoot multiple times

If you want to keep track of several things of the same type, you should look into arrays and records. Here's the Turing Walkthrough links:

http://compsci.ca/v3/viewtopic.php?t=14333

http://compsci.ca/v3/viewtopic.php?t=9636
turinghelp123




PostPosted: Wed May 14, 2014 9:30 pm   Post subject: RE:Shoot multiple times

What do you mean? How does this help shooting multiple times?
Tony




PostPosted: Wed May 14, 2014 11:03 pm   Post subject: RE:Shoot multiple times

Right now you have only bullety. You want bullety_1, bullety_2, ..., etc. An array will let you group those related variables together, for much easier use.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
turinghelp123




PostPosted: Wed May 14, 2014 11:09 pm   Post subject: Re: RE:Shoot multiple times

Tony @ Wed May 14, 2014 11:03 pm wrote:
Right now you have only bullety. You want bullety_1, bullety_2, ..., etc. An array will let you group those related variables together, for much easier use.



Thanks tony, I just looked at arrays but I'm having trouble applying it to my program
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: