Hello everyone.
Enigma here

As most of you should know, I am in a class in school for learning how to code in DarkBasic. Well, we are working on a project (just to get the hang of different commands) where we start out with a plain, a cube (rectangular shaped) and really thin cylinders along the axis for reference when playing. It displays the coordinates and angles and such as well. We then needed to load a goblin in, and make him walk around be able to jump. We then had to texture the goblin, and make collision boxes... This is where the problem sets in...
Now, I can make it where I just do the simple code for collision boxes..
set collision box on 6...
make collision box -50,-50,-50, 50,50,50, 6
....
do
if object collision(1,6) = 1 :
position object 6, 6pX#,6pY#,6pZ# :
Yrotate object 6,6aY
Maybe some of the semantics of that code isn't right, not sure if it is create collision box or make. Anyways, that way works well, but I want to make it where the collision is set to the polygons.
I have it where the collision is set to the polygons... The goblin can walk around, and his collision works perfectly.... Well.... When I try to rotate the cube.. the computer crashes. Well, I am not sure if it is a crash, but it nonetheless freezes. I can still press ctrl+alt+delete. If you could look over my code, and see how to keep it as set collision to polygons 6 will work with this I would greatly appreciate it. Thank you for your help!
Oh, and here is the code =p I sincerely apologize if some of it is malindented..
Oh yeah. Forgot. The texture I use, and maybe the goblin itself wont work. You can rem the Texture out if you want, and if any other media (just pics, no sounds) problems occur, just change them to fit your comp.
REM *****************************************
RemStart
***
*** TITLE - 3D Space
*** VERSION - 3.2 LAST UPDATED - 1.1.2000
*** DEVELOPER - Jason Holm
*** COPYRIGHT - Ingenious Student Labs
*** DATE CREATED - 1.1.2000
***
RemEnd
REM *** START SYSTEM SETUP SECTION
sync on : sync rate 30
autocam off
hide mouse
randomize timer()
REM *** STOP SYSTEM SETUP SECTION
REM *****************************************
REM *****************************************
REM *** START INTRO SECTION
REM *** INTRO SECTION HEADER
REM DECLARE VARIABLES
REM SCREEN DISPLAY
cls
load bitmap "images/cubetitle.bmp"
ink rgb(255,255,255),0 : set text font "arial" : set text size 14 : set text to normal : set text transparent
center text 320,460,"Copyright (c) 2000 Ingenious Student Labs"
REM LOAD SOUNDS
REM SPECIAL EFFECTS
REM REFRESH SCREEN
sync
REM *** INTRO SECTION LOOP
do
REM SCREEN DISPLAY
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
MyTimer = 1500 : rem MyTimer / sync rate = seconds on timer (approx.)
Gravity# = 1 : rem How powerful gravity is
MyPower = 10 : rem How strong the player can jump
MySpeed = 9 : rem How fast the player can run
REM DECLARE VARIABLES
REM SCREEN DISPLAY
cls
backdrop on : Rem Create the 3D world's background
color backdrop rgb(50,0,50) : Rem Change the Backdrop color
REM OBJECT CREATION
make object cube 1, 50
1dX# = 50 : Rem The X size you want the Object to become
1dY# = 120 : Rem The Y size you want the Object to become
1dZ# = 30 : Rem The Z size you want the Object to become
scale object 1, (1dX# / object size x(1))*100,(1dY# / object size y(1))*100,(1dZ# / object size z(1))*100
remStart
Since the default size of this cube is 50 in each direction, this function becomes
scale object 1, (50 / 50) * 100, (120 / 50) * 100, (30 / 50) * 100
scale object 1, (1) * 100, (2.4) * 100, (.6) * 100
scale object 1, 100,240,60
remEnd
position object 1, 0,60,0 : Rem Place Object 1 at a specific place in the world
rotate object 1,0,350,0 : Rem Rotate Object 1 a specific amount
make object plain 2, 400,300 : Rem Make Object 2 a flat plane
rotate object 2, 90,0,0
make object cylinder 3, 100 : Rem Make Object 3 a cylinder marking the X axis
color object 3,rgb(255,0,0)
scale object 3, 5,1000,5
position object 3, 0,0,0
rotate object 3, 0,0,90
make object cylinder 4, 100 : Rem Make Object 4 a cylinder marking the Y axis
color object 4,rgb(0,255,0)
scale object 4, 5,1000,5
position object 4, 0,0,0
rotate object 4, 0,90,0
make object cylinder 5, 100 : Rem Make Object 5 a cylinder marking the Z axis
color object 5,rgb(0,0,255)
scale object 5, 5,5000,5
position object 5, 0,0,0
rotate object 5, 90,0,0
REM GOBLIN GUY
load object "models/walk.x",6
Load image "images/flames.bmp",6 : `Get teh image in da game foo
texture object 6,6
scale object 6, 300,200,300
position object 6, 200,0,0
xrotate object 6,0
yrotate object 6,0
zrotate object 6,0
fix object pivot 6
position camera -20,100,-300
point camera 0,50,0
REM *** MAIN SECTION LOOP
`MAKE COLLISIONY GUY
set object collision to polygons 6
do
`set object collision to polygons 6
color object 1,rgb(1pX#,1pY#,1pZ#)
REM SPECIAL EFFECTS
REM OBJECT ORIENTATIONS
1pX# = object position X(1)
1pY# = object position Y(1)
1pZ# = object position Z(1)
1aX = object angle X(1)
1aY = object angle Y(1)
1aZ = object angle Z(1)
REM GOBLIN OBJECT ORIENTATION
6pX# = object position X(6)
6pY# = object position Y(6)
6pZ# = object position Z(6)
6aX = object angle X(6)
6aY = object angle Y(6)
6aZ = object angle Z(6)
REM CAMERA ORIENTATIONS
REM LIVE SCREEN DISPLAY
ink rgb(255,255,255),0 : set text font "times" : set text size 16 : set text to bold : set text opaque
center text 320,420,"USE ARROW KEYS TO MOVE | PRESS 'V' TO FLOAT UP AND 'B' TO SINK DOWN"
center text 320,440,"PRESS 'Q' TO QUIT"
Rem Print Object Dimensions
set cursor 0,0
ink rgb(255,255,255),0 : print "OBJECT 1"
ink rgb(255,0,0),0 : print "X dimension: ";1dX#
ink rgb(0,255,0),0 : print "Y dimension: ";1dY#
ink rgb(0,0,255),0 : print "Z dimension: ";1dZ#
print
Rem Print Object position
ink rgb(255,0,0),0 : print "X position: ";1pX#
ink rgb(0,255,0),0 : print "Y position: ";1pY#
ink rgb(0,0,255),0 : print "Z position: ";1pZ#
print
Rem Print Object angles
ink rgb(255,0,0),0 : print "X angle: ";1aX
ink rgb(0,255,0),0 : print "Y angle: ";1aY
ink rgb(0,0,255),0 : print "Z angle: ";1aZ
REM CONTROL INPUT
if Upkey()=1 then move object 1,5
if Downkey()=1 then move object 1,-5
if Leftkey()=1 then Yrotate object 1,wrapvalue(1aY-5)
if Rightkey()=1 then Yrotate object 1,wrapvalue(1aY+5)
if Inkey$()="v" then 1pY# = 1pY# + 5 : Rem If the user hits the 'v' key, then move Object 1 up 5 units
if Inkey$()="b" then 1pY# = 1pY# - 5 : Rem If the user hits the 'b' key, then move Object 1 down 5 units
REM GOBLIN CONTROL INPUT
if Inkey$()="8" then move object 6,0-MySpeed : loop object 6,5,25 : set object speed 6,18
if Inkey$()="2" then move object 6,MySpeed : loop object 6,5,25 : set object speed 6,-18
if Inkey$()="4" then Yrotate object 6,wrapvalue(6aY+(MySpeed/3)) : loop object 6,5,25
if Inkey$()="6" then Yrotate object 6, wrapvalue(6aY-(MySpeed/3)) : loop object 6,5,25
REM GOBLIN WALK
if Spacekey()=1
if 6pY# < 141 then position object 6, (6pX#),(6pY#+10),(6pZ#)
if Inkey$()="8" then move object 6,0-MySpeed : loop object 6,5,25 : set object speed 6,18
if Inkey$()="2" then move object 6,MySpeed : loop object 6,5,25 : set object speed 6,-18
endif
if Spacekey()=0
if 6pY# > 0 then position object 6,(6pX#),(6pY#-10),(6pZ#)
if Inkey$()="8" then move object 6,0-MySpeed : loop object 6,5,25 : set object speed 6,18
if Inkey$()="2" then move object 6,MySpeed : loop object 6,5,25 : set object speed 6,-18
endif
if Inkey$()=""
stop object 6
endif
if object collision(6,1) = 1 :
position object 1, 1pX#,1pY#,1pZ# :
Yrotate object 1,1aY
endif
if object collision(1,6) = 1 :
position object 6, 6pX#,6pY#,6pZ# :
Yrotate object 6,6aY
endif
if Inkey$()="q"
for x = 1 to 100
if object exist(x) = 1
delete object x
endif
next x
backdrop off : Rem Remove the 3D world's background
goto EndSection
endif
REM TRANSFORM OBJECTS
REM MOVE OBJECTS
Rem Store the new positions of Object 1
1pX# = object position X(1)
1pZ# = object position Z(1)
position object 1,1pX#,1pY#,1pZ# : Rem Reposition Object 1
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 DECLARE VARIABLES
REM SCREEN DISPLAY
cls 0
ink rgb(255,255,255),0 : set text font "times" : set text size 20 : set text to bold : set text transparent
center text 320,240,"PLAY AGAIN [Y/N]?"
REM LOAD SOUNDS
REM SPECIAL EFFECTS
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 *****************************************
Regards,
Enigma
-Mike
All hope is lost when one subjects to the malevolence of apathy. ~by me~
Trust in someone is a greater compliment than love. ~By me~