ok thanks again grog, I got past that part but hit another snag,
I keep hitting a Function declaration mid-game ( when I press new game button on menu) and it exits me from the game, I know the problem but not how to fix it, I'll keep messing around with it until I get a reply
// Project: dodging game tut
// Created: Saturday, November 20, 2010
// ***** Main Source File ****
gosub settings // setup the game
gosub main_menu //start the main menu
// =============================================
// ======== M A I N M E N U ================
// =============================================
main_menu:
status = 0
//show the mouse
show mouse
repeat
SET TEXT TO ITALIC
cls
set text size 25
ink RGB(255,255,255),0
PASTE IMAGE 1,0,0
// little info about game shown on main menu
center TEXT (ScrWid / 2) + 60,(ScrHgt / 2) + 20,"Left & Right Arrow keys to move"
center TEXT (ScrWid / 2) + 60,(ScrHgt / 2) + 80,"Avoid the blocks for as long...."
center TEXT (ScrWid / 2) + 60,(ScrHgt / 2) + 110,"as possible!"
SET TEXT TO NORMAL
set text size 30
center text (ScrWid / 2) + 220,(ScrHgt / 2) + 260,"Created by Shadow-Legacy"
// =============== MAIN MENU BUTTONS ========================
SET TEXT TO NORMAL
set text size 45
//if button pressed goto newgame
if button((ScrWid / 2) - 250,50,"New Game")=1 then status = 1 : PlyrHlth = 50 : PlyScr = 0
//if button pressed then goto credits
if button((ScrWid / 2) - 250,120,"Credits")=1 then gosub Credits
//if button pressed exit game
If Button((ScrWid / 2) - 250,190,"Exit")=1 then gosub Finish
sync
until status = 1
return
// ============================================
// === S T A R T N E W G A M E ==========
// ============================================
maingame:
cls
HIDE MOUSE
set text size 40
gosub SetupGame
// MAIN GAME LOOP
DO
// setup text
INK RGB(70,255,0),RGB(0,0,0)
SET TEXT SIZE 40
TEXT 10,20,"PLAYER HEALTH: "+ STR$(PlyrHlth)
TEXT 10,60,"PLAYER SCORE: "+ STR$(PlyScr)
//centers mouse in center of screen
POSITION MOUSE SCREEN WIDTH()/2,SCREEN HEIGHT()/2
//positions camera in center of board
POSITION CAMERA 0,30,145
POINT CAMERA 0,10,95
//move player left
IF LEFTKEY()=1 AND OBJECT POSITION X(1)<34.5
MOVE OBJECT LEFT 1,1.3
ENDIF
//move player right
IF RIGHTKEY()=1 AND OBJECT POSITION X(1)>-34.5
MOVE OBJECT RIGHT 1,1.3
ENDIF
MOVE OBJECT 2,3
IF OBJECT POSITION Z(2)>145 AND PlyrHlth>0
POSITION OBJECT 2,RND(37.5),5,-90
PlyScr=PlyScr+10
ENDIF
MOVE OBJECT 3,3
IF OBJECT POSITION Z(3)>145 AND PlyrHlth>0
POSITION OBJECT 3,RND(37.5)*-1,5,-90
PlyScr=PlyScr+10
ENDIF
MOVE OBJECT 4,2.3
IF OBJECT POSITION Z(4)>145 AND PlyrHlth>0
POSITION OBJECT 4,RND(25),5,-95
PlyScr=PlyScr+10
ENDIF
MOVE OBJECT 5,3
IF OBJECT POSITION Z(5)>145 AND PlyrHlth>0
POSITION OBJECT 5,RND(25)*-1,5,-95
PlyScr=PlyScr+10
ENDIF
MOVE OBJECT 6,1.7
IF OBJECT POSITION Z(6)>145 AND PlyrHlth>0
POSITION OBJECT 6,RND(3),5,-95
PlyScr=PlyScr+10
ENDIF
MOVE OBJECT 7,3
IF OBJECT POSITION Z(7)>145 AND PlyrHlth>0
POSITION OBJECT 7,RND(25)*-1,5,-95
PlyScr=PlyScr+10
ENDIF
MOVE OBJECT 8,3.1
IF OBJECT POSITION Z(8)>145 AND PlyrHlth>0
POSITION OBJECT 8,RND(25),5,-95
PlyScr=PlyScr+10
ENDIF
for obj = 2 to 8
IF OBJECT COLLISION(1,obj) = 1
PlyrHlth=PlyrHlth-1
POSITION OBJECT obj,RND(37.5),5,-90
ENDIF
next obj
IF PlyrHlth <= 0
PlyrHlth=0
POSITION OBJECT 1,0,OBJECT POSITION Y(1)-1,0
TEXT (ScrWid / 2) - 100,(ScrHgt / 2),"GAME OVER"
TEXT (ScrWid / 2) - 100,(ScrHgt / 2) + 40,"YOUR SCORE IS: "+ STR$(PlyScr)
TEXT (ScrWid / 2) - 100,(ScrHgt / 2) + 80,"PRESS SPACE TO EXIT..."
TEXT (ScrWid / 2) - 100,(ScrHgt / 2) + 120,"TO MAIN MENU"
ENDIF
if spacekey()=1 then gosub main_menu : if status = 1 then gosub SetupGame
SYNC
LOOP
end
// ==========================================================
// ================= C R E D I T S ==========================
// ==========================================================
Credits:
cls 0
// deletes objects from last game (if any)
delete objects 1,9999
repeat
color backdrop 0
// because if game is played, but exitted before finish
// item are not removed properly + has a blue background
ink RGB(255,0,0),RGB(0,0,0)
PASTE IMAGE 1,0,0
SET TEXT SIZE 35
SET TEXT TO BOLD
center TEXT ScrWid / 2,(ScrHgt / 2) - 250,"Game Created By"
center TEXT ScrWid / 2,(ScrHgt / 2),"Thanks Goes To"
SET TEXT SIZE 28
SET TEXT TO ITALIC
center TEXT ScrWid / 2,(ScrHgt / 2) - 205,"Shaun Wilkinson AKA Shadow-Legacy"
center TEXT ScrWid / 2,(ScrHgt / 2) + 045,"Zaibatsu for tutorial"
center TEXT ScrWid / 2,(ScrHgt / 2) + 090,"Eminent, T4r4ntul4, Grog Grueslayer, and LBFN"
CENTER TEXT ScrWid / 2,(ScrHgt / 2) + 135,"for all the help"
set text size 30
ink RGB(255,255,255),0
center text ScrWid / 2,(ScrHgt / 2) + 250,"Press SPACE to exit credits."
sync
until spacekey() = 1
return
// =================================================================
// ============== S E T U P G A M E =============================
// =================================================================
SetupGame:
// deletes objects from last game (if any)
delete objects 1,9999
//makes the game board (floor)
MAKE OBJECT BOX 9999,75,5,300
COLOR OBJECT 9999,RGB(36,0,192)
//makes game wall
make object box 9998,5,15,400
color object 9998,RGB(18,0,128)
position object 9998,40,0,50
//makes game wall
make object box 9997,5,15,400
color object 9997,RGB(18,0,128)
position object 9997,-40,0,50
//makes the player (default square for now)
MAKE OBJECT BOX 1,5,15,5
COLOR OBJECT 1,RGB(255,255,255)
POSITION OBJECT 1,0,10,95
YROTATE OBJECT 1,180
// MAKES DODGING BLOCK
MAKE OBJECT BOX 2,4.5,4.5,20
COLOR OBJECT 2,RGB(87,255,128)
POSITION OBJECT 2,RND(37.5),5,-90
// MAKES DODGING BLOCK
MAKE OBJECT BOX 3,4.5,4.5,20
COLOR OBJECT 3,RGB(0,0,255)
POSITION OBJECT 3,RND(37.5)*-1,5,-90
// MAKES DODGING BLOCK
MAKE OBJECT BOX 4,18,4.5,4.5
COLOR OBJECT 4,RGB(255,0,255)
POSITION OBJECT 4,RND(20),5,-95
// MAKES DODGING BLOCK
MAKE OBJECT BOX 5,18,4.5,4.5
COLOR OBJECT 5,RGB(0,255,255)
POSITION OBJECT 5,RND(20)*-1,5,-95
// MAKES DODGING BLOCK
MAKE OBJECT BOX 6,30,4.5,4.5
COLOR OBJECT 6,RGB(255,66,0)
POSITION OBJECT 6,0,5,-95
// MAKES DODGING BLOCK
make object box 7,15,4.6,4.5
color object 7,RGB(255,0,128)
position object 7,rnd(20),5,-95
// MAKES DODGING BLOCK
make object box 8,15,4.6,4.5
color object 8,RGB(78,0,192)
position object 8,rnd(20)*-1,5,-95
// SETS UP COLLISION BETWEEN PLAYER AND DODGING BLOCKS
FOR X=1 TO 8
SET OBJECT COLLISION ON X
SET OBJECT COLLISION TO BOXES X
NEXT X
// A NICE POLISH (SETS SHADOWS FOR GAME ITEMS)
SET SHADOW LIGHT 0,100,100,100,1000
POSITION LIGHT 0,100,100,100
SET LIGHT RANGE 0,1000
FOR X=1 TO 8
SET SHADOW SHADING ON X,-1,200,1
NEXT X
// PLAYER HEALTH & SCORE VARIABLES
PlyrHlth=10
PlyScr=0
suspend for key
return
// =================================================================
// ==================== S E T T I N G S ============================
// =================================================================
settings:
SET WINDOW TITLE "Dodge Block"
SYNC ON
SYNC RATE 60
AUTOCAM OFF
SET GLOBAL SHADOWS ON
set display mode 800,600,32
set text font "papyrus"
ScrWid = screen width()
ScrHgt = screen height()
load image "pixie.bmp",1
load image "End Screen.bmp",2
music = rnd(1)+1
//set up music
LOAD MUSIC "a_california_morning.mp3",1
load music "venom.mp3",2
if music = 1
set music speed 1,200
loop music 1
set music volume 1,35
endif
if music = 2
set music speed 1,150
loop music 2
set music volume 2,35
endif
return
GameBoardClr:
rem cls 0
// deletes objects from last game (if any)
rem delete objects 1,9999
rem repeat
rem color backdrop 0
// because if game is played, but exitted before finish
// item are not removed properly + has a blue background
rem ink RGB(255,0,0),RGB(0,0,0)
rem PASTE IMAGE 1,0,0
rem SET TEXT SIZE 35
rem center TEXT ScrWid / 2,(ScrHgt / 2),"What gameboard do you want?"
rem set text size 20
rem center TEXT ScrWid / 2,(ScrHgt / 2) + 60,"Press 1 for dark, 2 for cheery, 3 for rainbow"
rem input color$
rem if color$ = 1 center TEXT ScrWid / 2,(ScrHgt / 2) +120,"DARK Board
rem if color$ = 2 center TEXT ScrWid / 2,(ScrHgt / 2) +120,"CHEERY Board
rem if color$ = 3 center TEXT ScrWid / 2,(ScrHgt / 2) +120,"RAINBOW Board
rem sync
rem until spacekey() = 1
rem return
Finish:
cls
color backdrop 0
delete objects 1,9999
delete image 1
paste image 2,0,0
if spacekey() = 1 then end
function Button(x1,y1,WORDS$) //button function
Pressed=0
x2=Text Width(WORDS$)
y2=Text Height(WORDS$)
if mousex()>x1 and mousex()<x1+x2
if mousey()>y1 and mousey()<y1+y2
Pressed=1
endif
endif
if pressed=1 then ink rgb(255,0,0),0 else ink rgb(255,255,255),0
if pressed=1
Pressed=Mouseclick()
else
pressed = 0
endif
text x1,y1,WORDS$
endfunction pressed
DBPro noob here
Skype = Shadow-Legacy