
-----------------------------------
TokenHerbz
Tue Oct 04, 2005 11:03 pm

FLEXABLE  ARRAYS!
-----------------------------------
this is a classic example of my code screwing up cause i lack knowledge or these arrays which can change size...

Anyways, Help me out please...


%%UFO GAME%%
setscreen("Graphics:300;150")

%%Variables
var counter: int:= 1
var game: boolean := false
var x, y: int                               %Ball
var speed: int := 0                         %Ball other speed
var vx, vy: int                             %ball direction
var sp,sz: int                              %ball speed/size
var num: int := 1                           %number of obsticles
var x1, y1: flexible array 1 .. 1 of int   %obsticle
var vx1, vy1: array 1 .. 20 of int         %obsticle direction
var sp1,sz1: array 1 .. 20 of int          %obsticle speed/size
var level: int          
var ship: array char of boolean

%%Declare
%ball
x := 20
randint(y,20,80)
sp := 1
sz := 5
vx := sp
vy := sp
%obsicle
for i: 1 .. num
    x1(i) := 280
    randint(y1(i),11,139)
    sp1(i) := 1
    sz1(i) := 10
    vx1(i) := sp1(i)
    vy1(i) := sp1(i)
end for

%%Intro
put "Hi, wecome to a UFO game"
put "Just avoid the obsticles"
put "Good luck"
put "More to come later"
Input.Pause
cls

%%Game%%
loop
    %move ship
    Input.KeyDown(ship)
    
    if ship (KEY_UP_ARROW) then
        y := y + vy
    end if
    if ship (KEY_DOWN_ARROW) then
        y := y - vy
    end if
    if ship (KEY_RIGHT_ARROW) then
        x := x + vx
    end if
    if ship (KEY_LEFT_ARROW) then
        x := x - (vx + 1)
    end if
    
    %boundry
    if x = 300 then
        x *= -1
    end if
    if y = 150 then
        y *= -1
    end if
    
    for i: 1 .. num
        x1(i) := x1(i) - vx1(i) - speed

        %%Colistion
        if x+sz >= x1(i)-sz1(i) and x-sz = y1(i)-sz1(i) and y-sz 