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 / loop command help!

Author
Message
TylerTheLizard
7
Years of Service
User Offline
Joined: 26th Sep 2016
Location:
Posted: 10th Nov 2016 14:33
So I am making a 3D world and I just finish all my collision stuff in but my loop doesn't want to work. It worked before I added the collision stuff. Someone please help!



This is my code:
REM Project: Game Arena
REM Created: 10/11/2016 7:41:35 AM
REM Tyler D. Hathaway
REM ***** Main Source File *****
REM
sync on
sync rate 60
hide mouse

Load music "M:\Video Game Design\Phase 4\Sounds\Lilith.wav", 1
play music 1
loop music 1
Rem Load Image
load image "C:\Users\tyler_hatha172\Desktop\Textures\bloodmoon.jpg", 1
load image "C:\Users\tyler_hatha172\Desktop\Textures\lavaboat.jpg", 2
load image "C:\Users\tyler_hatha172\Desktop\Textures\lavapool.jpg", 3
load image "C:\Users\tyler_hatha172\Desktop\Textures\lavariver.jpg", 4
load image "C:\Users\tyler_hatha172\Desktop\Textures\pentacle1.jpg", 5
load image "C:\Users\tyler_hatha172\Desktop\Textures\pentacle2.jpg", 6
load image "C:\Users\tyler_hatha172\Desktop\Textures\pentacle3.jpg", 7
load image "C:\Users\tyler_hatha172\Desktop\Textures\pentacle4.jpg", 8
load image "C:\Users\tyler_hatha172\Desktop\Textures\lava waterfall.jpg", 9
load image "C:\Users\tyler_hatha172\Desktop\Textures\treetop.jpg", 10
load image "C:\Users\tyler_hatha172\Desktop\Textures\treebark.jpg", 11

make light 1
set point light 1, 0, 50, 0
set light range 1, 7500
REM South Wall
Make Object box 4,3000,1000,1
Color object 4, RGB (255,255,255)
position object 4,0,490, -1500
Rem !same thing as function below!


makeWall(2,3000,1,3000, 0,-10,0,rgb(0,255,0)) REM Floor
makeWall(3,3000,1000,1,0,490,1500,rgb(0,191,255)) REM North Wall
makeWall(5,3000,1000,1,1500,490,0,rgb(255,0,0)) REM East Wall
makeWall(6,3000,1000,1,-1500,490,0,rgb(255, 204, 0)) REM West Wall
YROTATE OBJECT 5, 90
YRotate Object 6 ,-270

TEXTURE OBJECT 2, 3
TEXTURE OBJECT 3, 2
TEXTURE OBJECT 4, 1
TEXTURE OBJECT 5, 4
TEXTURE OBJECT 6, 9



Rem Create Cylinders
Make object cylinder 20, 12
Make object cylinder 8, 12
Make object cylinder 9, 12
Make Object Cylinder 10, 12
Make object cylinder 11, 12
Make object cylinder 12, 12
TEXTURE OBJECT 20, 11
TEXTURE OBJECT 8, 11
TEXTURE OBJECT 9, 11
TEXTURE OBJECT 10, 11
TEXTURE OBJECT 11, 11
TEXTURE OBJECT 12, 11
Rem Create Cones
make object cone 13, 30
make object cone 14, 30
make object cone 15, 30
make object cone 16, 30
make object cone 17, 30
make object cone 18, 30
TEXTURE OBJECT 13, 10
TEXTURE OBJECT 14, 10
TEXTURE OBJECT 15, 10
TEXTURE OBJECT 16, 10
TEXTURE OBJECT 17, 10
TEXTURE OBJECT 18, 10
Rem Position Cylinders
position object 20,25,-7, -150
position object 9,75,-7, 150
position object 10,-25,-7, 84
position object 11,-75,-7, -84
position object 12,30,-7, 46
position object 8,-30,-7, -46
Rem Positions Cones
position object 13,25,12, -150
position object 14,75,12, 150
position object 15,-25,12, 84
position object 17,-75,12, -84
position object 18,30,12, 46
position object 16,-30,12,-46
Rem Color Trees
color object 20, rgb(139,69,19)
color object 8, rgb(139,69,19)
color object 9, rgb(139,69,19)
color Object 10, rgb(139,69,19)
color object 11, rgb(139,69,19)
color object 12, rgb(139,69,19)

color object 13, rgb(0,100,0)
color object 14, rgb(0,100,0)
color object 15, rgb(0,100,0)
color object 16, rgb(0,100,0)
color object 17, rgb(0,100,0)
color object 18, rgb(0,100,0)
Rem Create Boxes
make object box 25, 10,10,10
make object box 26, 10,10,10
make object box 27, 10,10,10
make object box 28, 10,10,10
make object box 29, 10,10,10
make object box 30, 10,10,10





Rem Place Spheres
position object 25,RND(500),0, RND(500)
position object 26,RND(500),0, RND(500)
position object 27,RND(500),0, RND(500)
position object 28,RND(500),0, RND(500)
position object 29,RND(500),0, RND(500)
position object 30,RND(500),0, RND(500)
rem Color Rocks
TEXTURE OBJECT 25,5
TEXTURE OBJECT 26,6
TEXTURE OBJECT 27, 7
TEXTURE OBJECT 28, 8
TEXTURE OBJECT 29,5
TEXTURE OBJECT 30, 6
Rem Player
make object cone 1,10
color object 1,rgb(0,0,255)
TEXTURE OBJECT 20, 11
TEXTURE OBJECT 8, 11
TEXTURE OBJECT 9, 11
TEXTURE OBJECT 10, 11
TEXTURE OBJECT 11, 11
TEXTURE OBJECT 12, 11
TEXTURE OBJECT 13, 10
TEXTURE OBJECT 14, 10
TEXTURE OBJECT 15, 10
TEXTURE OBJECT 16, 10
TEXTURE OBJECT 17, 10
TEXTURE OBJECT 18, 10





do
REM OBJECT ORIENTATIONS
P1X# = object position X(1)
P1Y# = object position Y(1)
P1Z# = object position Z(1)
A1X = object angle X(1)
A1Y = object angle Y(1)
A1Z = object angle Z(1)
REM CAMERA ORIENTATIONS
Rem Store the positions of the Camera as variables
cpX# = camera position X()
cpY# = camera position Y()
cpZ# = camera position Z()
Rem Store the angles of the Camera as variables
caX# = camera angle X()
caY# = camera angle Y()
caZ# = camera angle Z()




if object collision(1,2)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,3)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,4)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,5)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,6)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,7)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,8)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,9)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,10)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,11)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,12)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,13)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,14)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,15)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,16)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,17)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,18)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,19)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,20)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,21)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,22)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,23)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,24)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,25)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,26)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,27)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,28)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,29)= 1
position object 1, P1X#,P1Y#,P1Z#
if object collision(1,30)= 1
position object 1, P1X#,P1Y#,P1Z#
if keystate(200) = 1
move object 1,2
endif

if keystate(208) = 1
move object 1,-2
endif

if keystate(203) = 1
turn object left 1,2
endif

if keystate(205) = 1
turn object right 1,2
endif

`Camera settings
rotate camera 0,0,0
position camera 0,object position x(1),object position y(1)+10,object position z(1)
rotate camera 0,object angle x(1),object angle y(1),object angle z(1)
move camera 0,-30

sync
loop



Rem **Create Walls**
function makeWall(ID, xsize, ysize, zsize, xp, yp, zp, color)
make object box ID, xsize, ysize, zsize
position object ID, xp, yp, zp
color object ID, color
set object texture ID, 100, 1
endfunction
Derek Darkly
12
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 12th Nov 2016 15:06 Edited at: 12th Nov 2016 15:18
Hello! I see you are checking collision against 30 objects or so....
This would be much simpler:



However, it appears that your code puts the player in the place he is already in when a collision occurs, unless I read it wrong.
I'm sure you'll work that part out though.

Cheers!
Send your parents to noisy sprite demo hell... enter the D-Zone
Derek Darkly
12
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 12th Nov 2016 15:15

Also, I wouldn't get into the habit of using full paths to load your media, since your future players won't have the same directories as you.

Use:
load image ".\Textures\bloodmoon.png", 1

Looks like you're off to a good start though, keep at it.
Send your parents to noisy sprite demo hell... enter the D-Zone
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 14th Nov 2016 14:48
Looking at your main loop, I notice a couple of issues.

You are missing the “endif” on the last two collision checks.

if object collision(1,29)= 1
position object 1, P1X#,P1Y#,P1Z#
if object collision(1,30)= 1
position object 1, P1X#,P1Y#,P1Z#


After commenting the media loading and compiling the code, I get “object does not exist” errors on the following collision checks.

if object collision(1,7)= 1
position object 1, P1X#,P1Y#,P1Z#
endif

if object collision(1,19)= 1
position object 1, P1X#,P1Y#,P1Z#
endif

if object collision(1,21)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,22)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,23)= 1
position object 1, P1X#,P1Y#,P1Z#
endif
if object collision(1,24)= 1
position object 1, P1X#,P1Y#,P1Z#
endif

Login to post a reply

Server time is: 2024-03-28 18:12:33
Your offset time is: 2024-03-28 18:12:33