
-----------------------------------
turinghelp123
Wed May 14, 2014 8:53 pm

Shoot multiple times
-----------------------------------
What is it you are trying to achieve?



What is the problem you are having?



Describe what you have tried to solve this problem



Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)




<
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


-----------------------------------
DemonWasp
Wed May 14, 2014 9:27 pm

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
Wed May 14, 2014 9:30 pm

RE:Shoot multiple times
-----------------------------------
What do you mean? How does this help shooting multiple times?

-----------------------------------
Tony
Wed May 14, 2014 11:03 pm

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.

-----------------------------------
turinghelp123
Wed May 14, 2014 11:09 pm

Re: 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.


Thanks tony, I just looked at arrays but I'm having trouble applying it to my program
