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 / Collision and Stairs Problem

Author
Message
Aetos
14
Years of Service
User Offline
Joined: 5th Oct 2009
Location:
Posted: 5th Oct 2009 18:20
REM *****************************************
RemStart
*** TITLE - Introduction to DarkBASIC
*** VERSION - 1.1 LAST UPDATED - 10.05.2009
*** DEVELOPER - The Benchwarmers
*** COPYRIGHT - Ingenious Student Labs
*** DATE CREATED - 1.1.2000
***
RemEnd
REM *** START SYSTEM SETUP SECTION

sync on : sync rate 30
autocam on
hide mouse

REM *** STOP SYSTEM SETUP SECTION
REM *****************************************

REM *****************************************
REM *** START INTRO SECTION
REM *** INTRO SECTION HEADER

REM SET VARIABLES
REM SCREEN DISPLAY
cls 0 : center text 320,240,\"HIT ANY KEY TO BEGIN\"
REM LOAD SOUNDS
REM SPECIAL EFFECTS
REM REFRESH SCREEN
sync

REM *** INTRO SECTION LOOP

do
REM CONTROL INPUT
x=scancode() : if Keystate(x)=1 then goto MainSection
REM REFRESH SCREEN
sync
loop

REM *** END INTRO SECTION
REM *****************************************

REM *****************************************
REM *** START MAIN SECTION
REM *** MAIN SECTION HEADER

MainSection:
REM DECLARE VARIABLES
REM SCREEN DISPLAY
cls 0 : backdrop on
REM LOAD TEXTURES
REM LOAD SOUNDS
REM OBJECT CREATION
Load Object \"monkey.x\",1
Position Object 1,0,285,-810
Scale Object 1,3000,3000,3000
make object collision box 1,-1500,-1500,-1500,1500,1500,1500,1

rem Floor
make object box 18,2000,1000,2000 : position object 18,0,-500,0 : color object 18,rgb(203,255,67)
make object collision box 18,-1000,-500,-1000,1000,500,1000,0
rem Walls

rem North Wall
make object box 21,2000,1000,10
rotate object 21,0,0,0
position object 21, 0,500,600
make object collision box 21,-1000,-500,-5,1000,500,5, 1
rem East Wall
make object box 31,2000,1000,10
rotate object 31,0,90,0
position object 31, 1005,500,0
make object collision box 31,-1000,-500,-5,1000,500,5,1
rem West Wall
make object box 5,2000,1000,10
rotate object 5,0,270,0
position object 5, -1005,500,0
make object collision box 5,-1000,-500,-5,1000,500,5,1


REM LOAD MODELS
REM SET CAMERA
REM REFRESH SCREEN
sync

REM *** MAIN SECTION LOOP

do
REM SPECIAL EFFECT

REM OBJECT ORIENTATIONS
1aY# = object angle Y(1)
REM CAMERA ORIENTATIONS
REM LIVE SCREEN DISPLAY
center text 320,440,\"USE ARROW KEYS TO MOVE | PRESS \'Q\' TO QUIT\"
REM CONTROL INPUT
if Upkey()=1 then move object 1,10
if Leftkey()=1 then 1aY# = wrapvalue(1aY#-5)
if Rightkey()=1 then 1aY# = wrapvalue(1aY#+5)
if Downkey()=1 then move object 1,-10
REM TRANSFORM OBJECTS
REM MOVE OBJECTS
Yrotate object 1,1aY#
REM CHECK FOR COLLISion

REM REFRESH SCREEN
sync
loop

REM *** STOP MAIN SECTION
REM *****************************************

REM *****************************************
REM *** START END SECTION
REM *** END SECTION HEADER

EndSection:
REM SCREEN DISPLAY
cls 0 : center text 320,240,\"PLAY AGAIN [Y/N]?\"
REM LOAD SOUNDS
REM REFRESH SCREEN
sync

REM *** END SECTION LOOP

do
REM CONTROL INPUT
if Inkey$()=\"y\" then goto MainSection
if Inkey$()=\"n\"
cls : end
endif
REM REFRESH SCREEN
Sync
loop

end
REM *** STOP END SECTION
REM *****************************************



ok so i need with stairs and collision box; im new to the class and dont kno wat the hell im doin.
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 9th Oct 2009 06:13
Hello,

Please state specifically what you are trying to do and what you do not understand.

Enjoy your day.
Aetos
14
Years of Service
User Offline
Joined: 5th Oct 2009
Location:
Posted: 9th Oct 2009 17:52
im trying to make a room that has stiars going up to another room. i cant seem fix the collision and i cant build stairs.
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 9th Oct 2009 21:01
What do you want to do with the collision? All you've done as far as I can see is make collision boxes, you haven't got any code actually dealing with what happens when you collide with them.

Also, a model of stairs would possibly be the best way of doing it. Just find a model you like, and use the load object and object position commands to put it where you want.

"A West Texas girl, just like me"
-Bush
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 10th Oct 2009 00:46 Edited at: 10th Oct 2009 00:47
Hi there!

This might be a bit sudden, but the easiest way for checking collision with loaded X or 3DS objects is Sparky's collision DLL.

Attached is a simple demonstration of sliding collision using sparky's dll. It should be easy to implement into your project, just change "position camera x#,y#+2,z#" with the object you want to position:

position object <player>,x#,y#,z#

But only if you want the player to be an object.



Download the attachment, hope this helps!

Another thing you may have to change is the collision size and speed, because your world may be a lot bigger or smaller than mine. My collision size is set to 6:



You will notice the 3 everywhere. If your character is 30 wide, 20 long and 80 high, you will have to divide those numbers by 2 and insert them at the correct place:



Of course, feel free to use this example as your base structure to build things into it how you like and turn it into a good FPS game!

TheComet


Make the paths of your enemies easier with WaypointPro!

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-05-04 06:17:22
Your offset time is: 2024-05-04 06:17:22