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

Username:   Password: 
 RegisterRegister   
 Missile FIX
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Remm




PostPosted: Mon May 08, 2006 7:34 pm   Post subject: Missile FIX

*ACK* yeah i had somthing more filling here, but i clicked back and it erased it all.
SO; the quick form.
The origonal was made by Tom West, Stephen Perelgut and Ric Holt
all credit goes to them
This FIX was made to look better, and be generally more fun, putting in custom stuffs as well as keeping the origonal version if wanted.
Dont ask me why typed in text doesnt show up at start, just type it in and click enter. I messed around with the code and made this up in the first 4 weeks of programming, and havnt changed anything since then (thats why i havnt put in 80+ proceedures Very Happy )
So, have fun.
code:



% Remix version meant not to suck as much as origonal
% Remix by (NAME REMOVED)
%                       Constants                               %

const groundColour := 1
const missileColour1 := red
const missileColour2 := brightblue
const explosionColour := 2
const playerColour := blue
const turnDelay := 100
const outOfPlay := 0

var maxMissiles : int
maxMissiles := 100000

process song
    Music.Play("1a4a<1a>4d4d4c<1a<1a>>4d4d4c<1a<la<lala>4a4a4b4b<1a<1a>4a4a4b4b<1a<1a>4a4a4b4b<1a<1a>>4d4d4c<1a<1a>4d4d4c<la<la>4a4a4b4b<1a<1a>4a4a4b4b<1a<1a")
    end song


%                  Global Variables                             %
var playerSpeed : int
var choose : string
var numMissiles : int % the number of missiles in play
var evadedMissiles : int := 0 % total number of missiles evaded
var tx : int := maxx div 2 % the x position of the player in pixels
var ty : int := maxy div 2 % the y position of the player in pixels
var turns, timer, dist, font1 : int
var howmany : int
 %   This procedure gives the instructions for the game.      %
font1 := Font.New("Bauhaus 93:40x50")
fork song
procedure Instructions

    locate (1, 30)
    delay(2000)
    Font.Draw ("Missiles",53,203, font1, gray)
    Font.Draw ("Missiles",47,197, font1, gray)
    Font.Draw ("Missiles",50,200, font1, brightred)
    delay(2000)
    cls
    colour(black)
    colour(brightred)
    put "                    Missiles Remix"
    delay(400)
    colour(brightgreen)
    put "       Try not to get hit. not that complex."
    colour(black)
    put skip
    delay(400)
    put "Normal game or Custom? (N or C)"
    put "Normal uses the settings from the origonal game."
    put "Custom allows you to choose your settings, making the game"
    put "easier or harder, to your preferance."
    put "What is typed in will not show up, just click enter after"
    put "you designate your desired amount / command, even if it does"
    put "not show up."
    colour(black)
    get choose
    if (choose = "C") or (choose = "c") then
        put "How many missles at start? (1 - 100000)"
        get numMissiles
        put "How many missles per turn? (1 - 50000)"
        get howmany
        put "What speed would you like to go? (1-100)"
        get playerSpeed
    else
        numMissiles := 1
        howmany    := 1
        playerSpeed:= 4
        maxMissiles := 20
    end if
    colour(red)
    put "       Hit any key to start the game..."

    Input.Pause
    cls
end Instructions


%   This procedure draws the player.                           %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

procedure DrawPlayer (clr : int)
Draw.FillBox (round (tx - 5), round (ty - 5), round (tx + 5), round (ty + 5), clr)
Draw.FillBox (round (tx - 4), round (ty - 4), round (tx + 4), round (ty + 4), clr)
Draw.FillBox (round (tx - 3), round (ty - 3), round (tx + 3), round (ty + 3), clr)
end DrawPlayer

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   This procedure handles any key strokes by reading any char  %
% from the keyboard and moving the player in response to it.    %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure ControlPlayer
    var x, y, b : int
    Mouse.Where (x, y, b)
    if b = 1 and (x not= tx or y not= ty) then
        DrawPlayer (0)

        var d : real := sqrt ((x - tx) ** 2 + (y - ty) ** 2)
        var dx : int := round ((x - tx) * playerSpeed / d)
        var dy : int := round ((y - ty) * playerSpeed / d)
        if abs (dx) > abs (x - tx) then
            tx := x
        else
            tx := tx + dx
        end if
        if abs (dy) > abs (y - ty) then
            ty := y
        else
            ty := ty + dy
        end if

        % 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

        % Draw the player in its new position
        DrawPlayer (playerColour)
    end if
end ControlPlayer

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                         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
        px (i) := Rand.Int (0, maxx)
        py (i) := 0
        vx (i) := 0
        vy (i) := Rand.Int (1, 5)
    end for

    % Draw the screen
    cls
    drawline (0, 0, maxx, 0, 1)
    DrawPlayer (playerColour)

    % Set the clock and number of elapsed turns
    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 20 = 0 then
                        vx (i) -= sign (vx (i))
                    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 8 = 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
                    Draw.FillStar (ox, oy, px (i), py (i), missileColour2)
                else
                    Draw.ThickLine (ox, oy, px (i), py (i),3, missileColour1)
                    Draw.ThickLine (ox, oy, px (i), py (i),2, brightgreen)
                    Draw.ThickLine( ox, oy, px (i), py (i),1, brightred)
                end if
               
                % Check to see if it hit the ground
                if py (i) <= 0 then
                    drawline (px (i), 0, px (i) - 10, 10, explosionColour)
                    drawline (px (i), 0, px (i), 10, explosionColour)
                    drawline (px (i), 0, px (i) + 10, 10, explosionColour)
                    px (i) := outOfPlay
                    evadedMissiles += 1
                end if

                % Check to see if it hit the player
                if Math.DistancePointLine (tx, ty, ox, oy, px (i), py (i)) < 3 then
                    drawfillstar (tx - 7, ty - 7, tx + 7, ty + 7, brightblue)
                    locate (10, 5)
                    for flash :1 .. 1000
    Font.Draw ("FAILURE",97,197, font1, gray)
    Font.Draw ("FAILURE",97,197, font1, gray)
    Font.Draw ("FAILURE",100,200, font1, brightred)
    delay (300)
    Font.Draw ("FAILURE",97,197, font1, gray)
    Font.Draw ("FAILURE",97,197, font1, gray)
    Font.Draw ("FAILURE",100,200, font1, red)
    delay(200)
    Font.Draw ("FAILURE",97,197, font1, gray)
    Font.Draw ("FAILURE",97,197, font1, gray)
    Font.Draw ("FAILURE",100,200, font1, black)
    delay(300)
    Font.Draw ("FAILURE",97,197, font1, gray)
    Font.Draw ("FAILURE",97,197, font1, gray)
    Font.Draw ("FAILURE",100,200, font1, red)
    delay(300)
    colour(black)
     put "You lost miserably after ", evadedMissiles, " missiles..." ..
            locate(2,2)     
    end for
    Font.Draw ("FAILURE",97,197, font1, gray)
    Font.Draw ("FAILURE",97,197, font1, gray)
    Font.Draw ("FAILURE",100,200, font1, brightred)
                    delay (500)
                    return
                end if
            end if
        end for
        % Check if the player is being controlled
        ControlPlayer

        % This is a timer delay loop to make sure that each turn takes
        % the same length of time to execute, regardless of the number
        % of missiles on the screen
        Time.DelaySinceLast (30)

        % 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 += howmany
    if numMissiles > maxMissiles then
        numMissiles := maxMissiles
    end if
end loop

i tried to put it in a attachment, but it got all buggy on me. sorry.

Mod Edit: User's full name removed from code comments at request of user.
Sponsor
Sponsor
Sponsor
sponsor
ohgeez_




PostPosted: Mon May 08, 2006 8:16 pm   Post subject: (No subject)

ok a few things

this is a source and therefore shouldnt be posted here. but since it is..

firstly, i think that they game runs a little to fast. the missle started chasing the thing before i even had a chance to react. perhaps slowing it down a little bit.

secondly, when u do lose, u cant exit or so i cant find one. when i looked at the code. i dont really see an exit statement that exit's the main loop. (unless i overlooked) the only exit is in the for loop.

also. u should set a screen size. the font seems to go over sized on the screen

also. ur colision detector isnt the very best. some lines just go right past the square.

but otherwise. a cool game. good job =D
upthescale




PostPosted: Mon May 08, 2006 9:38 pm   Post subject: (No subject)

Even though this is the applications asrea , u shud zip it cuz i dont have Math.Distance in 4.0.4...so zip it and re apply it please...(only if oyu would like;))


ps (I no this ins't part of this section, nor of this site, but please look at this, it will make your night!)

hey at least im not making a new topic of it!!

http://www.youtube.com/watch?v=LVCb52iQrfo
Clayton




PostPosted: Mon May 08, 2006 10:08 pm   Post subject: (No subject)

upthescale: not only is that the stupidest thing i have ever seen, but it is in the totally wrong forum, and you obviously knew that. post stuff like this in the Off Topic forum (formerly known as the Spam forum for a reason) keep this kind of thing there, as to the program, i dont have access to Turing right this moment so i cant test it, i will in a bit though Very Happy
Remm




PostPosted: Tue May 09, 2006 7:06 am   Post subject: (No subject)

Meant to put in source code >.< sorry.
jamonathin




PostPosted: Tue May 09, 2006 9:22 am   Post subject: (No subject)

Well at least you gave credit to who made it. This is probabily the 3rd or 4th "missile" game ive seen thats in the demo folder of Turing that people claim to be their own.

Also take off noecho - that way we can see what we type Wink.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: