Hi,
I created a simple game in DarkBasic Pro, but there are some things that I want to do but I cannot work out how to do them. It is an asteroid game, central ship, missiles fire out of ship, ateroids are destroyed when missiles hit the asteroids.
These are the things that I want to do:
1. I want to add a counter! When an asteroid is detroyed, it should increase by one point each time. 1 points, 2 points, 3 points, etc should displayed in the top right hand corner of the screen.
2. My missile is in the wrong place! How can I make it come from the end point of the ship? I set the position but it didn't work!
3. I want to add different levels! (started this in non-working version, but couldn't get it to work!) Level one should be speed 0.5, level two 1.0 and level three 1.5.
4. I want to add a menu! In my non-working version I've actually done this but I cannot get it to work (kept the code in there). Pressing 1 should start the game on level one, pressing 2 should start the game on level two and pressing 3 should start the game on level 3. Pressing 4 should make a help menu come up and pressing 5 should make the game exit.
5. If an asteroid hits a ship, then a 'game over' message should come up, and it should return to the main menu.
6. After all asteroids have been destroyed it should go back to the main menu.
Please be as informative as possible when posting, I am an absoulte noob to all of this! If someone could do these for me, get it working and then post comments in the relevent areas so that I actually understand what is going on then that would be good also, and probably easier since otherwise its going to take ages for me to work it all out!
Working version:
REM ***** Main Source File *****
REM
#CONSTANT SHIP 1
#CONSTANT FIRSTMISSILE 101
#CONSTANT ASTEROID 51
#CONSTANT SPACE 9
REM *** CONSTANT IS SOMETHING THAT STAYS THE SAME THROUGHOUT THE PROGRAM - THE MAIN VALUE CHANGES EVERY OTHER VALUE WHEN IT IS REFFERED TO***
GLOBAL KEYPRESSED AS BYTE
GLOBAL ANGLE AS INTEGER
GLOBAL LASTFIRED AS INTEGER
GLOBAL MISSILENUMBER AS INTEGER
GLOBAL DIM MISSILEMOVES(9)
REM *** GLOBAL MEANS CAN BE SEEN BY ANY FUNCTION THROUGHOUT THE PROGRAM - NOT JUST ONE ***
INITIALISEGAME()
DO
HANDLEKEYBOARD()
HANDLESHIP()
HANDLEMISSILES()
HANDLEASTEROIDS()
LOOP
WAIT KEY
END
FUNCTION HANDLEKEYBOARD()
KEYPRESSED=0
IF KEYSTATE(44)=1
REM *** 44 IS THE VALUE OF Z - IF IT IS EQUAL TO 1 THEN IT HAS BEEN PRESSED ***
KEYPRESSED=KEYPRESSED||%001
ENDIF
REM *** BINARY HAS TO BE USED SO THAT ZERO IS NOT RETURNED ***
IF KEYSTATE(45)=1
KEYPRESSED=KEYPRESSED||%010
ENDIF
IF KEYSTATE(57)=1
KEYPRESSED=KEYPRESSED||%100
ENDIF
ENDFUNCTION KEYPRESSED
REM *** SENDS VALUE BACK TO PROGRAM FROM FUNCTION - IN THIS CASE KEYPRESSED - HOWEVER ONLY ONE THING CAN BE PASSED BACK***
REM *** THE Z, X AND SPACE BAR ARE CONVERTED INTO THE BINARY SPECIFIED IN THIS FUNCTION***
FUNCTION HANDLESHIP()
PASTE IMAGE 9,0,0
IF (KEYPRESSED && %001) > 0
ANGLE = WRAPVALUE(ANGLE-5);
ENDIF
IF (KEYPRESSED && %010) > 0
ANGLE = WRAPVALUE(ANGLE+5);
ENDIF
IF (KEYPRESSED && %100) > 0 AND TIMER() - LASTFIRED > 1000
REM *** MAKES SURE THAT THERE IS A SECOND IN BETWEEN THE FIRING OF THE MISSILES ***
LAUNCHMISSILE()
ENDIF
ROTATE SPRITE SHIP, ANGLE
REM *** BOTH CONDITIONS HAVE TO BE TRUE FOR IF STATMENT TO WORK ***
REM *** BOTH HAVE TO BE MORE THAN ZERO, ONE AND TWO FOR THE PRINT OUTCOME TO OCCUR ***
REM *** WRAPVALUE TAKES AN ANGLE AND RETURNS ITS VALUE OF BETWEEN 0' AND 360 ***
REM *** BECAUSE CONTINUOUS KEYBOARD VALUES ARE BEING USED, THE SHIP WILL CONTINUOUSLY ROTATE WHEN Z OR X IS PRESSED ***
ENDFUNCTION
FUNCTION INITIALISEGAME()
SET DISPLAY MODE 1024,768,32
INK 1, 1
REM *** THE SCREEN DISPLAY IN PIXELS IS SET HERE ***
LOAD IMAGE "background.PNG", 9
LOAD IMAGE "ship.PNG", 2
REM *** THIS COMMAND LOADS THE SHIP IMAGE ***
SPRITE SHIP, SCREEN WIDTH()/2, SCREEN HEIGHT()/2, 2
OFFSET SPRITE SHIP, SPRITE WIDTH(SHIP)/2, SPRITE HEIGHT(SHIP)/2
REM *** SETS THE IMAGE TO CENTRE FROM THE MIDDLE OF THE IMAGE, RATHER THAN THE TOP LEFT ***
LASTFIRE=TIMER()
REM *** THIS SETS HOW MANY MISSILES CAN BE FIRED PER SECOND - TAKES VARIABLES FROM HANDLESHIP FUNCTION ***
LOAD IMAGE "MISSILE.BMP",3
MISSILENUMBER=FIRSTMISSILE
FOR COUNT = 0 TO 9
MISSILEMOVES(COUNT)=0
NEXT COUNT
CREATEASTEROID()
STARTPOSITIONFORASTEROIDS()
ENDFUNCTION
FUNCTION LAUNCHMISSILE()
IF SPRITE EXIST(MISSILENUMBER)
EXITFUNCTION
ENDIF
REM *** THIS IS USED BECAUSE WE DO NOT WANT TO USE A NUMBER THAT HAS ALREADY BEEN USED - SEE LAST LINE OF CODE IN THIS FUNCTION ***
REM *** PRINT "FIRE" ***
SPRITE MISSILENUMBER, SPRITE X(SHIP), SPRITE Y(SHIP),3
OFFSET SPRITE MISSILENUMBER, SPRITE WIDTH(MISSILENUMBER)/2, SPRITE HEIGHT(MISSILENUMBER)/2
REM *** MOVES CO-ORDINATES FROM TOP LEFT OF SPRITE TO MIDDLE OF SPRITE ***
ROTATE SPRITE MISSILENUMBER, SPRITE ANGLE(SHIP)
REM *** MAKES SURE THAT IT ROTATES WITH THE SPACESHIP ***
MOVE SPRITE MISSILENUMBER, 30
REM *** MOVES MISSILE BY 30 PIXELS ***
REM INC MISSILENUMBER
LASTFIRED = TIMER()
MISSILENUMBER=MISSILENUMBER MOD 10 + FIRSTMISSILE
REM *** DIV GIVES THE WHOLE NUMBER, MOD GIVES THE REMAINDER ***
REM *** MAKES IT SO NUMBERS (MISSILES) CAN ONLY BE USED 10 TIMES. HOWEVER, ONCE THE MISSILE HAS GONE OF THE SCREEN IT CAN BE RE-USED ***
ENDFUNCTION
FUNCTION HANDLEMISSILES()
FOR SPRITENUMBER=FIRSTMISSILE TO FIRSTMISSILE + 9
IF SPRITE EXIST(SPRITENUMBER)
MOVE SPRITE SPRITENUMBER,15
REM *** THIS LINE SAYS THAT IF THE SPRITE EXISTS, THEN IT IS GOING TO BE MOVED BY 15 PIXELS EACH TIME ***
SPRITEHIT = SPRITE HIT(SPRITENUMBER, 0)
REM *** USED TO DETERMINE WHETHER ONE SPRITE HAS HIT ANOTHER ***
IF SPRITEHIT >1
REM *** IF SPRITE HIT IS ONE IT WILL DELETE SPIRTEHIT ***
DELETE SPRITE SPRITEHIT
DELETE SPRITE SPRITENUMBER
POST = SPRITENUMBER - FIRSTMISSILE
MISSILEMOVES(POST)=0
ELSE
POST = SPRITENUMBER - FIRSTMISSILE
INC MISSILEMOVES(POST)
IF MISSILEMOVES(POST)>=40
DELETE SPRITE (SPRITENUMBER)
MISSILEMOVES(POST)=0
ENDIF
REM *** POST IS JUST A VARIABLE CREATED ***
REM *** THIS SAYS THAT WHEN THE MISSILE IS FIRED, THE SPRITE WILL BE DELETED WHEN IT MOVES 40 TIMES THE PREVIOUSLY SPECIFIED 15 PIXELS. AKA - 40*15 WHICH EQUILS 600 ***
REM *** WHEN THE MISSILE HAS MOVED 600 PIXLES, AND OVER THE END OF THE SCREEN, IT WILL BE DELETED. THIS ALLOWS THE USER TO THEN RE-FIRE A MISSILE ONCE IT HAS DISSAPEARED OF THE SCREEN ***
ENDIF
ENDIF
NEXT SPRITENUMBER
ENDFUNCTION
REM *** AN ARRAY OCCURS IN ALL LANGUAGES NOT JUST DB - IT IS A DATATYPE CAPABLE OF HOLDING MORE THAN ONE VALUE ***
function createasteroid()
Create animated sprite asteroid, "asteroid.jpg",4,4,1
REM *** CALLS THE ASTEROID SPRITE ***
sprite asteroid, 640,500,1
offset sprite asteroid, sprite width(asteroid)/2, sprite height(asteroid)/2
randomize timer()
REM *** RANDOMIZES THE ASTEROID SPIRTE - TIMER ACTS LIKE A SEED***
for spriteno=asteroid+1 to asteroid+9
clone sprite asteroid, spriteno
REM *** CLONES THE CONSTANT ASTEROID***
next spriteno
endfunction
function startpositionforasteroids()
REM *** BELOW SETS THE STARTING POSITIONS FOR THE ASTEROID SPRITES ***
for spriteno=asteroid to asteroid+9
side=rnd(3)
select side
case 0
x=rnd(screen width())
y=0
angle=rnd(180)+90
endcase
case 1
x=screen width()
y=rnd(screen height())
angle=rnd(180)+180
endcase
case 2
x=rnd(screen width())
y=screen height()
angle=rnd(180)+270
endcase
case 3
x=0
y=rnd(screen height())
angle=rnd(180)
endcase
endselect
rotate sprite spriteno,angle
REM *** MAKES THE SPRITE ROTATE ***
sprite spriteno,x,y,1
next spriteno
endfunction
function handleasteroids()
for spriteno = asteroid to asteroid+9
IF SPRITE EXIST(SPRITENO)
REM *** CALLS ASTEROIDS INCASE THEY HAVE ALL BEEN DESTROID ***
move sprite spriteno,2.0
REM *** SETS SPEED OF MOVING SPRITE ***
if sprite Y(spriteno) <0
sprite spriteno,sprite X(spriteno), screen height(),1
endif
if sprite y(spriteno)> screen height()
sprite spriteno, sprite x(spriteno),0,1
endif
if sprite x(spriteno)<0
sprite spriteno, screen width(), sprite y(spriteno),1
endif
if sprite x(spriteno)>screen width ()
sprite spriteno,0,sprite y(spriteno),1
endif
REM *** ABOVE WRAPS THE SPIRES AROUND THE SCREEN - WHEN ONE DISSAPEARS ANOTHER ENTERS***
play sprite spriteno,1,16,100
ENDIF
next spriteno
endfunction
www.lizardinternet.com/WORKING.zip
Non-working version:
REM ***** Main Source File *****
REM
#CONSTANT SHIP 1
#CONSTANT FIRSTMISSILE 101
#CONSTANT ASTEROID 51
REM *** CONSTANT IS SOMETHING THAT STAYS THE SAME THROUGHOUT THE PROGRAM - THE MAIN VALUE CHANGES EVERY OTHER VALUE WHEN IT IS REFFERED TO***
GLOBAL KEYPRESSED AS BYTE
GLOBAL ANGLE AS INTEGER
GLOBAL LASTFIRED AS INTEGER
GLOBAL MISSILENUMBER AS INTEGER
GLOBAL DIM MISSILEMOVES(9)
REM *** GLOBAL MEANS CAN BE SEEN BY ANY FUNCTION THROUGHOUT THE PROGRAM - NOT JUST ONE ***
valinput = menu()
if valinput = 1
INITIALISEGAME()
DO
HANDLEKEYBOARD()
HANDLESHIP()
HANDLEMISSILES()
HANDLEASTEROIDS()
if valinput = 2
INITIALISEGAME()
DO
HANDLEKEYBOARD()
HANDLESHIP()
HANDLEMISSILES()
HANDLEASTEROIDS2()
if valinput = 3
INITIALISEGAME()
DO
HANDLEKEYBOARD()
HANDLESHIP()
HANDLEMISSILES()
HANDLEASTEROIDS3()
LOOP
ENDIF
REM *** DETERMINING WHETHER TO EXIT PROGRAM, GO TO HELP MENU OR START PROGRAM DEPENDING ON USER CHOICE ***
if valinput = 4
help()
endif
if valinput = 5
end
endif
until valinput = 5
WAIT KEY
END
FUNCTION HANDLEKEYBOARD()
KEYPRESSED=0
IF KEYSTATE(44)=1
REM *** 44 IS THE VALUE OF Z - IF IT IS EQUAL TO 1 THEN IT HAS BEEN PRESSED ***
KEYPRESSED=KEYPRESSED||%001
ENDIF
REM *** BINARY HAS TO BE USED SO THAT ZERO IS NOT RETURNED ***
IF KEYSTATE(45)=1
KEYPRESSED=KEYPRESSED||%010
ENDIF
IF KEYSTATE(57)=1
KEYPRESSED=KEYPRESSED||%100
ENDIF
ENDFUNCTION KEYPRESSED
REM *** SENDS VALUE BACK TO PROGRAM FROM FUNCTION - IN THIS CASE KEYPRESSED - HOWEVER ONLY ONE THING CAN BE PASSED BACK***
REM *** THE Z, X AND SPACE BAR ARE CONVERTED INTO THE BINARY SPECIFIED IN THIS FUNCTION***
FUNCTION HANDLESHIP()
IF (KEYPRESSED && %001) > 0
ANGLE = WRAPVALUE(ANGLE-5);
ENDIF
IF (KEYPRESSED && %010) > 0
ANGLE = WRAPVALUE(ANGLE+5);
ENDIF
IF (KEYPRESSED && %100) > 0 AND TIMER() - LASTFIRED > 500
REM *** MAKES SURE THAT THERE IS A SECOND IN BETWEEN THE FIRING OF THE MISSILES ***
LAUNCHMISSILE()
ENDIF
ROTATE SPRITE SHIP, ANGLE
REM *** BOTH CONDITIONS HAVE TO BE TRUE FOR IF STATMENT TO WORK ***
REM *** BOTH HAVE TO BE MORE THAN ZERO, ONE AND TWO FOR THE PRINT OUTCOME TO OCCUR ***
REM *** WRAPVALUE TAKES AN ANGLE AND RETURNS ITS VALUE OF BETWEEN 0' AND 360 ***
REM *** BECAUSE CONTINUOUS KEYBOARD VALUES ARE BEING USED, THE SHIP WILL CONTINUOUSLY ROTATE WHEN Z OR X IS PRESSED ***
ENDFUNCTION
FUNCTION INITIALISEGAME()
SET DISPLAY MODE 1024,768,32
REM *** THE SCREEN DISPLAY IN PIXELS IS SET HERE ***
COLOR BACKDROP 1
LOAD IMAGE "SHIP.JPG", 2
REM *** THIS COMMAND LOADS THE SHIP IMAGE ***
SPRITE SHIP, SCREEN WIDTH()/2, SCREEN HEIGHT()/2, 2
OFFSET SPRITE SHIP, SPRITE WIDTH(SHIP)/2, SPRITE HEIGHT(SHIP)/2
REM *** SETS THE IMAGE TO CENTRE FROM THE MIDDLE OF THE IMAGE, RATHER THAN THE TOP LEFT ***
LASTFIRE=TIMER()
REM *** THIS SETS HOW MANY MISSILES CAN BE FIRED PER SECOND - TAKES VARIABLES FROM HANDLESHIP FUNCTION ***
LOAD IMAGE "MISSILE.BMP",3
MISSILENUMBER=FIRSTMISSILE
FOR COUNT = 0 TO 9
MISSILEMOVES(COUNT)=0
NEXT COUNT
CREATEASTEROID()
STARTPOSITIONFORASTEROIDS()
ENDFUNCTION
FUNCTION LAUNCHMISSILE()
IF SPRITE EXIST(MISSILENUMBER)
EXITFUNCTION
ENDIF
REM *** THIS IS USED BECAUSE WE DO NOT WANT TO USE A NUMBER THAT HAS ALREADY BEEN USED - SEE LAST LINE OF CODE IN THIS FUNCTION ***
REM *** PRINT "FIRE" ***
SPRITE MISSILENUMBER, SPRITE X(SHIP), SPRITE Y(SHIP),3
OFFSET SPRITE MISSILENUMBER, SPRITE WIDTH(MISSILENUMBER)/2, SPRITE HEIGHT(MISSILENUMBER)/2
REM *** MOVES CO-ORDINATES FROM TOP LEFT OF SPRITE TO MIDDLE OF SPRITE ***
ROTATE SPRITE MISSILENUMBER, SPRITE ANGLE(SHIP)
REM *** MAKES SURE THAT IT ROTATES WITH THE SPACESHIP ***
MOVE SPRITE MISSILENUMBER, 30
REM *** MOVES MISSILE BY 30 PIXELS ***
REM INC MISSILENUMBER
LASTFIRED = TIMER()
MISSILENUMBER=MISSILENUMBER MOD 10 + FIRSTMISSILE
REM *** DIV GIVES THE WHOLE NUMBER, MOD GIVES THE REMAINDER ***
REM *** MAKES IT SO NUMBERS (MISSILES) CAN ONLY BE USED 10 TIMES. HOWEVER, ONCE THE MISSILE HAS GONE OF THE SCREEN IT CAN BE RE-USED ***
ENDFUNCTION
FUNCTION HANDLEMISSILES()
FOR SPRITENUMBER=FIRSTMISSILE TO FIRSTMISSILE + 9
IF SPRITE EXIST(SPRITENUMBER)
MOVE SPRITE SPRITENUMBER,15
REM *** THIS LINE SAYS THAT IF THE SPRITE EXISTS, THEN IT IS GOING TO BE MOVED BY 15 PIXELS EACH TIME ***
SPRITEHIT = SPRITE HIT(SPRITENUMBER, 0)
REM *** USED TO DETERMINE WHETHER ONE SPRITE HAS HIT ANOTHER ***
IF SPRITEHIT >1
REM *** IF SPRITE HIT IS ONE IT WILL DELETE SPIRTEHIT ***
DELETE SPRITE SPRITEHIT
DELETE SPRITE SPRITENUMBER
POST = SPRITENUMBER - FIRSTMISSILE
MISSILEMOVES(POST)=0
ELSE
POST = SPRITENUMBER - FIRSTMISSILE
INC MISSILEMOVES(POST)
IF MISSILEMOVES(POST)>=40
DELETE SPRITE (SPRITENUMBER)
MISSILEMOVES(POST)=0
ENDIF
REM *** POST IS JUST A VARIABLE CREATED ***
REM *** THIS SAYS THAT WHEN THE MISSILE IS FIRED, THE SPRITE WILL BE DELETED WHEN IT MOVES 40 TIMES THE PREVIOUSLY SPECIFIED 15 PIXELS. AKA - 40*15 WHICH EQUILS 600 ***
REM *** WHEN THE MISSILE HAS MOVED 600 PIXLES, AND OVER THE END OF THE SCREEN, IT WILL BE DELETED. THIS ALLOWS THE USER TO THEN RE-FIRE A MISSILE ONCE IT HAS DISSAPEARED OF THE SCREEN ***
ENDIF
ENDIF
NEXT SPRITENUMBER
ENDFUNCTION
REM *** AN ARRAY OCCURS IN ALL LANGUAGES NOT JUST DB - IT IS A DATATYPE CAPABLE OF HOLDING MORE THAN ONE VALUE ***
function createasteroid()
Create animated sprite asteroid, "asteroid.jpg",4,4,1
REM *** CALLS THE ASTEROID SPRITE ***
sprite asteroid, 640,500,1
offset sprite asteroid, sprite width(asteroid)/2, sprite height(asteroid)/2
randomize timer()
REM *** RANDOMIZES THE ASTEROID SPIRTE - TIMER ACTS LIKE A SEED***
for spriteno=asteroid+1 to asteroid+9
clone sprite asteroid, spriteno
REM *** CLONES THE CONSTANT ASTEROID***
next spriteno
endfunction
function startpositionforasteroids()
REM *** BELOW SETS THE STARTING POSITIONS FOR THE ASTEROID SPRITES ***
for spriteno=asteroid to asteroid+9
side=rnd(3)
select side
case 0
x=rnd(screen width())
y=0
angle=rnd(180)+90
endcase
case 1
x=screen width()
y=rnd(screen height())
angle=rnd(180)+180
endcase
case 2
x=rnd(screen width())
y=screen height()
angle=rnd(180)+270
endcase
case 3
x=0
y=rnd(screen height())
angle=rnd(180)
endcase
endselect
rotate sprite spriteno,angle
REM *** MAKES THE SPRITE ROTATE ***
sprite spriteno,x,y,1
next spriteno
endfunction
function handleasteroids()
for spriteno = asteroid to asteroid+9
IF SPRITE EXIST(SPRITENO)
REM *** CALLS ASTEROIDS INCASE THEY HAVE ALL BEEN DESTROID ***
move sprite spriteno,0.5
REM *** SETS SPEED OF MOVING SPRITE ***
if sprite Y(spriteno) <0
sprite spriteno,sprite X(spriteno), screen height(),1
endif
if sprite y(spriteno)> screen height()
sprite spriteno, sprite x(spriteno),0,1
endif
if sprite x(spriteno)<0
sprite spriteno, screen width(), sprite y(spriteno),1
endif
if sprite x(spriteno)>screen width ()
sprite spriteno,0,sprite y(spriteno),1
endif
REM *** ABOVE WRAPS THE SPIRES AROUND THE SCREEN - WHEN ONE DISSAPEARS ANOTHER ENTERS***
play sprite spriteno,1,16,100
ENDIF
next spriteno
endfunction
function handleasteroids2()
for spriteno = asteroid to asteroid+9
IF SPRITE EXIST(SPRITENO)
REM *** CALLS ASTEROIDS INCASE THEY HAVE ALL BEEN DESTROID ***
move sprite spriteno,1.0
REM *** SETS SPEED OF MOVING SPRITE ***
if sprite Y(spriteno) <0
sprite spriteno,sprite X(spriteno), screen height(),1
endif
if sprite y(spriteno)> screen height()
sprite spriteno, sprite x(spriteno),0,1
endif
if sprite x(spriteno)<0
sprite spriteno, screen width(), sprite y(spriteno),1
endif
if sprite x(spriteno)>screen width ()
sprite spriteno,0,sprite y(spriteno),1
endif
REM *** ABOVE WRAPS THE SPIRES AROUND THE SCREEN - WHEN ONE DISSAPEARS ANOTHER ENTERS***
play sprite spriteno,1,16,100
ENDIF
next spriteno
endfunction
function handleasteroids3()
for spriteno = asteroid to asteroid+9
IF SPRITE EXIST(SPRITENO)
REM *** CALLS ASTEROIDS INCASE THEY HAVE ALL BEEN DESTROID ***
move sprite spriteno,1.5
REM *** SETS SPEED OF MOVING SPRITE ***
if sprite Y(spriteno) <0
sprite spriteno,sprite X(spriteno), screen height(),1
endif
if sprite y(spriteno)> screen height()
sprite spriteno, sprite x(spriteno),0,1
endif
if sprite x(spriteno)<0
sprite spriteno, screen width(), sprite y(spriteno),1
endif
if sprite x(spriteno)>screen width ()
sprite spriteno,0,sprite y(spriteno),1
endif
REM *** ABOVE WRAPS THE SPIRES AROUND THE SCREEN - WHEN ONE DISSAPEARS ANOTHER ENTERS***
play sprite spriteno,1,16,100
ENDIF
next spriteno
endfunction
function menu()
REPEAT
CLS
SET CURSOR 260,200
REM *** SETTING POSITION OF CURSOR ON SCREEN ***
SET TEXT TO BOLD
SET TEXT FONT "ARIAL"
SET TEXT SIZE 30
INK RGB(0,255,0), 1
REM *** SETTING FOREGROUND COLOUR AND BACKGROUND COLOUR ***
PRINT "MENU"
SET CURSOR 260,230
SET TEXT SIZE 15
INK RGB(255,0,0),1
PRINT "1. START GAME - LEVEL ONE"
SET CURSOR 260,240
SET TEXT SIZE 15
INK RGB(0,0,255),1
PRINT "2. START GAME - LEVEL TWO"
SET CURSOR 260,250
SET TEXT SIZE 15
INK RGB(255,255,0),1
PRINT "3. START GAME - LEVEL THREE"
SET CURSOR 260,260
SET TEXT SIZE 15
INK RGB(255,255,255),1
PRINT "4. HELP"
SET CURSOR 260,270
SET TEXT SIZE 15
INK RGB(0,255,0),1
PRINT "5. EXIT"
REM *** INPUTS ARE VALIDATED HERE BY THE PROGRAM ***
SET CURSOR 260,290
INPUT "PLEASE CHOOSE A NUMBER ", INPUT$
LENINPUT = LEN (INPUT$)
REM *** LENINPUT is storing the length of the input. ***
VALINPUT = VAL (INPUT$)
REM *** VALINPUT stores the validated result of the input. ***
STRVALINPUT$ = STR$(VALINPUT)
REM *** STRVALINPUT$ converts the validated input back to a sting. ***
LENSTRVALINPUT = LEN(STRVALINPUT$)
REM *** Holds the length of the validated string. ***
IF LENSTRVALINPUT<>LENINPUT OR VALINPUT <1 OR VALINPUT >3
SET CURSOR 260,310
PRINT "ERROR"
WAIT KEY
ENDIF
UNTIL LENSTRVALINPUT = LENINPUT AND VALINPUT >0 AND VALINPUT <4
endfunction valinput
function help()
print "hello"
REM *** PRINTS USER HELP MENU ***
wait key
ENDFUNCTION
www.lizardinternet.com/NONWORKING.zip
Many thanks,
Simon.