Computer Science Canada

randomizing array....

Author:  TrAnCeIn4LiFe [ Sat May 29, 2004 7:58 pm ]
Post subject:  randomizing array....

is there a possibility to randomize an array that has pictures.... set as an array
hum i tried this but not working...

loop
for x : 1 .. 5
randomize
delay (10000)
Pic.Draw, randint (sprite1 (x), bxr, bxl)
put sprite1 (x)
end for
end loop

Author:  Paul [ Sat May 29, 2004 8:08 pm ]
Post subject: 

wha?
just make an array of picture then...
var num: int
loop
for x : 1 .. 5
randint (num, 1, howevermanypicsuhave)
delay (10000)
Pic.Draw (sprite1 (num), bxr, bxl)
put sprite1 (num)
end for
end loop

Author:  TrAnCeIn4LiFe [ Sun May 30, 2004 10:40 am ]
Post subject: 

yah one problem i cant Pic.Draw, randint Confused eh thats my real problem

but here is the whole code of what i got

code:

/***************************************************************
 *                          Images                             *
 ***************************************************************/

var xx : array 1 .. 9 of int := init (0, 0, 0, 0, 0, 0, 0, 0, 0)
var xx1 : array 1 .. 3 of int := init (1, 2, 0)

var sprite : array 1 .. 9 of int % your ship
for redplane : 1 .. 9
    sprite (redplane) := Pic.FileNew ("redplane" + intstr (redplane) + ".bmp")
end for

var sprite1 : array 1 .. 5 of int % upgrade for ship
for upgrades : 1 .. 5
    sprite1 (upgrades) := Pic.FileNew ("upgrade" + intstr (upgrades) + ".bmp")
end for

var sprite2 : array 1 .. 4 of int % enemy planes
for enemy : 1 .. 4
    sprite2 (enemy) := Pic.FileNew ("enemy" + intstr (enemy) + ".bmp")
end for

var background : int := Pic.FileNew ("back.bmp") % background

/***************************************************************
 *                      Scoring System                         *
 ***************************************************************/

var e_plane : array 1 .. 5 of int % enemy plain score keep
var plane_count : int := 0 % plains destroyed
var z : int % data file

/***************************************************************
 *                         Movement                            *
 ***************************************************************/

var chars : array char of boolean
var key : string (1)
var uy, dy : int := 0 % up y, bottom y
var lx, rx : int := 0 % left x right x
var byt, byb : int := 0 % top y,bottom y,
var bxr, bxl : int := 0 % right x, left x

/***************************************************************
 *                         Other                               *
 ***************************************************************/

var num : int := 5

/***************************************************************
 *                      Introduction                           *
 ***************************************************************/

procedure info

    setscreen ("noecho,nocursor")

    locate (1, 30)
    colour (13)
    put "SKY HUNTER"
    put skip
    color (2)
    put "During the year of 1942 many man were summended for the war to,"
    put "defeat German sky forces."
    put skip
    put "You are one of the Canadian pilots summeneded for this warfare"
    put "your plane is a classic from World War plane, " ..
    colour (13)
    put "Spit Fire" ..
    colour (2)
    put ".  Unfortunately"
    put "the Germans will attack harder and harder as you defeat more,"
    colour (2)
    put "and more of them.  In order to save your " ..
    put "plane you must collect repair "
    put "kits and aimunition. Use SPACE BAR to shot, X to change weapons "
    put "to the left, Z change weapons to the right and ARROWS to move up,"
    put "left, right, front and back."
    put skip
    put "   If you take down more then 100 planes you get a 'Medal of Honor'."
    put skip
    put "       Good luck."
    put skip
    put "Hit any key to start the game..."

    Input.Pause

    cls

end info

/***************************************************************
 *                      Game Code                              *
 ***************************************************************/

open : z, "score system.t", get % scoring system from data file
assert z > 0

for x : 1 .. 5

    get : z, skip
    get : z, e_plane (x)

end for

close : z

procedure fly

    View.Set ("offscreenonly,nobuttonbar")
    setscreen ("graphics:maxx;maxy,noecho,nocursor")
    View.Update

    % input keys to move plane around

    loop
        Input.KeyDown (chars)
        if chars (KEY_UP_ARROW) then
            for x : 1 .. 1
                xx (x) := x
                uy := 4
            end for
        elsif chars (KEY_RIGHT_ARROW) then
            for x : 1 .. 1
                xx (x) := x + 2
                rx := 4
            end for
        elsif chars (KEY_DOWN_ARROW) then
            for x : 1 .. 1
                xx (x) := x
                dy := dy - 4
            end for
        elsif chars (KEY_LEFT_ARROW) then
            for x : 1 .. 1
                xx (x) := 2
                lx := lx - 4
            end for
        elsif chars ('x') then



        elsif chars ('z') then



        elsif chars ('q') then % exit game
            exit
        end if

        getch (key)
        if key = " " then % shoot

        end if

        if xx (1) > 0 then % move the airplane
            for movex : 1 .. 1
                bxr := bxr + lx + rx
                byt := byt + uy + dy
                View.Update
                Pic.Draw (background, 0, 0, picCopy)
                Pic.Draw (sprite (xx (movex)), bxr, byt, picMerge)
                View.Update
            end for
        end if

        lx := 0 % clear modes
        rx := 0
        uy := 0
        dy := 0

    end loop

end fly

procedure upgrades
    loop
        for x : 1 .. 5
            randomize
            randint (num, 1, 3)
            randint (sprite1 (num), bxr, bxl)
            Pic.Draw, sprite1 (num)
        end for
    end loop
end upgrades

/***************************************************************
 *                      Game Run Code                          *
 ***************************************************************/


loop

    info
    fly
    upgrades
   
end loop


: