
-----------------------------------
MoTi0n
Tue Oct 16, 2007 9:44 am

Need help with my space shooter for my turing class
-----------------------------------
Hey I'm trying to make a space shooter for my turing class but my Teacher doesent know how to get the shooting to work properly lol, when he shows me how to get it to shoot everything stops the projectile starts going and then everything starts moving again. I need to get it to work like that space ace program http://compsci.ca/v3/viewtopic.php?t=14764&highlight=space+invaders, where you shoot and u can continue to strafe while the projectile is flying across the screen, anny suggestions?


Heres what i have so far:



%Variables Dictionary
%declare variable by name and type
var picID : int %.......................................sets aside memory and names it for gamepiece
var picIDback : int %...................................sets aside memory and names it for background
var chars : array char of boolean %.....................sets up keystroke decisions true or false
var key : string (1)
var y : int := 0
var x : int := 0
%*********************************
%
%
%*********************************
%Procedures/Subprograms/Subroutines
%do each seperatly in a block
%>ORBITAL CANNON GAMEPIECE MADE WITHM OSTLY DRAWFILL BOX'S AND LINES
proc gamepiece (x : int, y : int)
    drawfillbox (82, 60, 120, 100, grey) %...........main box
    drawbox (82, 60, 120, 100, black)
    drawfillbox (98, 100, 104, 133, yellow) %........yellow cannon shaft
    drawbox (98, 100, 104, 133, black)
    drawline (96, 102, 106, 102, red)
    drawline (96, 102 + 2, 106, 102 + 2, red)
    drawline (96, 102 + 4, 106, 102 + 4, red)
    drawline (96, 102 + 6, 106, 102 + 6, red)
    drawline (96, 102 + 8, 106, 102 + 8, red)
    drawline (96, 102 + 10, 106, 102 + 10, red) %....red conductors on cannon shaft
    drawline (96, 102 + 12, 106, 102 + 12, red)
    drawline (96, 102 + 14, 106, 102 + 14, red)
    drawline (96, 102 + 16, 106, 102 + 16, red)
    drawline (96, 102 + 18, 106, 102 + 18, red)
    drawline (96, 102 + 20, 106, 102 + 20, red)
    drawline (96, 102 + 22, 106, 102 + 22, red)
    drawline (96, 102 + 24, 106, 102 + 24, red)
    drawline (96, 102 + 26, 106, 102 + 26, red)
    drawline (96, 102 + 28, 106, 102 + 28, red)
    drawline (95, 133, 107, 133, black) %...........tip of laser
    drawline (95, 133, 99, 143, black)
    drawline (107, 133, 103, 143, black)
    drawline (99, 143, 103, 143, black)
    drawoval (101, 80, 5, 5, black) %...............mainbody detail
    drawoval (101, 80, 8, 12, black)
    drawfilloval (101, 80, 2, 2, red)
    drawline (85, 63, 85, 97, red)
    drawline (117, 63, 117, 97, red)
    drawline (88, 66, 88, 94, red)
    drawline (114, 66, 114, 94, red)
    drawline (82, 78, 74, 76, black) %..............left thruster
    drawline (74, 76, 74, 86, black)
    drawline (74, 86, 82, 84, black)
    drawline (120, 78, 128, 76, black) %............right thruster
    drawline (128, 76, 128, 86, black)
    drawline (128, 86, 120, 84, black)

    drawfill (124, 80, grey, black) %...............Fills right thruster with colour
    drawfill (77, 80, grey, black) %................Fills left thruster with colour
    drawfill (101, 138, grey, black) %..............Fills left thruster with colour
    drawfillbox (92, 55, 110, 60, grey) %...........Lil box on the bottom of body
    drawbox (91, 55, 110, 60, black)

end gamepiece

%STARS
proc dots
    drawfilloval (150, 50, 1, 1, 92)
end dots
%> 540 then
        x := x - 5
    end if

    locate (20, 20) %...............................location of coords below
    put x : 5 .. %..................................shows coords

    Pic.Draw (picID, x, y, picMerge)
    View.Update
    Pic.Draw (picIDback, x, y, picCopy)
end loop

%*********************************
[/code]

-----------------------------------
Bored
Tue Oct 16, 2007 8:56 pm

Re: Need help with my space shooter for my turing class
-----------------------------------
All you really need to do is use a variable to keep track of the shots position like you have for the laser you've made there. Then when you shoot it simply checks to see if the shot is already moving, if not it simply moves it to the appropriate x and y position. Each time if the shot is still on the screen you move it up so many pixels.

Some psuedo code:
if key pressed and can shoot (shot offscreen) then
    move shot to start position
end if

if shot is moving (on screen) then
    move shot
end if

-----------------------------------
MoTi0n
Tue Oct 16, 2007 11:31 pm

Re: Need help with my space shooter for my turing class
-----------------------------------
thanks, I'll try to work it out tommorow at school :p

-----------------------------------
MoTi0n
Wed Oct 17, 2007 12:52 pm

Re: Need help with my space shooter for my turing class
-----------------------------------
Yeah this is all me and my teacher can come up with so far lol...and it has to be done by friday :(

 if chars (' ') then
        for c : 1 .. 350
            drawfilloval (x + 54, y + 100 + c, 3, 3, red)
            View.Update
            drawfilloval (x + 54, y + 100 + c, 3, 3, black)
        end for[/code]

I may just ditch the proper projectile because my teacher thinks its too complex and a waste of time

-----------------------------------
Carey
Fri Oct 19, 2007 12:06 pm

RE:Need help with my space shooter for my turing class
-----------------------------------
try having a main loop with the essentials in it and the shot moving proc

loop
     if one of the arrow keys pressed then
        movePlane
     end if

     if shoot key pressed and canShoot then
          shoot
     end if

     moveShot
     checkShot
     draw
     View.Update
     cls
end loop


where movePlane moves the plane @ the bottom of the screen, shoot makes the bullet coords equal to the plane coords, canShoot is a fcn that returns if you can shoot or not, moveShot adds some amount to the bullet y coord, checkShot checks to see if the bullet has hit something, and draw draws all the enemies, plane, bullet(s), etc. on to the screen.

hopefully that helps.

even if the deadline for your project was today :)
