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 / Free FPS source code HERE!

Author
Message
QuothTheRaven
17
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 11th Oct 2002 03:26
I come to you bringing an almost working fps code. It includes jumping, strafing and object collision. Buildings levels with this would be extremly easy. The only problem with this is that you can climb up walls by jumping and moving towards them. This provides obvious problems (jumping of level, climbing walls makes gameplay much harder, defeats the purpose of realistic gravity...)

The code is the engine for my fps, Arena, which is a hybrid of the sliding collision code tutorial and the idea of strafing. I have exlcuded the weapons and enemies to simplify it. Here is the code, can anyone tell me what I'm doing wrong to avoid jumping up the walls? Thanks in advance, you'll get a mention or two in the credits.

sync on
hide mouse
sync rate 60
make object box 1,10,150,1000 : position object 1,-500,0,0 : color object 1,rgb(0,40,20)
make object box 2,10,150,1000 : position object 2, 500,0,0 : color object 2,rgb(155,40,20)
make object box 3,1000,150,10 : position object 3, 0,0,-500 : color object 3,rgb(0,255,255)
make object box 4,1000,150,10 : position object 4, 0,0, 500 : color object 4,rgb(255,0,255)
make object box 5,1000,10,1000 : position object 5,0,-5,0 : color object 5,rgb(0,255,0)
set object collision on 5
set object collision on 4
set object collision on 3
set object collision on 2
set object collision on 1
create bitmap 1,32,32 : cls rgb(0,155,0) : ink rgb(0,145,0),0 : box 4,4,12,12
get image 1,0,0,32,32 : delete bitmap 1 : texture object 5,1
scale object texture 5,200,200
REM MAKE CHARACTER
make object cylinder 11,1
hide object 11
set object collision on 11
position object 11,0,0,0
color object 11,rgb(20,100,255)
make object collision box 11,-4,-4,-4,4,4,4,0
disable object zdepth 11


rem Make a pedestal steps
for t=0 to 4
make object box 6+t,50,8,50
position object 6+t,0,4+(t*10),100+(t*50)
color object 6+t,rgb(100,200,100)
set object collision on 6+t
next t
for t=6 to 10
set object collision on t
make object collision box t,-25,-4,-25,25,4,25,0
next t

make object collision box 1,-6,-75,-500,5,75,500,0
make object collision box 2,-6,-75,-500,5,75,500,0
make object collision box 3,-500,-75,-6,500,75,5,0
make object collision box 4,-500,-75,-6,500,75,5,0
make object collision box 5,-500,-50,-500,500,6,500,0

playergrav#=2
REM **************************************************************************
REM ::::::::::::::::::---START LOOP---::::::::::::::::::::::::::::::::::::::::
REM **************************************************************************
DO

oldcAY#=cAY#
oldcAX#=cAX#
oldposx#=object position x(11)
oldposy#=object position y(11)
oldposz#=object position z(11)
cAY#=WrapValue(cAY#+MousemoveX()*.15)
cAX#=WrapValue(cAX#+MousemoveY()*.15)
caZ#=Camera angle Z()
yrotate object 11,cAY#
If keystate(18)
posx#=Newxvalue(posx#,cAY#,2)
posz#=Newzvalue(posz#,cAY#,2)
Endif
If keystate(32)
posx#=Newxvalue(posx#,Wrapvalue(cAY#-180),2)
posz#=Newzvalue(posz#,Wrapvalue(cAY#-180),2)
Endif
If keystate(31)
posx#=Newxvalue(posx#,Wrapvalue(cAY#-90),2)
posz#=Newzvalue(posz#,Wrapvalue(cAY#-90),2)
Endif
If keystate(33)
posx#=Newxvalue(posx#,Wrapvalue(cAY#+90),2)
posz#=Newzvalue(posz#,Wrapvalue(cAY#+90),2)
Endif
REM PICK CURRENT GUN
if scancode()=2 THEN cgun#=1
if scancode()=3 THEN cgun#=2
if scancode()=4 THEN cgun#=3
if scancode()=5 THEN cgun#=4
if scancode()=6 THEN cgun#=5
if scancode()=7 THEN cgun#=6
if keystate(17) and nw#=0
nw#=1
inc cgun#
if cgun#=7 then cgun#=1
endif
if keystate(17)=0 then nw#=0
set cursor 0,0
print cgun#
REM CHARACTER COLLISION
position object 11,posx#,posy#,posz#
if object collision(11,0)>0
dec posx#,get object collision x()
dec posy#,get object collision y()
dec posz#,get object collision z()
playergrav#=0
endif
if spacekey()=1 and playergrav#=0 then playergrav#=2
playergrav#=playergrav#-.1
posy#=posy#+playergrav#
REM CHARACTER COLLISION
position object 11,posx#,posy#,posz#
if object collision(11,0)>0
dec posx#,get object collision x()
dec posy#,get object collision y()
dec posz#,get object collision z()
playergrav#=0
endif
cTestX#=WrapValue(cAX#-180)
if cTestX#>225 then cAX#=45
if cTestX#
QuothTheRaven
17
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 11th Oct 2002 03:28
errrr code tag didnt work (I did highlight and select code, here it is continued from if cTestX# (replace cTestX# with the first line of this)

if cTestX#<135 then cAX#=315
YRotate camera CurveAngle(cAY#,oldcAY#,24)
XRotate camera CurveAngle(cAX#,oldcAX#,24)
Position Camera posx#,posy#+15,posz#



The Darthster
17
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 11th Oct 2002 20:52
I made something similar to this and had the problem of jumping = sliding up walls. If you check the y value of your static collision, you should see that when you are standing on something the y collision is >0 and when you are not, the y collision is 0. Use this to turn the gravity up and down to prevent you from sliding up walls.
Freddix
AGK Developer
17
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 12th Oct 2002 00:16
there is one thing that noone has resolved !

sliding collisions for walls that are rotated !

making a fps with only 90° angled walls should look a bit like Wolfeinstein 3D . . .

It a bit . . . just for making a game nowadays !
QuothTheRaven
17
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 12th Oct 2002 02:28
It can be done, it just has to be manually programmed, and frankly db doesnt have the rescources for it.

QuothTheRaven
17
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 12th Oct 2002 06:32
Its...not...working....still climb up walls.......AHH!H!H!111!!1one
if my collision code is

position object 11,posx#,posy#,posz#
if object collision(11,0)>0
dec posx#,get object collision x()
dec posy#,get object collision y()
dec posz#,get object collision z()
playergrav#=0
endif

and you can only jump when playergrav=0, can you give me an example of the code that would make him jump when he's supposed to? I tried the static collision thingy with no luck, what code do I need to add to fix that?

QuothTheRaven
17
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 12th Oct 2002 06:49
HAHAHAHAHAH!WOOOTWOOOOOOTOOOOO000TT!
Its fixed, heres what the code looks like (needs to be in this order)



REM CHARACTER COLLISION
if spacekey()=1 and playergrav#=0 then playergrav#=2
playergrav#=playergrav#-.1
posy#=posy#+playergrav#
position object 11,posx#,posy#,posz#
if object collision(11,0)>0
if get object collision y() then playergrav#=0
dec posx#,get object collision x()
dec posy#,get object collision y()
dec posz#,get object collision z()
endif

The Darthster
17
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 13th Oct 2002 01:59
Thought my suggestion might work. Except, it seems it doesn't. If I put that collision code into your other code, you can still run against the outside walls and climb up them by holding jump. Hmm...
QuothTheRaven
17
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 13th Oct 2002 06:37
it works on my comp, I deleted a few other things and re-aranged a few lines that made a weird bouncing effect, but that works. I can finally move on to finishing the weapons
MiRRoRMaN
17
Years of Service
User Offline
Joined: 9th Oct 2002
Location: Netherlands
Posted: 13th Oct 2002 22:45
I dont know what I am doing wrong with this but I keep getting a "nesting error"

www.mirrorman.cjb.net, the classic Commodore 64 and Amiga site.
QuothTheRaven
17
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 13th Oct 2002 23:19
I butchered the code in the first 2 posts, theres some more to it (like LOOP at the end) that for some reason wasn't posted. Anyway this isn't here so you can steal my 3 weeks of hard work , its so someone could tell me what I did wrong.
The Darthster
17
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 14th Oct 2002 19:54
So when you say "Free fps source code here" you mean "Oi! Don't nick my fps source code! Just tell me what's wrong!" Lol. Anyway, I tried to help you a bit, I didn't steal your hard work, no hard feelings .
MiRRoRMaN
17
Years of Service
User Offline
Joined: 9th Oct 2002
Location: Netherlands
Posted: 16th Oct 2002 14:47
TheDarthster I agree. You shouldn't be saying "Free FPS code here" then and get peoples hopes up. lol.

www.mirrorman.cjb.net, the classic Commodore 64 and Amiga site.
Mirthin
17
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Land of the Rising Haggis
Posted: 18th Oct 2002 03:42
Perhaps you don't know the difference between 'free' and 'royalty free.' Lay off QuothTheRaven, until you actually have something on him.
QuothTheRaven
17
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 18th Oct 2002 05:01
Now honestly, if you copied my code, what kind of programmer would you be then?
indi
17
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 18th Oct 2002 09:07
a Quoth clone ette

http://www.lunarpixel.com/ is my new site
Stevo
17
Years of Service
User Offline
Joined: 4th Oct 2002
Location:
Posted: 19th Oct 2002 16:58
HI, I'm new to this. That code was really good, I can't help with the walls thing, but I was looking at the exam 25 (with the stairs pedastal as well), what I am trying to do though is make it so that you are standing on a matrix instead of a box, I did try it with your -Qouth The Raven, code, but I sank through the floor! Their's a command called "Get Hieght" I wonder if this would be needed. I've basicly got a matrix for a courtyard, then slightly higher there's another matrix for a temple, and i want to be able to jump up from one to the other. The camera hieght just stays at the same leval at the moment.
If this is a bit off subject for you don't worry, I shall just have to go back and try it a bit more, or learn the commands a bit more.

QuothTheRaven
17
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 19th Oct 2002 19:35
well...using matricies along with sliding collision will prove to be problematic. The main concept behind it is that if you are on the matrix, you ignore sliding collision. If you aren't, you use sliding collision. As for multiple height matricies, that would be reaaaly had, and you might have to write custom algorithms to see how close you are to each matrix, and use the closest one as the ground. Generally you only use 1 type of level object, and mixing them will screw up collision.
Mirthin
17
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Land of the Rising Haggis
Posted: 19th Oct 2002 20:08
You know, valve had the same problem in half life. If a moveable entity was placed on a wall, it would 'sink off' of the wall slowly, and then go beyond the floor. Weird
MiRRoRMaN
17
Years of Service
User Offline
Joined: 9th Oct 2002
Location: Netherlands
Posted: 19th Oct 2002 23:13
"Now honestly, if you copied my code, what kind of programmer would you be then?"

A newbie. but you did say "free fps code here"

what did u mean by that then?

www.mirrorman.cjb.net, the classic Commodore 64 and Amiga site.
QuothTheRaven
17
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 20th Oct 2002 00:16
la-het it go!
MiRRoRMaN
17
Years of Service
User Offline
Joined: 9th Oct 2002
Location: Netherlands
Posted: 20th Oct 2002 21:36
Sure, if you name the topic differently next time.

www.mirrorman.cjb.net, the classic Commodore 64 and Amiga site.
Deion
17
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United States
Posted: 26th Oct 2002 23:32
well here is a butcherd version of teh tut on the back of teh manual



its free to everyone but the little kid who said free code and dicided his code was to precious. i'll post updates to this as they come i have better code but its not working yet so i will wait to post that til it is its going to be a 3rd person shooter the above code is just my rant to learn the language. but im a fast learn and a decent programmer so i feel confident that in the next month this will be some awsome code coming out

MiRRoRMaN
17
Years of Service
User Offline
Joined: 9th Oct 2002
Location: Netherlands
Posted: 27th Oct 2002 15:36
Lol & Thanx! Have you perhaps got the mediafiles for this source too?

www.mirrorman.cjb.net, the classic Commodore 64 and Amiga site.
MiRRoRMaN
17
Years of Service
User Offline
Joined: 9th Oct 2002
Location: Netherlands
Posted: 27th Oct 2002 15:43
Hi,

It wont work here, do you perhaps need DarkMatter for this one?

It wont load the BSP map, as well as some other commands.

www.mirrorman.cjb.net, the classic Commodore 64 and Amiga site.
Shadow Robert
17
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 28th Oct 2002 03:38
i don't think its misleading...
the code happens to be FREE of charge, it is full source and is well here...
therefor Free FPS source code HERE, as FPS just means First Person Shooter - not checked this yet but if there is a gun involved then he wasn't lying right?
niether has he stated it is purely his own work

however technically i could make a post and give everyone this ->


Mwhahaa... my free FPS source code

Anata aru kowagaru no watashi!
Deion
17
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United States
Posted: 28th Oct 2002 12:20
i will make the zip file source with media available tomorrow night

Cheers,
Deion G.
Deion
17
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United States
Posted: 28th Oct 2002 21:47
never mind : i didnt realize they stuck a db forum on the dbpro site. i got to this page from inside dbdn so i never saw the header that it is for the regular db i just visited the dbpro site and saw that this comment was made to a regular db forumn. sorry it is code for dbpro

Cheers,
Deion G.
MiRRoRMaN
17
Years of Service
User Offline
Joined: 9th Oct 2002
Location: Netherlands
Posted: 30th Oct 2002 13:58
Damn damn.... hehe oh well I will try Raven's code now

www.mirrorman.cjb.net, the classic Commodore 64 and Amiga site.
Megaman X
17
Years of Service
User Offline
Joined: 21st Oct 2002
Location: Sweden
Posted: 30th Oct 2002 18:39
Bwahahahahah, thanks Vegeta...I was looking for a code like this for centuries

I don't suffer from insanity, I enjoy every minute of it.
-Rogue

Login to post a reply

Server time is: 2020-08-13 18:15:23
Your offset time is: 2020-08-13 18:15:23