Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Still can't get my game to run.

Author
Message
TogaMario
23
Years of Service
User Offline
Joined: 30th Jan 2003
Location:
Posted: 22nd Jun 2003 09:00
IT seems that everytime I run this, it'll go through loading the resources then it dies. Any suggestions to why?

set display mode 800,600,16
hide mouse

sync on
sync rate = 100
autocam off

GravWait# = 55

remstart
dim treeX(500) : rem xpos
dim treeZ(500) : rem zpos
dim treeS(500) : rem size
dim treeR(500) : rem range Calculation
dim treeUpdateFrequency() : rem Time Check
dim gameSpeed#() : rem Game Speed Sycnronisation Ledger
dim lastTime() : rem Game Speed Syncronisation Tracker
remend

print "Loading picture..."
sync
load image "TreeBark1.jpg",1
load image "GrassTex.jpg",2
load image "fire.jpg", 10
load image "sprites\HealthBarSymbol.bmp",100
load image "sprites\RedBar.bmp", 101
load image "sprites\ArmorSymbol.bmp", 102
load image "sprites\GreenBar.jpg", 103
load image "sprites\ManaSymbol.bmp", 104
load image "sprites\BlueBar.jpg", 105

print "Loading music..."
sync
load music "Helm.mp3",1

playerx#=400
playery#=10
playerz#=100

print "Loading objects..."
sync
` Load tree trunk
load object "trunk.x",1
` Load my player model (no animation)
load object "sam.x",10
` Load my test building (no collision)
load object "testbuilding.x", 1000
` Load my sword object, with swinging animation in first person mode
load object "FPHandAnim.x", 10000
` Load the floor collision plane
load object "floor.x", 2
` Load our building block
` load object "block.x", 3

make object box 3, 2.4, 14, 14

texture object 2, 10

set object frame 10, 1
set object frame 10000,1

set object collision on 2
set object collision to boxes 2
set object radius 2, .1

` Set up swinging sword
lock object on 10000
disable object zdepth 10000
scale object 10000, 400, 400, 600
position object 10000, 1, -1, 0
set object speed 10000, 50

` Particle test
MAKE PARTICLES 1, 10, 100, 50
position particles 1, 300, 0, 300
color particles 1, 255,20,0

` Scale my player model
scale object 10, 660, 660, 660

` Hide original tree, and make clones (because clone did not work)
hide object 1
make mesh from object 1,1

` Setup building
scale object 1000, 2000,2300,2000
rotate object 1000, 0, 150, 0

` Setup matrices for terrain simulation
make matrix 1, 300, 300, 10, 10

make matrix 2, 300, 300, 10, 10

position matrix 2, 300, 0, 0

randomize matrix 1, 5
prepare matrix texture 1,2,1,1
prepare matrix texture 2,2,1,1

` Set player collision on and to spheres
set object collision on 10
set object collision to spheres 10

` Create alllll those trees randomly placed and give collision boxes
for trees=11 to 500
make object trees,1,1
position object trees, rnd(200), 1, rnd(200)
treeY#=get ground height (1, object position x(trees), object position z(trees))
position object trees, object position x(trees), treeY#, object position z(trees)
scale object trees, 100, rnd(15)+100,100
rotate object trees, 0,rnd(300), 0
remstart
treesX(trees)=object position x(trees)
treesZ(trees)=object position z(trees)
remend
next trees

` Foggy until I can setup skybox
fog on
fog distance 250
fog color RGB(200,200,200)

backdrop on
color backdrop RGB(200,200,200)

set camera range 1,250

set ambient light 100

` loop through matrix tiles
for xTile=0 to 9
for zTile=0 to 9
`set the matrix tile texture
set matrix tile 1,xTile,zTile,1
next zTile
next xTile

update matrix 1

randomize matrix 2, 5

if matrix position x(2) >= 300 and matrix position z(2) = 0
position matrix 2, 300, 0, 0
for points = 0 to 10
terrainY# = get matrix height (1, 10, points)
set matrix height 2, 0, points, terrainY#
next points
endif

for xTile2=0 to 9
for zTile2=0 to 9
`set the matrix tile texture
set matrix tile 2,xTile2,zTile2,1
next zTile2
next xTile2

update matrix 2

` Place player's start
position object 10, playerx#,playery#,playerz#

` Texture my trees
texture object 1,1

` Store player object info
xPos#=10
yPos#=5
zPos#=10
xAng#=0
yAng#=0
zAng#=0
playerXang#=0
playerYang#=0
playerZang#=0

` Camera Mode - First Person
CameraMode=0

hold = 0

` loop music 1

` Gravity variables
yVel#=0
g#=.2

` Floor collision test that isn't working right now
floorcoll#=0

` Getting worldheight and setting up building
cY# = worldheight(camera position x(), camera position y(), camera position z(), 1, 2, 300, 300)+4

buildingY# = worldheight(object position x(1000), object position y(1000), object position z(1000), 1, 2, 300, 300)+.5
position object 1000, 390, buildingY#, 150

` Set player collision radius to 1.5
set object radius 10, 1.2

position object 2, 390, buildingY#, 150
rotate object 2, 0, object angle y(1000), 0
scale object 2, 800,780,800
hide object 2


` Set up HUD
sprite 1, 5, 5, 100
sprite 2, 40, 17, 101
sprite 3, 5, 35, 102
sprite 4, 40, 47, 103
sprite 5, 6, 65, 104
sprite 6, 40, 77, 105

` Store HUD variables
HealthPercent# = 100.0
ManaPercent# = 100.0
ArmorPercent# = 100.0

rem Mainloop
`gameSpeed()

set object collision on 3
set object radius 3, 0

remstart wall test-----------------------------------
position object 3, 397.5, buildingY#+11, 154.5
rotate object 3, 0, object angle y(1000), 0
sx#=object size x(3)/2
sy#=object size y(3)/2
sz#=object size z(3)/2
make object collision box 3,-1*sx#,-1*sy#,-1*sz#,sx#,sy#,sz#,1
Remend

rem ****************Camera Loop************

do

fps = screen fps()
set cursor 600,10
print fps

` Take care of HUD
if HealthPercent# GravWait#
yvel#=yvel#-g#
REM make gravity affect the motion
OldTime = Timer()
endif

if y# = worldheight(camera position x(), camera position y(), camera position z(), 1, 2, 300, 300)+25
cY# = worldheight(camera position x(), camera position y(), camera position z(), 1, 2, 300, 300)+25
endif

Position Camera cX#,cY#,cZ#
Point camera SphereX#,Y#,SphereZ#
endif
remstart
treeUpdateFrequency()=treeUpdateFrequency()+gameSpeed#()
if treeUpdateFrequency()>2500
treeUpdateFrequency()=treeUpdateFrequency()-2500
treeCalculate()
endIf
gameSpeed()
remend

wallx#=object position x(3)
wallz#=object position z(3)

if keystate(36)=1 then move object left 3, .1

if keystate(38)=1 then move object right 3, .1

if keystate(23)=1 then move object 3, .1

if keystate(37)=1 then move object 3, -.1


set cursor 10,100
print "Walls X is ";wallx#
set cursor 10,110
print "Walls Y is ";wallz#

open to write 1, "RuinsEB.REB"
WRITE FLOAT 1, wallx#
WRITE FLOAT 1, wallz#
close file 1

sync
loop

` First person camera commands
CameraFirst:
show object 10000
if object frame (10000) = 20
set object frame 10000, 1
endif

PlayerXAng# = Object Angle X (10)
PlayerYAng# = Object Angle Y (10)
PlayerZAng# = Object Angle Z (10)
CameraXAng# = Camera Angle x()

if Jumping# = 1
if upkey()=1 then Move Object 10,.5
else
if upkey()=1 then Move Object 10,.2
endif
if downkey()=1 then Move Object 10,-.1
if rightkey()=1 then Move Object Right 10, .1
if leftkey()=1 then Move Object Left 10, .1

if mouseclick()=1
` Swing sword
PLAY OBJECT 10000, 1, 20
endif

if scancode()=15 and hold=0
CameraMode=1
hold=1
endif

if keystate(15)=0
hold = 0
else
hold = 1
endif

X# = Object position X(10)
Z# = Object position Z(10)

` Restrict camera angles
if cameraXang#=200.0
if cameraXang#=0.0 and cameraXang#=70.0 then cameraXang#=70.0
endif

` Rotate object and camera
`Xrotate object 10, Wrapvalue(playerXang#+MouseMoveY()*.2)
Xrotate camera WrapValue(CameraXAng#+MouseMoveY()*.2)
Yrotate object 10, Wrapvalue(playerYang#+MouseMoveX()*.2)
Yrotate camera WrapValue(playerYang#+MouseMoveX()*.2)

return

` Third person camera commands
CameraThird:
hide object 10000
playerthirdY# = Object angle Y(10)
cameraYang# = camera angle y()
if Jumping# = 1
if Upkey() = 1
Move object 10,.5
endif
else
If Upkey() = 1
Move object 10,.2
endif
endif
If Downkey() = 1 then Move object 10,-.1
If LeftKey() = 1 then Move object left 10, .1
If RightKey() = 1 then Move object right 10, .1

Yrotate object 10, Wrapvalue(playerthirdY#+MouseMoveX()*.2)

if scancode()=15 and hold=0
CameraMode=0
hold=1
endif

if keystate(15)=0
hold = 0
else
hold = 1
endif

SphereX# = Object position x(10)
SphereZ# = Object position z(10)

cZ# = Newzvalue(SphereZ#,playerthirdY#+180,20)
cX# = Newxvalue(SphereX#,playerthirdY#+180,20)

X# = Object position X(10)
Z# = Object position Z(10)

`Y# = Get ground height(1,X#,Z#)

return

```GET WORLD HEIGHT
```This will find the current matrix y# ground height position
```based on the Number of matrix used in variable mat#
```and the Matrix x,z tile size in variables matx# and matz#
```these can be set from an array if required.

function worldheight(ox#,oy#,oz#,firstmatrix,mat,matx#,matz#)

for a=firstmatrix to (firstmatrix+mat)-1
xx#=matrix position x(a)
zz#=matrix position z(a)
if ox# > xx# and ox# zz# and oz#
P.S. This is what the alphabet would look like if Q and R were eliminated.
Dave J
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 22nd Jun 2003 09:22
Your code was cut off so you might want to post it in the code box next time you post. Also, there's a lot of media there so it will be hard for others to test.

The only problem I picked up really quickly is:



should actually be:



"Computers are useless they can only give you answers."
TogaMario
23
Years of Service
User Offline
Joined: 30th Jan 2003
Location:
Posted: 22nd Jun 2003 09:26
I tried posting it in a code box ... but thanks, I'll try that out.

P.S. This is what the alphabet would look like if Q and R were eliminated.
TogaMario
23
Years of Service
User Offline
Joined: 30th Jan 2003
Location:
Posted: 22nd Jun 2003 09:28
Ok, that wasn't it, but i'm sure that didn't hurt. The code should be right now?

P.S. This is what the alphabet would look like if Q and R were eliminated.
Dave J
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 22nd Jun 2003 09:39
After replacing all your model files with basic objects and commenting out your Load Images, etc. it ran fine on my computer. Maybe take a look and see if all your media files are working and are not corrupt. Does it give an error message when it crashes or does it just quit?

"Computers are useless they can only give you answers."
TogaMario
23
Years of Service
User Offline
Joined: 30th Jan 2003
Location:
Posted: 22nd Jun 2003 10:10
It just quits, unfortunately. That's what's got me baffled. I'll double check all my resources, thanks for your help, and I'll keep ya posted, so to speak.

P.S. This is what the alphabet would look like if Q and R were eliminated.

Login to post a reply

Server time is: 2026-07-17 19:33:33
Your offset time is: 2026-07-17 19:33:33