well i added some .wav files that @mrToad send me and added "fbsound1.1" bi file and lib files to the project and code now when the player moves forwards or backwards there is a sound of steps and in location 2 "outside - yard" you can hear a harp playing for 3 minutes...
still need some ideas about improving the movement of the player (changed navigation to "r" = right "l" = left "f" forwards "b" = backwards)
updated code"
file "main.bas"
Code: Select all
#INCLUDE "fbgfx.bi"
#INCLUDE ONCE "fbsound_dynamic.bi"
CONST AS SHORT scr_w = 800, scr_h = 600 ' screen constants
TYPE locations
AS STRING _location
AS FB.Image PTR _view(1 TO 4)
END TYPE
TYPE position
PRIVATE:
DIM AS locations map(1 TO 7)
AS STRING _direction(1 TO 4)
PUBLIC:
DECLARE CONSTRUCTOR()
DECLARE DESTRUCTOR()
DECLARE SUB display_screen(x AS INTEGER,z AS INTEGER)
DECLARE SUB main()
DECLARE SUB make_sound(f AS STRING, hWave AS INTEGER,t AS INTEGER)
END TYPE
CONSTRUCTOR position
DIM r AS STRING
FOR x AS INTEGER = 1 TO 4
READ r
_direction(x) = r
NEXT
FOR ii AS INTEGER = 1 TO 7
READ r
map(ii)._location = r
NEXT
FOR m AS INTEGER = 1 TO 7
FOR i AS INTEGER = 1 TO 4
map(m)._view(i) = IMAGECREATE(800, 600)
BLOAD("art\0" & m & "-" & i & ".bmp"), map(m)._view(i)
NEXT
NEXT
END CONSTRUCTOR
'directions data
DATA "north", "east", "south", "west"
''locations data
DATA "stable", "outside - yard", "yard", "yard road", "yard road", "up-stairs", "up-stairs"
DESTRUCTOR position
FOR y AS INTEGER = 1 TO 7
FOR i AS INTEGER = 1 TO 4
IMAGEDESTROY(map(y)._view(i))
NEXT
NEXT
END DESTRUCTOR
Sub centerPrint(row AS INTEGER, s AS STRING)
LOCATE row ,(LOWORD(width) - LEN(s)) Shr 1 : PRINT s
END SUB
SUB position.display_screen(x AS INTEGER, z AS INTEGER)
SCREENLOCK
PUT (0,0), map(x)._view(z), TRANS
centerprint 1, _direction(z)
CENTERPRINT 3, map(x)._location
SCREENUNLOCK
SLEEP 1
END SUB
SUB position.make_sound(f AS STRING, hWave AS INTEGER, t AS INTEGER)
fbs_Load_WAVFile(f , @hWave)
fbs_Play_Wave(hWave , t)
END SUB
SUB position.main()
DIM AS INTEGER harpWav, stepsWav, knockWav
DIM direc AS STRING
DIM z AS INTEGER = 1, x AS INTEGER = 1
'DIM AS boolean isenter = FALSE
DO
centerprint 15, "press any key to begin..."
SLEEP
DO
CLS
IF direc = "q" THEN
fbs_Destroy_Wave(@harpWav)
fbs_Destroy_Wave(@knockWav)
fbs_Destroy_Wave(@stepsWav)
END
ENDIF
display_screen(x,z)
IF x = 2 THEN
make_sound("sound\harp.wav" ,harpWav, 1)
ENDIF
'IF next_room = 1 ANDalso index = 4 ANDalso direc = "open door" THEN
' centerprint 16, "cell door open! you can exit the cell!"
' isenter = TRUE
'
'ELSEIF next_room = 1 ANDALSO index = 4 THEN
' centerprint 15, "type 'open door' to open door"
' isenter = FALSE
' IF direc = "f" then
' centerprint 14, "door closed you cannot move forwards"
' ENDIF
'ENDIF
'IF next_room = 3 ANDALSO index = 4 ANDALSO direc = "open door" THEN
' centerprint 16, "from the room an armed gurde come and stab you with a sward you die! - RIP"
'ELSEIF next_room = 3 ANDALSO index = 4 THEN
' centerprint 15, "should we try to forcely open this door? if so type 'open door'"
'ENDIF
'IF next_room = 4 ANDALSO index = 2 ANDALSO direc = "open gate" THEN
' centerprint 16, "you made it! you are free! out of the prison cell!"
' isenter = TRUE
'ELSEIF next_room = 4 ANDALSO index = 2 THEN
' centerprint 15, "shell we try to open this gate? type 'open gate'"
' isenter = FALSE
' IF direc = "f" THEN
' centerprint 14, "first we most open the gate!"
' ENDIF
'
'ENDIF
LOCATE 36, 1
INPUT "choose direction('r' = right, 'l' = left, 'f' = forward, 'b' = backwards) or an action or key 'q' to quit: ", direc
IF direc = "r" THEN z += 1
IF direc = "l" THEN z -= 1
IF direc = "f" THEN
x += 1
make_sound("sound\step_02.wav" ,stepsWav, 1)
ENDIF
IF direc = "b" THEN
x -= 1
make_sound("sound\step_02.wav" ,stepsWav, 1)
ENDIF
IF z < 1 THEN z = 4
IF z > 4 THEN z = 1
IF x < 1 THEN x = 1
IF x > 7 THEN x = 7
LOOP
LOOP UNTIL INKEY = CHR(27)
END SUB
IF fbs_Init()=false THEN
PRINT "error: FBS_INIT() " & FBS_Get_PlugError()
BEEP : SLEEP : END 1
END IF
SCREENRES scr_w, scr_h, 32
WIDTH scr_w \ 8, scr_h \ 16
DIM game AS position
game.main()
ron77