
-----------------------------------
Flashkicks
Fri May 13, 2005 12:00 pm

Control Problems via Input.KeyDown ()
-----------------------------------
Hay hay ppl'z!  This is Flashkicks here!  I am just trying to make simple asteroids game and its been awhile.  I was just seeing if anyone can remember or tell me how to have two things going at one withOUT using a process.  Example, have my spaceship move, while shooting lasers at the same time.  Here's the code.
%%%%%%%%%%%%%%%%
%              %
%%%  JoyPad  %%%
%              %
%%%%%%%%%%%%%%%%
% Billy Boldt  %
%%%% % % % %%%%%


%% Button : ground (y) := orange
setscreen ("graphics:max;max")
View.Set ("offscreenonly")

drawfillbox (0, 0, maxx, maxy, 7)
var shipX, shipY, laserX, laserY : int
shipX := 10
shipY := maxy div 2
laserX := shipX
laserY := shipY
proc eraseShip
    drawfillbox (shipX - 10, shipY, shipX + 50, shipY + 25, 7)
end eraseShip

proc DrawShip
    drawfilloval (shipX + 25, shipY + 15, 25, 10, 28)
    drawfillbox (shipX - 10, shipY, shipX + 25, shipY + 10, 28)
    drawfilloval (shipX + 35, shipY + 20, 7, 3, 1)
    drawfillbox (shipX + 27, shipY + 2, shipX + 50, shipY + 4, 23)
    drawfillbox (shipX + 25, shipY, shipX + 27, shipY + 5, 23)
end DrawShip

proc eraseLaser
    drawfillbox (laserX + 51, laserY + 2, laserX + 75, laserY + 4, 7)
end eraseLaser

proc DrawLaser
    drawfillbox (laserX + 51, laserY + 2, laserX + 75, laserY + 4, 1)
end DrawLaser

proc Controls
    var input : array char of boolean
    var speed : int := 3
    loop
        Input.KeyDown (input)
        if input (KEY_UP_ARROW) then
            eraseShip
            shipY := shipY + speed
            DrawShip
            View.Update
        end if
        if input (KEY_DOWN_ARROW) then
            eraseShip
            shipY := shipY - speed
            DrawShip
            View.Update
        end if
        if input (KEY_LEFT_ARROW) then
            eraseShip
            shipX := shipX - speed
            DrawShip
            View.Update
        end if
        if input (KEY_RIGHT_ARROW) then
            eraseShip
            shipX := shipX + speed
            DrawShip
            View.Update
        end if
        if input (KEY_TAB) then
            laserX := shipX
            laserY := shipY
            loop
                eraseLaser
                laserX := laserX + 10
                DrawLaser
                View.Update
                exit when laserX >= maxx
            end loop
        end if
        if shipX = maxx - 50 then
            shipX := maxx - 50
        end if
        if shipY = maxy + 25 then
            shipY := 0
        end if
    end loop
end Controls

DrawShip
Controls

So run it and you will see once you shoot- you can not move.  And I've made a game like this before so i KNOW its possible.  Good Luck-and have fun!
~Flashkicks

-----------------------------------
Dylan-182
Fri May 13, 2005 12:07 pm


-----------------------------------
:o i tried it and its coolness i have no idea how 2 help u with it :roll:  but so far its cool :P i think im guna look at the code n figure out how 2 do this for myself :D then maybe go on 2 make a cool game of my own... :think:  lol ne ways sry i culdnt help but at least i got 2 see that this sorta thing is possible with turing, gives me sumthin 2 aim for :D

-----------------------------------
Delos
Fri May 13, 2005 12:12 pm


-----------------------------------
My general comment on this (after having looked through your code), is to set up your 'main' loop to be the one that controls all movement/firing etc.  Break down these actions into procedures, somewhat like the way you have it.
This way, if one of the arrow keys are pressed, the corresponding movement is called via a procedure/function.
When the key to fire is pressed, the object be be fired is created, and then in subsequent checks by the main loop, its status is checked and changed (i.e., its x-/y- pos'ns are altered, etc etc).  Of course, these changes are done in a seperate procedure altogether.  Compartmentalization is good!  Don't put additional loops within your main loop...
This is the general idea that I used when making [url=http://www.compsci.ca/v2/viewtopic.php?t=8457]~Star Catcher~ [/shameless plug].

-----------------------------------
jamonathin
Fri May 13, 2005 12:23 pm


-----------------------------------
Now some of the variables can be changed to boolean, and I heard it a million tiem to do so, but it's my personal preference not to, say what you will, but anyways here's a code for what you need.  I didn't edit your program, beacause you'll remember more you edit your program yourself.

setscreen ("graphics:400;500,nobuttonbar,position:center;center,offscreenonly,title:SiMaCz Productionz")
colorback (black)
var dif : int := 3 %Difference of movement
var done, laserwait : int := 0 %Tells program when another laser is allowed to fire
var x, y : int := 20 %Player co-ordinates
var laserx, lasery, hold : array 1 .. 10 of int
var key : array char of boolean
drawfillbox (0, 0, 15, 20, 2)
var ship : int := Pic.New (0, 0, 15, 20)
cls
for i : 1 .. upper (hold) %Max amount of lasers
    laserx (i) := 0 %Just defaulting everything to zero
    lasery (i) := 0
    hold (i) := 0
end for

procedure shoot_lasers %Shoots the lasers
    for i : 1 .. upper (hold) %Checking for all lasers
        if hold (i) = 1 then %If the current laser(i) is being shot then . .
            Draw.ThickLine (laserx (i), lasery (i), laserx (i), lasery (i) + 15, 2, 13) %Draw laser
            lasery (i) += dif * 2 %Move laser twice the speed of the player
            if lasery (i) > maxy then %If its greater than the screen then reset it
                hold (i) := 0
            end if
        end if
    end for
end shoot_lasers

procedure draw
    cls
    shoot_lasers %Calling shoot_lasers
    Pic.Draw (ship, x, y, picMerge) %Space ship, just change the variable to an acutal picture
    View.Update
end draw

loop
    Input.KeyDown (key) %Just Checking teh boundries for movement
    if key (KEY_LEFT_ARROW) and x > dif then
        x -= dif
    elsif key (KEY_RIGHT_ARROW) and x + Pic.Width (ship) < maxx - dif then
        x += dif
    end if
    if key (KEY_UP_ARROW) and y + Pic.Height (ship) < maxy - dif then
        y += dif
    elsif key (KEY_DOWN_ARROW) and y > 30 then
        y -= dif
    end if
    if key (' ') and done = 0 then %If we're allowed to shoot another laser
        for i : 1 .. upper (hold)
            if hold (i) = 0 and done = 0 then %If the current laser is free to be shot
                laserx (i) := x + (Pic.Width (ship) div 2) %Centering the laser
                lasery (i) := y + Pic.Height (ship) %Making it drawn at the top of the ship
                hold (i) := 1 %Making it taken
                done := 1 %Telling the program to delay before shooting again
            end if
        end for
    end if
    if done = 1 and laserwait < 20 then %Waiting untill laserwait is 20
        laserwait += 1 %This will make a delay of 

Have fun.  :)

Edit: Once again, I should type faster :P

-----------------------------------
Flashkicks
Fri May 13, 2005 12:47 pm


-----------------------------------
Hay- thanks very much for that demo.  I will try to incorporate it into mine..  I will let you now how it goes!
~Flashkicks

Hold on- I have ONE question that I have been seeing a lot lately.  Well, not the question, but .. yeah.Okay----what is this;

 +=

??..  Anyways..

:: EDIT ::

(About 15 minutes later)
Okay, that demo proggy you left me is wonderful, however, I can NOT interpret it into my program :'( ..  Im not sure what to do now.  I tried the whole upper with hold and everything and it just wont shoot any lasers at all...  I dont want to just copy all your code so do you think you can get me started as of what to do next to interpret it into my coding??..  I will keep trying but Im really just getting frustrated.  Anyway, thanks, and hopefully you can help me out..  BTY-My teacher liked the sample you left :lol: lol..  Kay, c ya!
~Flashkicks

:: EDIT ::
Okay- I got it to shoot now, but once 10 lasers are shot-its DONE!  You cant shoot no more :(..  achoo Help!!.....

-----------------------------------
jamonathin
Fri May 13, 2005 1:49 pm


-----------------------------------
Ok, this is what += means.

x -= 2
 % Is the same thing as
x := x - 2

% And . .

y += 7
 % Is the same thing as
y := y + 7

% And . .

z *= 5
 % Is the same thing as
z := z * 5

% And . .

a /= 9
 % Is the same thing as
a := a / 9


And for your shooting problem. . . when do you reset the shots?  Do you ever make it so when the laser gets past the top of the screen that you reset it, making it available to shoot again?

Take a look at this again

procedure shoot_lasers %Shoots the lasers 
    for i : 1 .. upper (hold) %Checking for all lasers 
        if hold (i) = 1 then %If the current laser(i) is being shot then . . 
            Draw.ThickLine (laserx (i), lasery (i), laserx (i), lasery (i) + 15, 2, 13) %Draw laser 
            lasery (i) += dif * 2 %Move laser twice the speed of the player 
            if lasery (i) > maxy then %If its greater than the screen then reset it 
                hold (i) := 0 
            end if 
        end if 
    end for 
end shoot_lasers 


Once the lasery is > maxy, I reset that laser, making it available to shoot again, and I use a for loop to check through all 10 lasers to save up room.

-----------------------------------
Flashkicks
Mon May 16, 2005 7:57 am


-----------------------------------
haha-sorry..  I had a silly mistake and everything werks fine.. :oops:  My Baad..  Anyways.. I thank you very much..  Now comes the asteroids :lol: 
~Flashkicks

:UPDATE:

OKAY-wtfrick... :evil: My asteroids arent werking either.. I feel like I cant do anything.. Anyways..  Heres what I have for it- they draw but they never move..
proc asteroids
    type asteroids :
        record
            x : int
            y : int
            size : int
            spd : int
            dx : int
        end record

    var rock : array 1 .. 100 of asteroids
    % Declare initial values
    for i : 1 .. 10
        rock (i).x := Rand.Int (maxx, maxx + 400)
        rock (i).y := Rand.Int (0, maxy)
        rock (i).size := 30
        % rock (i).spd := -1 - rock (i).size
        % rock (i).dx := Rand.Int (-2 - rock (i).size, 2 + rock (i).size)
    end for
    % Make move
    for i : 1 .. 10
        drawfilloval (rock (i).x, rock (i).y, rock (i).size, rock (i).size, 7)
        rock (i).x -= 5
        drawfilloval (rock (i).x, rock (i).y, rock (i).size, rock (i).size, 43)
        delay (5)
    end for
end asteroids
I call asteroids in my main Controls loop...  Maybe I shouldnt be going through this using a record :?   But I thought it would be a good idea cuz then I could eventually keep track of different sizes of asteroids..

-----------------------------------
jamonathin
Tue May 17, 2005 8:17 am


-----------------------------------
Ok, there's nothing wrong with using a record, it just how you're using it.

Declare everything outside of the procedure.  This is what your record should look like:

var rock : array 1 .. 100 of
    record
        x, y, size, spd, dx : int
    end record
Now here's why your asteroids wont move.  You "Declare initial values", and then you decide to "Make move".  The when we run through the procedure again, you declare, then move.  We run through the procedure again, you declare, them move.  You only need to "declare" them once, not everytime in the procedure, because then they wont go anywhere.  So add that to the bottom of your array.

var rock : array 1 .. 100 of
    record
        x, y, size, spd, dx : int
    end record
for i : 1 .. upper (rock) %The amount in array (which is 100)
    rock (i).x := Rand.Int (maxx, maxx + 400)
    rock (i).y := Rand.Int (0, maxy)
    rock (i).size := 30
end for

Now, all thats left is to move, and that's what should be in your "asteroids" procedure.  
I noticed that you're using the "draw over top of the old ball to get rid of it" technique, don't.  There's no need to.  Clear the last screen, and then Update.

Now, we need to change our setscreen/View.Set options to offscreenonly to use View.Update.  But we only do this once, and not inside any loop or procedure.  Just at the top of your program.

setscreen ("graphics:640;480, position:center;center, nobuttonbar, offscreenonly, title: SiMaCz Productionz")
colorback(black)
cls

Now your loop and procedure is small, and this is what your entire program should look like.


setscreen ("graphics:640;480, position:center;center, nobuttonbar, offscreenonly, title: SiMaCz Productionz")
colorback (black)
cls
var rock : array 1 .. 100 of
    record
        x, y, size, spd, dx : int
    end record
for i : 1 .. upper (rock) %The amount in array (which is 100)
    rock (i).x := Rand.Int (maxx, maxx + 400)
    rock (i).y := Rand.Int (0, maxy)
    rock (i).size := Rand.Int (10, 20)
    rock (i).spd := round (19 - (rock (i).size) / 1.007) %rock(i).spd must be whole/int so we use round()
    if rock (i).spd = 0 then %Checking if the speed is 0
        rock (i).spd := 1
    end if
    %rock (i).dx := not sure what this does
end for
proc asteroids
    % Make move
    for i : 1 .. upper (rock)
        rock (i).x -= rock (i).spd
        drawfilloval (rock (i).x, rock (i).y, rock (i).size, rock (i).size, 43)
        drawoval (rock (i).x, rock (i).y, rock (i).size, rock (i).size, 42)%For effect
    end for
end asteroids
loop
    cls
    asteroids
    View.Update
    exit when hasch %Exit when keyboard is touched
    delay (5)
end loop


-----------------------------------
Flashkicks
Tue May 17, 2005 9:26 am


-----------------------------------
Okay.. I tried all your stuff (which by the way was WOW, wut a cool program you made.. I love the "effect :P ..lol..  Anyway") and it like.. Okay, the program RUNS- but not anything like yours..  First, the asteroids dont move quickly and swiftly.  Also, my ship is lagging like a mad mother monkey :?   Im not sure what to do..  I will put my code in here so you can see how I have it ALL set up.  If you comment out the "asteroids" in the 'DrawShipAndShoot' procedure, youll notice how nice and smooth it runs.. But oce I throw the 'asteroids' in there, it goes BOOM...lol
%%%%%%%%%%%%%%%%
%              %
%%%  JoyPad  %%%
%              %
%%%%%%%%%%%%%%%%
% Billy Boldt  %
%%%% % % % %%%%%


%% Button : ground (y) := orange
setscreen ("graphics:max;max, offscreenonly")
colorback (7)
cls
%% Variables %%
drawfillbox (0, 0, maxx, maxy, 7)
var key : array char of boolean
var shipX, shipY : int
shipX := 10
shipY := maxy div 2
var laserX, laserY, hold : array 1 .. 10 of int
var done, laserwait : int := 0 % Tells program when another laser is allowed to fire
var dif : int := 3 % Difference of movement
var level : array 1 .. 10 of int

for i : 1 .. upper (hold) % Give the lasers initial values
    laserX (i) := 0     % Just defaulting everything to zero
    laserY (i) := 0
    hold (i) := 0
end for

proc eraseShip
    drawfillbox (shipX - 10, shipY, shipX + 50, shipY + 25, 7)
end eraseShip

proc DrawShip
    drawfilloval (shipX + 25, shipY + 15, 25, 10, 28)
    drawfillbox (shipX - 10, shipY, shipX + 25, shipY + 10, 28)
    drawfilloval (shipX + 35, shipY + 20, 7, 3, 1)
    drawfillbox (shipX + 27, shipY + 2, shipX + 50, shipY + 4, 23)
    drawfillbox (shipX + 25, shipY, shipX + 27, shipY + 5, 23)
end DrawShip

proc Shoot
    for i : 1 .. upper (hold)
        if hold (i) = 1 then
            drawfillbox (laserX (i) + 51, laserY (i) + 2, laserX (i) + 75, laserY (i) + 4, 7)
            laserX (i) += dif * 3
            drawfillbox (laserX (i) + 51, laserY (i) + 2, laserX (i) + 75, laserY (i) + 4, 1)
            if laserX (i) > maxx then   % If its greater than the screen then reset it
                hold (i) := 0
            end if
        end if
    end for
end Shoot

var rock : array 1 .. 100 of
    record
        x, y, size, spd, dx : int
    end record
for i : 1 .. upper (rock) %The amount in array (which is 100)
    rock (i).x := Rand.Int (maxx, maxx + 400)
    rock (i).y := Rand.Int (0, maxy)
    rock (i).size := Rand.Int (10, 20)
end for

proc asteroids
    % Make move
    for i : 1 .. upper (rock)
        drawfilloval (rock (i).x, rock (i).y, rock (i).size, rock (i).size, 7)
        rock (i).x -= 5
        drawfilloval (rock (i).x, rock (i).y, rock (i).size, rock (i).size, 43)
        drawoval (rock (i).x, rock (i).y, rock (i).size, rock (i).size, 42) %For effect
        delay (5)
        View.Update
        if rock (i).x  dif then
        eraseShip
        shipX -= dif
    elsif key (KEY_RIGHT_ARROW) then
        eraseShip
        shipX += dif
    end if
    if key (KEY_UP_ARROW) then
        eraseShip
        shipY += dif
    elsif key (KEY_DOWN_ARROW) and shipY > 30 then
        eraseShip
        shipY -= dif
    end if
    if key (KEY_TAB) and done = 0 then % If we're allowed to shoot another laser
        shoots
    end if
    if done = 1 and laserwait < 20 then % Waiting untill laserwait is 20
        laserwait += 1 % This will make a delay of [20 * (whatever delay is set)] before shooting again
    elsif done = 1 and laserwait >= 20 then % Now its ok to shoot, so reset laserwait
        laserwait := 0
        done := 0
    end if
    if shipX = maxx - 40 then
        shipX := maxx - 40
    end if
    if shipY >= maxy - 30 then
        shipY := maxy - 30
    end if
    DrawShipAndShoot     % Draw everything
end loop

I think im missing something major(but is probably very small :x ) ..  If you can catch it than I must say, your Good...lol..  You've helped a lot alreay and Im still sitting here every stinkin day werking on it..  But once again-Im stuck:(..

-----------------------------------
jamonathin
Tue May 17, 2005 1:04 pm


-----------------------------------
Here's your code, I added a cool background for yas.

The reason it went incredibly slow was because you were delaying(5) and updating the screen (View.Update) 100 times in that for loop.  You only need View.Update once, and thats before your delay.  I changed things so that only one asteroid comes at a time, and as you shoot more, you can change the new variable i made (rocks) to a higher value, so more asteroids come.

I cleaned up a couple of little things that I forget, but I left the collision for you ;).  If you need help with it just ask, but your programs lookin good so far, keep goin. :)

%%%%%%%%%%%%%%%%
%              %
%%%  JoyPad  %%%
%              %
%%%%%%%%%%%%%%%%
% Billy Boldt  %
%%%% % % % %%%%%


%% Button : ground (y) := orange
setscreen ("graphics:max;max, offscreenonly,nobuttonbar")%nobuttonbar = no button bar :P
colorback (7)
cls

%COol Background
var stars : int := 100
var starx, stary, sdif : array 1 .. 100 of int
for i : 1 .. stars
    starx (i) := Rand.Int (1, maxx) %Making a default for the star somewhere on the screen
    stary (i) := Rand.Int (1, maxy)
    sdif (i) := Rand.Int (2, 7)
end for

proc move_stars
    for i : 1 .. stars %For all of the stars
        starx (i) -= sdif (i) %Move them to their corresponding speed
        drawdot (starx (i), stary (i), white) %Draw them
        if starx (i) < 0 then %If they're off the screen
            starx (i) := maxx %Reset at maxx
            stary (i) := Rand.Int (1, maxy) %Reset for a random y
            sdif (i) := Rand.Int (2, 7) %Reset a random speed
        end if
    end for
end move_stars
%% Variables %%
drawfillbox (0, 0, maxx, maxy, 7)
var key : array char of boolean
var shipX, shipY : int
shipX := 10
shipY := maxy div 2
var laserX, laserY, hold : array 1 .. 10 of int
var done, laserwait : int := 0 % Tells program when another laser is allowed to fire
var dif : int := 3 % Difference of movement
var level : array 1 .. 10 of int
var rocks : int := 2

for i : 1 .. upper (hold) % Give the lasers initial values
    laserX (i) := 0     % Just defaulting everything to zero
    laserY (i) := 0
    hold (i) := 0
end for

proc DrawShip
    drawfilloval (shipX + 25, shipY + 15, 25, 10, 28)
    drawfillbox (shipX - 10, shipY, shipX + 25, shipY + 10, 28)
    drawfilloval (shipX + 35, shipY + 20, 7, 3, 1)
    drawfillbox (shipX + 27, shipY + 2, shipX + 50, shipY + 4, 23)
    drawfillbox (shipX + 25, shipY, shipX + 27, shipY + 5, 23)
end DrawShip

proc Shoot
    for i : 1 .. upper (hold)
        if hold (i) = 1 then
            laserX (i) += dif * 3
            drawfillbox (laserX (i) + 51, laserY (i) + 2, laserX (i) + 75, laserY (i) + 4, 1)
            if laserX (i) > maxx then   % If its greater than the screen then reset it
                hold (i) := 0
            end if
        end if
    end for
end Shoot

var rock : array 1 .. 100 of
    record
        x, y, size, spd, dx : int
    end record
for i : 1 .. upper (rock) %The amount in array (which is 100)
    rock (i).x := Rand.Int (maxx, maxx + 400)
    rock (i).y := Rand.Int (0, maxy)
    rock (i).size := Rand.Int (10, 20)
    rock (i).spd := Rand.Int (1, 3)
end for

proc asteroids
    % Make move
    for i : 1 .. rocks div 2
        rock (i).x -= rock (i).spd
        drawfilloval (rock (i).x, rock (i).y, rock (i).size, rock (i).size, 43)
        drawoval (rock (i).x, rock (i).y, rock (i).size, rock (i).size, 42) %For effect
        if rock (i).x  dif then
        shipX -= dif
    elsif key (KEY_RIGHT_ARROW) then
        shipX += dif
    end if
    if key (KEY_UP_ARROW) then
        shipY += dif
    elsif key (KEY_DOWN_ARROW) and shipY > 30 then
        shipY -= dif
    end if
    if key (KEY_TAB) and done = 0 then % If we're allowed to shoot another laser
        shoots
    end if
    if done = 1 and laserwait < 20 then % Waiting untill laserwait is 20
        laserwait += 1 % This will make a delay of 

-----------------------------------
Flashkicks
Wed May 18, 2005 7:55 am


-----------------------------------
Hay man!!..  I got the whole asteroids thing werking and I guess I shoudla told you that yesterday already bcuz I had it werking near the end of class- not sure if its as efficient as yours though..lol..  but anyways, I really like the background idea so I will throw that in mine..  Im werking on the collision detection right now and its going good, Im just making a life gauge and its giving me hassles..lol..  I'll let you know how it turns out..  TTY soon..
~Flashkicks

:: UPDATE ::
Okay.. The life gauge is all set and its kinda nifty..  It disappears when its not being used..lol..  But anyways.. Okay, not the asteroids. I made a lil procedure to check for collision with a laser and the rock.  This is what I've got;
proc RockHit
    for i : 1 .. upper (rock)
        if laserX (i) + 24 >= rock (i).x - 10 and laserY (i) > rock (i).y - 10 and laserY (i) < rock (i).y + 10 then
            drawfilloval (rock (i).x, rock (i).y, rock (i).size, rock (i).size, 14) % Eventually it'll explode
            drawfilloval (maxx div 2, maxy div 2, 200, 200, 12) % This is just to check if the rock is hit or not
        end if
    end for
end RockHit

It works maybe 40% of the time..  Any ideas Why it only werks so seldom??..
NOTE:  the red oval in the middle is not part of the game, its just my way of checking if a rock is hit.. you know..

-----------------------------------
jamonathin
Wed May 18, 2005 11:23 am


-----------------------------------
This is the method that I use for collision with lasers.

- I Start off with a for loop running every rock
- Then I run a for loop inside that running for every laser shot
- Then I run a for loop inside That, checking the length of the laser

And what the third for loop does is it checks every pixel on that laser, and as a result, if any point on it touches anything you dont want it to, it'll know.

This method's very efficient.  Actually last night I was playing some Intellevision games on my PS2 and I got addicted to Astrosmash! and decided to make it.  I dont know when I'll be submitting it, I'm gonnan be busy in the next few weeks, but I'm actually almost done, I only need all of those special features that the actual game has . . .:think:  But I'm trying to make it exactly like the real game.

Anyways, here's your code that you should use.

proc RockHit
    for i : 1 .. upper (rock) %Checking Every Rock
        for x : 1 .. lasers %Checking Every Laser / Not sure which variable you used (max lasers)
            for q : 0 .. 24 %Checking Ever Point In Every Laser
                if laserY (x) >= rock (i).y - 10 and laserY = rock (i).x - 10 and laserX (x) + q  dif then
            eraseShip
            shipX -= dif
        elsif key (KEY_RIGHT_ARROW) then
            eraseShip
            shipX += dif
        end if
        if key (KEY_UP_ARROW) then
            eraseShip
            shipY += dif
        elsif key (KEY_DOWN_ARROW) and shipY > 30 then
            eraseShip
            shipY -= dif
        end if
        if key (KEY_TAB) and done = 0 then % If we're allowed to shoot another laser
            shoots
        end if
        if done = 1 and laserwait < 20 then % Waiting untill laserwait is 20
            laserwait += 1 % This will make a delay of [20 * (whatever delay is set)] before shooting again
        elsif done = 1 and laserwait >= 20 then % Now its ok to shoot, so reset laserwait
            laserwait := 0
            done := 0
        end if
        if shipX = maxx - 40 then
            shipX := maxx - 40
        end if
        if shipY >= maxy - 30 then
            shipY := maxy - 30
        end if
        DrawShipAndShoot         % Draw everything
        if death = true then % Once you die, the game is over.
            exit
        end if
        if count = 10 then
            ReAssignValues
            % delay (1000)
            NextLevel
            exit
        end if
    end loop
end loop


Also, you will notice my "Levels" isnt very good either..  It only shows on screen for like a split second. :( I cant get that to werk nicely either..  Anyways..  Im sure you know where to look and you understand what does what..  Im gonna keep trying to get my levels to look a lil better here :roll: lol...  TTYL
~Flashkicks

-----------------------------------
jamonathin
Mon May 30, 2005 8:17 am


-----------------------------------
Your View.Update was in the wrong spot.  View.Update must go before an delay.

proc NextLevel
    cls
    drawfillbox (0, 0, maxx, maxy, 7)
    Font.Draw ("Next Level", 40, 400, fig, 28)
    View.Update
    delay (2000)
    count := 0
end NextLevel

Also, use >= rather than =, it's more accurate, because you could be on 9 and hit 2 at the same time (juss happened to me)

if count >= 10 then
            ReAssignValues
            % delay (1000)
            NextLevel
            exit
        end if


Other than that I dont see any other errors, just make your levels better, and reset the asteroids to maxx.  There should be more asteroids per level.  All you ahve to do is add 1 to a variable every time you use the nextlevel proc.  Then change how many asteroids move accordingly.  You sould also have to shoot down more than 10 asteroids.

-----------------------------------
Flashkicks
Mon May 30, 2005 8:55 am


-----------------------------------
Haha...  Silly little errors..  I hate those.. Maybe Im too unfocused and Im not conentrating enough..  Im trying to make my final project at the same time and not just that- but the 'boss' for my Asteroids game as well..lol.. *phew*..  But thanks for that..  But now Im still stuck on the stupid non-depleting missiles...lol... *gRRRRrrr*
~Flashkicks

-----------------------------------
jamonathin
Mon May 30, 2005 1:40 pm


-----------------------------------
Your "hold" variable tells the program if that laser can be shot, so just add a "hold (x) := 0" into your proc, like this:


roc RockHit
    for i : 1 .. upper (rock)     % Checking Every Rock
        for x : 1 .. upper (hold)     % Checking Every Laser
            for q : 0 .. 24     % Checking Ever Point In Every Laser
                if laserY (x) >= rock (i).y - 15 and laserY (x) = rock (i).x - 10 and laserX (x) + q 