Hello everyone
I used the tutorial code of Zaibatsu
http://forum.thegamecreators.com/?m=forum_view&t=153346&b=7and added a few extra functions (restart when you lose, pause and sound)
The sound is looping but when I pause the game it pause the sounds like I want it. But when I unpause the game it will resume it but it will stop looping it and I want to resume the sound where it has stopped and still keeping it looping
A second problem the happens is that after a while when running the game I get lag and my CPU usage will raise.
SET WINDOW TITLE "Dodging Game"
SET WINDOW OFF
SET DISPLAY MODE 1024,768,32
SYNC ON
SYNC RATE 60
HIDE MOUSE
AUTOCAM OFF
SET GLOBAL SHADOWS ON
LOAD SOUND "TETRISB.wav",1
LOOP SOUND 1
MAKE OBJECT BOX 9999,75,5,200
COLOR OBJECT 9999,RGB(180,150,90)
MAKE OBJECT BOX 1,5,15,5
COLOR OBJECT 1,RGB(0,200,150)
POSITION OBJECT 1,0,10,95
YROTATE OBJECT 1,180
MAKE OBJECT BOX 2,4.5,4.5,20
COLOR OBJECT 2,RGB(255,25,25)
POSITION OBJECT 2,RND(37.5),5,-90
MAKE OBJECT BOX 3,4.5,4.5,20
COLOR OBJECT 3,RGB(255,25,25)
POSITION OBJECT 3,RND(37.5)*-1,5,-90
MAKE OBJECT BOX 4,18,4.5,4.5
COLOR OBJECT 4,RGB(255,25,25)
POSITION OBJECT 4,RND(20),5,-95
MAKE OBJECT BOX 5,18,4.5,4.5
COLOR OBJECT 5,RGB(255,25,25)
POSITION OBJECT 5,RND(20)*-1,5,-95
MAKE OBJECT BOX 6,30,4.5,4.5
COLOR OBJECT 6,RGB(255,25,25)
POSITION OBJECT 6,0,5,-95
FOR X=1 TO 6
SET OBJECT COLLISION ON X
SET OBJECT COLLISION TO BOXES X
NEXT X
SET SHADOW LIGHT 0,100,100,100,1000
POSITION LIGHT 0,100,100,100
SET LIGHT RANGE 0,1000
FOR X=1 TO 6
SET SHADOW SHADING ON X,-1,200,1
NEXT X
PlyrHlth#=100
PlyrScr#=0
Pause=1
Highscore=0
DO
INK RGB(255,0,0),RGB(0,0,0)
SET TEXT SIZE 50
TEXT 10,20,"PLAYER HEALTH: "+ STR$(PlyrHlth#)
TEXT 10,60,"PLAYER SCORE: "+ STR$(PlyrScr#)
TEXT 680,20,"Highscore: "+ STR$(Highscore)
INK RGB(0,255,0),RGB(0,0,0)
CENTER TEXT 512,710,"PRESS P TO PAUSE"
POSITION CAMERA 0,30,145
POINT CAMERA 0,10,95
IF Pause=1
IF LEFTKEY()=1 AND OBJECT POSITION X(1)<34.5
MOVE OBJECT LEFT 1,0.5
ENDIF
IF RIGHTKEY()=1 AND OBJECT POSITION X(1)>-34.5
MOVE OBJECT RIGHT 1,0.5
ENDIF
MOVE OBJECT 2,1.8
IF OBJECT POSITION Z(2)>145 AND PlyrHlth#>0
POSITION OBJECT 2,RND(37.5),5,-90
PlyrScr#=PlyrScr#+1
ENDIF
MOVE OBJECT 3,1.4
IF OBJECT POSITION Z(3)>145 AND PlyrHlth#>0
POSITION OBJECT 3,RND(37.5)*-1,5,-90
PlyrScr#=PlyrScr#+1
ENDIF
MOVE OBJECT 4,1
IF OBJECT POSITION Z(4)>145 AND PlyrHlth#>0
POSITION OBJECT 4,RND(25),5,-95
PlyrScr#=PlyrScr#+1
ENDIF
MOVE OBJECT 5,1.2
IF OBJECT POSITION Z(5)>145 AND PlyrHlth#>0
POSITION OBJECT 5,RND(25)*-1,5,-95
PlyrScr#=PlyrScr#+1
ENDIF
MOVE OBJECT 6,.5
IF OBJECT POSITION Z(6)>145 AND PlyrHlth#>0
POSITION OBJECT 6,RND(3),5,-95
PlyrScr#=PlyrScr#+1
ENDIF
IF OBJECT COLLISION(1,2)=1
PlyrHlth#=PlyrHlth#-20
POSITION OBJECT 2,RND(37.5),5,-90
ENDIF
IF OBJECT COLLISION(1,3)=1
PlyrHlth#=PlyrHlth#-20
POSITION OBJECT 3,RND(37.5)*-1,5,-90
ENDIF
IF OBJECT COLLISION(1,4)=1
PlyrHlth#=PlyrHlth#-20
POSITION OBJECT 4,RND(25),5,-95
ENDIF
IF OBJECT COLLISION(1,5)=1
PlyrHlth#=PlyrHlth#-20
POSITION OBJECT 5,RND(25)*-1,5,-95
ENDIF
IF OBJECT COLLISION(1,6)=1
PlyrHlth#=PlyrHlth#-20
POSITION OBJECT 6,RND(3),5,-95
ENDIF
ENDIF
IF KEYSTATE(25)=1
IF Pause=1
Pause=0
PAUSE SOUND 1
WHILE KEYSTATE(25)=1
ENDWHILE
ELSE
Pause=1
RESUME SOUND 1
WHILE KEYSTATE(25)=1
ENDWHILE
ENDIF
ENDIF
IF PlyrHlth#<=0
STOP SOUND 1
HIDE OBJECT 1
POSITION OBJECT 1,0,OBJECT POSITION Y(1)-1,0
If PlyrScr#>Highscore
Highscore=PlyrScr#
ENDIF
INK RGB (255,0,0), RGB(0,0,0)
TEXT SCREEN WIDTH()/2-100,SCREEN HEIGHT()/2,"GAME OVER"
TEXT SCREEN WIDTH()/2-100,SCREEN HEIGHT()/2+40,"YOUR SCORE IS: "+ STR$(PlyrScr#)
TEXT SCREEN WIDTH()/2-100,SCREEN HEIGHT()/2+80,"PRESS ESCAPE TO EXIT"
TEXT SCREEN WIDTH()/2-100,SCREEN HEIGHT()/2+120,"PRESS ENTER TO RESTART"
IF KEYSTATE(28)=1
LOOP SOUND 1
SHOW OBJECT 1
POSITION OBJECT 1,0,10,95
POSITION OBJECT 2,RND(37.5),5,-90
POSITION OBJECT 3,RND(37.5)*-1,5,-90
POSITION OBJECT 4,RND(20),5,-95
POSITION OBJECT 5,RND(20)*-1,5,-95
POSITION OBJECT 6,0,5,-95
PlyrHlth#=100
PlyrScr#=0
Pause=1
ENDIF
ENDIF
SYNC
LOOP