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 Discussion / whats wrong with this engine?its driving me insane!

Author
Message
Xarshi
19
Years of Service
User Offline
Joined: 25th Dec 2005
Location: Ohio
Posted: 26th Dec 2005 09:34
what am i doing wrong with this engine? it says syntax error after i put gun bobbing code into the main loop.originally i had it outside of the main loop,but since i was looping the bobbing itself it sortof overwrote the main loop,getting rid of the collision detecting,moving,and mouse look and camera for that matter.
whats wrong with this engine?

HARK!
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 26th Dec 2005 13:02
Sorry, but the source code button is broken again, you'll have to put it in code tags.

SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 26th Dec 2005 18:01
Can't do that - Source button doesn't work as he is a new member, likewise, he also won't be able to edit, it will just say "Sorry, but I've given up"

Sorry, but for us to help, you'll need to post it again, In the message box (not the code box) click the code button at the top, then paste your code in and click code again...

...maybe one day I'll finish a project
Xarshi
19
Years of Service
User Offline
Joined: 25th Dec 2005
Location: Ohio
Posted: 26th Dec 2005 19:20
rem setup screen refreshing
sync on
sync rate 30
rem setup mouse and fog and camera view
hide mouse
set camera range 1,5000
fog on
fog distance 4000
fog color rgb(128,128,128)
color backdrop rgb(128,128,128)
rem make gun
load mesh "tommygun.x",1
load image "tommy gun tex.bmp",2
make object 2,1,0
yrotate object 2,180
scale object 2,100,100,100
position object 2,5,-7,15
secondarybob=45

rem make world and texture it
make matrix 1,10000,10000,20,20
load image "texture.bmp",1
prepare matrix texture 1,1,1,1
fill matrix 1,0,1
randomize matrix 1,150
rem set variables x and z
x#=5000
z#=5000
rem main loop
do
rem variables
for i=1 to 360 step 5
secondarybob=secondarybob+8
if secondarybob>360 then secondarybob=0
yrotate object 2,wrapvalue((sin(wrapvalue(i))*10))
xrotate object 2,wrapvalue(sin(wrapvalue(secondarybob))*2)
sync
next i
loop
oldcamangley#=cameraangley#
oldcamanglex#=cameraanglex#
cameraangley#=wrapvalue(cameraangley#+mousemovex()*0.2)
cameraanglex#=wrapvalue(cameraanglex#+mousemovey()*0.2)
rem controlling char/forward move
if upkey()=1
gunlag#=1.1
xtest#=newxvalue(x#,cameraangley#,10)
ztest#=newzvalue(z#,cameraangley#,10)
if xtest#>0 and xtest#<10000 and ztest#>0 and ztest#<10000
x#=xtest#
z#=ztest#
endif
endif
rem controlling char/backward move
if downkey()=1
gunlag#=1.1
xtest#=newxvalue(x#,wrapvalue(cameraangley#-180),10)
ztest#=newzvalue(z#,wrapvalue(camearangley#-180),10)
if xtest#>0 and xtest#<10000 and ztest#>0 and ztest#<10000
x#=xtest#
z#=ztest#
endif
endif
rem controlling char/strafe left
if leftkey()
gunlag#=1.1
xtest#=newxvalue(x#,wrapvalue(cameraangley#-90),10)
ztest#=newzvalue(z#,wrapvalue(cameraangley#-90),10)
if xtest#>0 and xtest#<10000 and ztest#>0 and ztest#<10000
x#=xtest#
z#=ztest#
endif
endif
rem controlling char/strafe right
if rightkey()
gunlag#=1.1
xtest#=newxvalue(x#,wrapvalue(cameraangley#+90),10)
ztest#=newzvalue(z#,wrapvalue(cameraangley#+90),10)
if xtest#>0 and xtest#<10000 and ztest#>0 and ztest#<10000
x#=xtest#
z#=ztest#
endif
endif
yrotate camera curveangle(cameraangley#,oldcamangley#,24)
xrotate camera curveangle(cameraanglex#,oldcamanglex#,24)

y#= get ground height(1,x#,z#)
position camera x#,y#+100,z#
sync
loop

HARK!
Xarshi
19
Years of Service
User Offline
Joined: 25th Dec 2005
Location: Ohio
Posted: 26th Dec 2005 19:21
thats the code.it started saying syntax rerror and something about nesting when i put in a gun bobbing code(ends with next i)if you could help,i would be very very very happy.thanks in advance.

HARK!
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 26th Dec 2005 22:28
The best way to squash nesting errors is to indent your code. I use just one space (others use tab). When you start any kind of loop you space it out so that the start of the loop is directly under the end of the loop. Using that method you can easily see when a loop starts and ends. Indenting makes it easier to debug too. Also don't be afraid to add blank lines in your code.

Non-indented Code (this code wasn't made by me):


The above is very hard to follow whats going on because it's not indented. The next code snip is that same code only indented... notice how much easier it is to read and where each loop starts and ends.



The next code snip is your own code indented. It appears that you had a "loop" at the end that was already closed right under the for/next loop. I just remed off the first "loop" and it runs.



To make code snips you do this:

[ code ]
Your code here.
[ /code ]

Just remove the spaces between the brackets... always put any code in code snips. You may have had your code indented but it won't be indented in the message if it's not in a code snip.


Xarshi
19
Years of Service
User Offline
Joined: 25th Dec 2005
Location: Ohio
Posted: 27th Dec 2005 01:05
yeah,that did work,twas extremely extremely extremely laggy,so thankyou anyways. i guess my guns were never mean to move from their original positions...unless can you string together animations from different x files and then save the frames together to get one animated model?

HARK!
master programmer
19
Years of Service
User Offline
Joined: 30th May 2005
Location: 3D Space
Posted: 27th Dec 2005 04:41
If it's laggy, just fix the sync rate to something higher than 30, maybe 45 or 50?

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 27th Dec 2005 05:24
Using "sync rate 0" goes as fast as the computer running it can handle.


new programmer
19
Years of Service
User Offline
Joined: 20th Dec 2005
Location: right behind you.
Posted: 28th Dec 2005 04:17
yeah, i always do that. but go like devistation, have an option to change between 30,45,50, and 0(highest possible).
blanky
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: ./
Posted: 28th Dec 2005 11:10
Nuh-uh. Set your sync rate to 50 or 60, and once you've worked out all the bugs in your code switch to a timer()-based version.

That way it will run the same speed on *every* machine, even if it doesn't achieve the required framerate, and you can set sync rate to 0. So if your computer can run it at 300 FPS it will, and the game'll run at the same speed as one that can only run it at 20 FPS.

Make the effort! It's worth it...

Support the AAANJL by doing nothing! Visit teh site below..
Red Ocktober
21
Years of Service
User Offline
Joined: 6th Dec 2003
Location:
Posted: 28th Dec 2005 14:45


--Mike
blanky
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: ./
Posted: 28th Dec 2005 20:54
No comment, but you can't say that timer()-based code doesn't work

Support the AAANJL by doing nothing! Visit teh site below..
Red Ocktober
21
Years of Service
User Offline
Joined: 6th Dec 2003
Location:
Posted: 29th Dec 2005 00:38


--Mike
SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 29th Dec 2005 02:10
I get nervous when people sit there grinning... :S

...maybe one day I'll finish a project
new programmer
19
Years of Service
User Offline
Joined: 20th Dec 2005
Location: right behind you.
Posted: 1st Jan 2006 00:42
its not :S

Xarshi
19
Years of Service
User Offline
Joined: 25th Dec 2005
Location: Ohio
Posted: 5th Jan 2006 00:05
ive come to a new problem with ai in my game.basicly,i have four ai running around killing eachother,and im using a placeenemy2 sub code to place the second soldier.the code is

but for some reason everytime i click it just thinks that its being shot,so it starts placing itself randomly,and not just once,it loops it.and only till i let go of the trigger,it stops.the shoot code for that part is this:

i'd like to know whats wrong with that.i've been trying to get this one ai to stop this,so i went back and compared it to its ally,and they are almost identical(except for position variables).so if anyone can help,i will be happy

HARK!

Login to post a reply

Server time is: 2025-05-23 00:03:54
Your offset time is: 2025-05-23 00:03:54