I have a problem with my terrain code, smehow before it worked and now it doesn't
It probably is a small mistake but thanks for any help
Here is code for a simple section of my code
sync on
backdrop on
autocam off
set camera range 0.5, 30000
hide mouse
set dir "media"
` movement
g_fSpeed# = 0.2
g_fTurn# = 0.3
` load base and detail texture
load image "texture.bmp", 1
load image "detail.tga", 2
MAKE OBJECT TERRAIN 1 ` create the terrain object
set terrain heightmap 1, "map.bmp" ` set the heightmap
set terrain scale 1, 3, 0.6, 3 ` set the scale
set terrain split 1, 16 ` split value by 16 * 16
set terrain tiling 1, 4 ` detail map tiling
set terrain light 1, 1, -0.25, 0, 1, 1, 0.78, 0.5 ` light - xdir, ydir, zdir, red, green, blue, intensity
set terrain texture 1, 1, 2 ` base and detail texture
build terrain 1 ` finally build the terrain
do
gosub userInput
` final screen update
sync
loop
userInput:
` simple mouse and keyboard movement
` move around with arrow keys
control camera using arrowkeys 0, g_fSpeed#, g_fTurn#
` store old camera angle
OldCamAngleY# = CameraAngleY#
OldCamAngleX# = CameraAngleX#
` store new camera angle
CameraAngleY# = wrapvalue ( CameraAngleY# + mousemovex ( ) * 0.4 )
CameraAngleX# = wrapvalue ( CameraAngleX# + mousemovey ( ) * 0.4 )
` rotate camera
yrotate camera curveangle ( CameraAngleY#, OldCamAngleY#, 24 )
xrotate camera curveangle ( CameraAngleX#, OldCamAngleX#, 24 )
return
And this is my full code
red as DWORD
blue as DWORD
white as DWORD
black as DWORD
red=rgb(255,0,0)
blue=rgb(0,0,255)
white=rgb(255,255,255)
black=rgb(0,0,0)
rem default text color
ink rgb(255,255,255),0
menu:
cls
rem menu background
box 20,20,620,460,black,black,black,red
rem game title
center text 320,100,"FPS ---- Alien Shooter"
ink rgb(0,0,0),0
repeat
if mouseclick()=0 then MOUSEOLD=0
if (((mousex() >= 100) and (mousex() <= 170)) and ((mousey() >=200) and (mousey() <=220))) then ink red,0 :text 100,200,"Play"
if (((mousex() <= 99) or (mousex() >= 169)) or ((mousey() <= 199) or (mousey() >= 219))) then ink rgb(255,255,255),0 :text 100,200,"Play"
if ((((mousex() >= 100) and (mousex() <= 170)) and ((mousey() >=200) and (mousey() <=220) and (mouseclick()=1) AND (MOUSEOLD=0)))) then MOUSEOLD=mouseclick() : goto start
if (((mousex() >= 100) and (mousex() <= 170)) and ((mousey() >=230) and (mousey() <=250))) then ink red,0 :text 100,230,"Controls"
if (((mousex() <= 99) or (mousex() >= 169)) or ((mousey() <= 229) or (mousey() >= 249))) then ink rgb(255,255,255),0 :text 100,230,"Controls"
if ((((mousex() >= 100) and (mousex() <= 170)) and ((mousey() >=230) and (mousey() <=250) and (mouseclick()=1) AND (MOUSEOLD=0)))) then MOUSEOLD=mouseclick() : goto controls
if (((mousex() >= 100) and (mousex() <= 170)) and ((mousey() >=260) and (mousey() <=280))) then ink red,0 :text 100,260,"Credits"
if (((mousex() <= 99) or (mousex() >= 169)) or ((mousey() <= 259) or (mousey() >= 279))) then ink rgb(255,255,255),0 :text 100,260,"Credits"
if ((((mousex() >= 100) and (mousex() <= 170)) and ((mousey() >=260) and (mousey() <=280) and (mouseclick()=1) AND (MOUSEOLD=0)))) then MOUSEOLD=mouseclick() : goto cred
if (((mousex() >= 100) and (mousex() <= 170)) and ((mousey() >=290) and (mousey() <=310))) then ink red,0 :text 100,290,"Exit"
if (((mousex() <= 99) or (mousex() >= 169)) or ((mousey() <= 289) or (mousey() >= 309))) then ink rgb(255,255,255),0 :text 100,290,"Exit"
if ((((mousex() >= 100) and (mousex() <= 170)) and ((mousey() >=290) and (mousey() <=310) and (mouseclick()=1) AND (MOUSEOLD=0)))) then MOUSEOLD=mouseclick() : end
until false
controls:
cls
rem menu background
box 20,20,620,460,black,black,black,red
ink rgb(0,255,0),0
print "-CONTROLS-"
print "To shoot with the pistol it is left mouseclick."
print "To shoot with the tommy it is right mouseclick."
print "To move you use the forward and backward arrow keys."
print "To look around move the mouse around."
print "To change to a pistol either press left mouseclick or left key"
print "To change to a tommy either press right mouseclick or right key"
print "BEWARE THIS IS NOT A BUG - when you shoot a couple of times it will stop."
print "This is just my way of reloading :-)"
print "press any key to go back to the menu"
wait key
goto menu
cred:
hide mouse
sync rate 0
sync on
set text font "Verdana"
set text size 25
sw = screen width()
sh = screen height()
max_lines = sh / 20
ink rgb(255,255,255),0
create bitmap 1,sw,sh
create bitmap 2,sw,sh
MakePage(1,max_lines,sw)
MakePage(2,max_lines,sw)
y1# = 480 : y2# = 960
speed# = 0.2
set current bitmap 0
` 3D stuff here
make object box 1,25,25,25
color object 1,rgb(0,0,100)
texture object 1,50
autocam off
color backdrop 0
set ambient light 25
do
paste image 1,0,y1#,1
paste image 2,0,y2#,1
dec y1#,speed#
dec y2#,speed#
if y1# <= -480
MakePage(1,max_lines,sw)
y1# = 480
endif
if y2# <= -480
MakePage(2,max_lines,sw)
y2# = 480
endif
xrotate object 1,wrapvalue(ox#*2)
yrotate object 1,wrapvalue(ox#)
zrotate object 1,wrapvalue(ox#)
inc ox#,0.5
sync
loop
` - DF Function --------------------------------------------------------
` This creates the next screen worth of text
` -------------------------------------------------------- DF Function -
function MakePage(b,max_lines,sw)
set current bitmap b
cls
y = 0
for a = 0 to max_lines
read temp$
ink rgb(10,10,10),0
center text sw/2,y,temp$
ink rgb(255,255,255),0
center text sw/2+1,y+1,temp$
inc y,20
next a
get image b,0,0,screen width(),screen height()
set current bitmap 0
` - DF Data ------------------------------------------------------------
` The actual data, terminate with an asterisk * on its own
` ------------------------------------------------------------ DF Data -
scrolltext:
data " "
data " "
data " "
data "Mrnaughty's"
data "FPS Game"
data " "
data "Alien Shooter"
data " "
data "Made by Darkbasic Professional"
data " "
data " "
data "Programmer - Scott"
data " "
data " "
data "Idea - Scott"
data " "
data "Collisions - Scott"
data " "
data "Menu - Scott"
data " "
data "Hope you will enjoy this game!"
data " "
data " "
data " "
data " "
data "And thank you for playing"
data ""
data "Alien shooter"
data "The FPS"
data " "
data " "
data " "
data " "
data "Press Esc to quit"
endfunction
start:
sync on
backdrop on
autocam off
set camera range 0.5, 30000
hide mouse
set dir "media"
load music "music.mp3",53
play music 53
loop music 53
load image "crosshair.bmp",8
sprite 1,280,210,8
load sound "loadclip.wav",3
load sound "treat.wav",5
load sound "mgun.wav",99
load sound "colt.wav",88
rem Load model for gun
load object "colt.x",9
lock object on 9
scale object 9,500,500,300
rotate object 9,0,0,0
position object 9,0.5,-1,2
disable object zdepth 9
`hide the object
hide object 9
rem Load model for gun
load object "tommy.x",7
lock object on 7
scale object 7,500,500,300
rotate object 7,0,0,0
position object 7,0.5,-1,2
disable object zdepth 7
`load alien model
load object "alien.x",76
scale object 76,4000,4000,4000
position object 76,350,0,500
make object sphere 8,1
position object 8,0,50,0
` movement
g_fSpeed# = 0.2
g_fTurn# = 0.3
` load base and detail texture
load image "texture.bmp", 1
load image "detail.tga", 2
MAKE OBJECT TERRAIN 1 ` create the terrain object
set terrain heightmap 1, "map.bmp" ` set the heightmap
set terrain scale 1, 3, 0.6, 3 ` set the scale
set terrain split 1, 16 ` split value by 16 * 16
set terrain tiling 1, 4 ` detail map tiling
set terrain light 1, 1, -0.25, 0, 1, 1, 0.78, 0.5 ` light - xdir, ydir, zdir, red, green, blue, intensity
set terrain texture 1, 1, 2 ` base and detail texture
build terrain 1 ` finally build the terrain
` load our skybox
load object "skybox2.x", 200
set object light 200, 0
set object texture 200, 3, 1
position object 200, 1000, 2000, 4000
scale object 200, 30000, 30000, 30000
set dir ".."
shoot#=0
` position the camera
position camera 385,23,100
` main program loop
do
` handle user input and show some stats
gosub userInput
`gosub information
`bring out gun
if leftkey() = 1
play sound 3
scale listener 0.1
show object 9
hide object 7
endif
`put away gun
if inkey$() = "n"
play sound 3
scale listener 0.1
hide object 9
hide object 7
endif
`bring out 2nd gun
if rightkey() = 1
play sound 3
scale listener 0.1
show object 7
hide object 9
endif
`shoot sound
if mouseclick()=1
show object 9
hide object 7
play sound 88
wait 100
endif
if mouseclick()=2
show object 7
hide object 9
play sound 99
wait 100
endif
`reloading
if mouseclick()=1 and mouseclick()=1 and mouseclick()=1 and mouseclick()=1 and mouseclick()=1
play sound 3
wait 1000
endif
if mouseclick()=2 and mouseclick()=2 and mouseclick()=2
wait 500
play sound 3
wait 1000
endif
if spacekey()=1 and shoot#=0
position object 8,camera position x(),camera position y(),camera position z()
set object to camera orientation 8
move object 8,7
shoot#=1
endif
if shoot#=0 then position object 8,0,50,0
if shoot#=1 then move object 8,2
if object collision(8,0)>0 then shoot#=0
`saving pics
if controlkey()=1
saveScreenShot("jpg")
endif
` get the height of the terrain at the current camera position
a# = get terrain ground height( 1, camera position x( ), camera position z( ) )
` now position the camera slightly above the terrain
position camera camera position x( ), a# + 3, camera position z()
` let the terrain handle some internal work
update terrain
` final screen update
sync
loop
userInput:
` simple mouse and keyboard movement
` move around with arrow keys
control camera using arrowkeys 0, g_fSpeed#, g_fTurn#
` store old camera angle
OldCamAngleY# = CameraAngleY#
OldCamAngleX# = CameraAngleX#
` store new camera angle
CameraAngleY# = wrapvalue ( CameraAngleY# + mousemovex ( ) * 0.4 )
CameraAngleX# = wrapvalue ( CameraAngleX# + mousemovey ( ) * 0.4 )
` rotate camera
yrotate camera curveangle ( CameraAngleY#, OldCamAngleY#, 24 )
xrotate camera curveangle ( CameraAngleX#, OldCamAngleX#, 24 )
return
Thanks again for any help
Nitrox is the new and improved me