
-----------------------------------
rollerdude
Wed Jun 01, 2005 9:05 am

missle game 2
-----------------------------------
to get the first part of the program, look for "check out my cool game"

this is lines 121-341(end)


code.....

            % The 6 key (on the numeric keypad)
        label 205 :
            tx += playerSpeed

            % The 1 key (on the numeric keypad)
        label 207 :
            tx -= playerSpeed
            ty -= playerSpeed

            % The 2 key (on the numeric keypad)
        label 208 :
            ty -= playerSpeed

            % The 3 key (on the numeric keypad)
        label 209 :
            tx += playerSpeed
            ty -= playerSpeed

            % The 'q' key (this quits the game)
        label ord ("q") :
            tx := - 1
            return
        label :
    end case

    % Make certain the player doesn't go off the screen.
    if tx < 10 then
        tx := 10
    elsif tx > maxx - 10 then
        tx := maxx - 10
    end if
    if ty < 10 then
        ty := 10
    elsif ty > maxy - 10 then
        ty := maxy - 10
    end if

    % This empties the buffer
    loop
        exit when not hasch
        getch (c)
    end loop

    % Draw the player in its new position
    DrawPlayer (playerColour)
end ControlPlayer

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   This function determines whether the player was hit by checking to %
% see if any pixels of the player's piece are not of the appropriate   %
% colour.  (i.e. a missile track was drawn over top of the player)     %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function PlayerHit : boolean
    var hit : boolean := false
    var dot : int
    for i : tx - 1 .. tx + 1
        for j : ty - 1 .. ty + 1
            dot := whatdotcolour (i, j)
            if dot not= playerColour then
                hit := true
            end if
        end for
    end for
    result (hit)
end PlayerHit

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                         Main Body                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
var px, py : array 1 .. maxMissiles of int
% The position array for the missiles
var vx, vy : array 1 .. maxMissiles of int
% The velocity array for the missiles

randomize
setscreen ("graphics,noecho")

Instructions

loop
    % Initialize the missile array.
    for i : 1 .. numMissiles
        randint (px (i), 0, maxx)
        py (i) := 0
        vx (i) := 0
        randint (vy (i), 1, 5)
    end for

    % Draw the screen
    cls
    drawline (0, 0, maxx, 0, 1)
    DrawPlayer (playerColour)

    % Set the clock and number of elapsed turns
    clock (prevTime)
    turns := 0

    % The main loop
    loop
        turns += 1

        % For each missile: determine the new x velocity
        %                   determine the new y velocity
        %                   set the new missile position
        %                   draw a travel line
        %                   check to see if it hit the ground
        %                   check to see if it hit the player
        for i : 1 .. numMissiles
            const ox : int := px (i)
            const oy : int := py (i)

            if ox not= outOfPlay then

                % Determine the x velocity
                dist := abs (vx (i)) * (abs (vx (i)) + 1) div 2
                if vx (i) < 0 and ox - dist < 0 then
                    vx (i) += 2
                elsif vx (i) > 0 and ox + dist > maxx then
                    vx (i) -= 2
                elsif turns > 100 then
                    if turns mod 10 = 0 then
                        if vx (i) < 0 then
                            vx (i) += 1
                        elsif vx (i) > 0 then
                            vx (i) -= 1
                        end if
                    end if
                elsif ox < tx then
                    vx (i) += 1
                elsif ox > tx then
                    vx (i) -= 1
                end if

                % Determine the y velocity
                dist := abs (vy (i)) * (abs (vy (i)) + 1) div 2
                if vy (i) > 0 and oy + dist > maxy then
                    vy (i) -= 2
                elsif turns > 100 then
                    if turns mod 4 = 0 then
                        vy (i) -= 1
                    end if
                elsif vy (i) < 0 and oy - dist < - turns div 15 then
                    vy (i) += 2
                elsif oy < ty then
                    vy (i) += 1
                elsif oy > ty then
                    vy (i) -= 1
                end if

                % Set the new missile position
                px (i) += vx (i)
                py (i) += vy (i)

                % Draw a travel line
                if turns > 100 then
                    drawline (ox, oy, px (i), py (i), missileColour2)
                else
                    drawline (ox, oy, px (i), py (i), missileColour1)
                end if

                % Check to see if it hit the ground
                if py (i)  prevTime + turnDelay
        end loop
        prevTime := timer

        % This will leave the loop when all the missiles have crashed.
        var endNow : boolean := true
        for i : 1 .. numMissiles
            if px (i) not= outOfPlay then
                endNow := false
            end if
        end for
        exit when endNow
    end loop

    % After each time all the missiles have crashed, add 1 to the number
    % of missiles with a maximum of maxMissiles.
    numMissiles += 1
    if numMissiles > maxMissiles then
        numMissiles := maxMissiles
    end if

end loop






there you have it, combine the two program peices and have fun!!!!

-----------------------------------
jamonathin
Wed Jun 01, 2005 8:12 pm


-----------------------------------
Ok ok, first of all, who's going to want to look up another half to the program, somewhere on the site?  Put it all together, or upload it in a .t file, which isn't very hard.

Secondly, use code tags, such as:


[code]Your code goes here.[/code]


Only makes sense man  :?

-----------------------------------
rollerdude
Wed Jun 01, 2005 9:38 pm


-----------------------------------
ok, but when i tried that, the internet errored and timed out

i also tried doing the whole program at once, but it was too large

-----------------------------------
decon1985
Tue Jun 07, 2005 2:22 pm

Whatever...
-----------------------------------
Well I guess Ill say something good then.  I really liked it even though I had to find the other part.  Very cool, keep it up! :wink:

-----------------------------------
Drake
Wed Jun 22, 2005 12:50 pm


-----------------------------------
This is just a copy of the missile game that Turing comes with.  He did no actual work to come up with this game, just looked around through the files that Turing comes with and pasted it onto here.  I'm pretty sure that there was a post somewhere on this forum about plagarism.  This is exactly what they were talking about.
