Hmmm, ok..I have an area loaded up in my little learning-experience-program, and I am trying to add a couple of loaded objects to it. Basically, I have an encircled area, lined with pillars. There is quite a large inner area made by the walls. I have tried several times to load up images within the walls, and for some reason, they keep appearing on the outside wall(?!?!). At no point in my code do define those objects to be outside the walls. As you will see by my subroutines at the end of the code, I have it set so that these objects will turn around after they reach a certain point, and I also added in a random factor to turn them on a 2 in 6 chance (provided they are "in-bounds").
The first object
is actually stationed on the outside of the walls, and I have no issues with him. It is the second and third enemy that I am having problems with. I place them within the area inclosed in the walls (of which I have a little alley into), and set up "boundries" within the walls in the subroutine to dictate their movements and turns, but they
keep showing up outside the walls!! I am at a loss...
For those that did not want to read my rant: CONDENSED VERSION
I keep trying to place enemies 2 and 3 within a closed in area of walls, and they keep appearing on the outside. Thanks for reading and helping! Code:
sync on
sync rate 60
randomize timer()
backdrop on
fog on
fog distance 4000
set camera range 1,5000
load sound "music misty room loop.wav",1
loop sound 1
load sound "THUMP.wav",2
load sound "9_53.wav",3
Hide Mouse
rem start Nukin'
StartCollisionPro( 000000000, 000000000, 000000000 )
StartCollisionDebugPro()
rem declare some constants
#Constant TYPE_NGC_ELLIP=1
#Constant TYPE_NGC_MESH=2
#Constant ELLIP_2_ELLIP=1
#Constant ELLIP_2_POLY=2
#Constant RESP_STICK=1
#Constant RESP_SLIDE=2
#Constant RESP_SLIDE_NO_SLOPES=3
#Constant RESP_SLIDE_NO_GRAV=4
#Constant RESP_NONE=5
#Constant DYN_NO_RESP=1
#Constant DYN_RESP=2
#Constant DYN_RESP_LOCK=3
#Constant DYN_RESP_LOCK_NOTURN=4
#constant TYPE_PLAYER = 1
#constant TYPE_OBJ = 17
#constant TYPE_ENEMY = 2
rem Begin Collision Detections
rem Define Player to enemy collision
SetCollisionsPro( TYPE_PLAYER, TYPE_ENEMY, ELLIP_2_ELLIP, RESP_SLIDE, DYN_NO_RESP )
rem Define Enemy to player collision
SetCollisionsPro( TYPE_ENEMY, TYPE_PLAYER, ELLIP_2_ELLIP, RESP_SLIDE, DYN_NO_RESP )
rem Define Player to World Objects
SetCollisionsPro( TYPE_PLAYER, TYPE_OBJ, ELLIP_2_POLY, RESP_SLIDE, DYN_RESP )
rem Define Enemy to World Objects
SetCollisionsPro( TYPE_ENEMY, TYPE_OBJ, ELLIP_2_POLY, RESP_SLIDE, DYN_RESP )
rem set fog
fog color rgb(28,28,0)
color backdrop rgb(28,28,28)
rem make matrix
make matrix 1,10000,10000,20,20
load image "lead.bmp",1
prepare matrix texture 1,1,1,1
position camera 100,0,100
rem load player
player = 1
load object "L-Knight-Idle.x",player
append object "L-Knight-Move.x",player,25
append object "L-Knight-Attack1.x",player,50
append object "H-Knight-Impact.x",player,75
rem set up player
CollisionTypePro( player, TYPE_PLAYER )
SetObjRadiusPro( player, 8, 6, 8 )
SetObjScalePro(player,4000,4000,4000)
yrotate object player,180
fix object pivot player
position object 1,15,0,15
set object collision to boxes 1
rem load enemy
monX# = 150
monZ# = 150
rollbug = 3
load object "L-Alien Rollerbug-Idle.x",rollbug
append object "L-Alien Rollerbug-Attack1.x",rollbug,25
rem set up monster
CollisionTypePro( rollbug, TYPE_ENEMY )
SetObjRadiusPro( rollbug, 8, 6, 8 )
SetObjScalePro(rollbug,4000,4000,4000)
position object rollbug,monX#,0,monZ#
set object collision to boxes 3
rem load 2nd enemy
floater = 32
load object "L-Alien Psionic-Idle.x",floater
CollisionTypePro( floater, TYPE_ENEMY )
SetObjRadiusPro( floater, 8, 6, 8 )
SetObjScalePro( floater, 4000, 4000, 4000 )
yrotate object floater,180
fix object pivot floater
set object collision to boxes 32
position object floater,400,0,10
loop object floater
rem make 3rd enemy
floater2 = 33
load object "L-Alien Psionic-Idle.x",floater2
CollisionTypePro( floater2, TYPE_ENEMY )
SetObjRadiusPro( floater2, 8, 6, 8 )
SetObjScalePro( floater2, 4000, 4000, 4000 )
yrotate object floater2,180
fix object pivot floater2
set object collision to boxes 33
position object floater2,779,0,700
loop object floater2
rem load spectre 4th enemy
gob = 34
load object "L-Spectre-Move.x",gob
CollisionTypePro( gob, TYPE_ENEMY )
SetObjRadiusPro( gob, 8, 6, 8 )
SetObjScalePro( gob, 4000, 4000, 4000 )
yrotate object gob,180
fix object pivot gob
set object collision to boxes 34
position object gob, 992,0,953
ghost object on 34, 1
rem make pillar
pillar = 2
load image "Sandstone_cliff_T.bmp",pillar
make object box pillar,400,10000,400
position object pillar,400,0,400
texture object pillar,2
CollisionTypePro( pillar, TYPE_OBJ )
rem make 2nd pillar
pillar2 = 4
make object box pillar2,400,10000,400
position object pillar2,900,0,400
texture object pillar2,2
CollisionTypePro( pillar2, TYPE_OBJ )
pillar3 = 5
make object box pillar3,400,10000,400
position object pillar3,1300,0,400
texture object pillar3,2
CollisionTypePro( pillar3, TYPE_OBJ )
pillar4 = 6
make object box pillar4,400,10000,400
position object pillar4,400,0,800
texture object pillar4,2
CollisionTypePro( pillar4, TYPE_OBJ )
pillar5 = 7
make object box pillar5,400,10000,400
position object pillar5,1700,0,400
texture object pillar5,2
CollisionTypePro( pillar5, TYPE_OBJ )
pillar6 = 8
make object box pillar6,400,10000,400
position object pillar6,1700,0,800
texture object pillar6,2
CollisionTypePro( pillar6, TYPE_OBJ )
pillar7 = 9
make object box pillar7,400,10000,400
position object pillar7,400,0,1200
texture object pillar7,2
CollisionTypePro( pillar7, TYPE_OBJ )
pillar8 = 10
make object box pillar8,400,10000,400
position object pillar8,1700,0,1200
texture object pillar8,2
CollisionTypePro( pillar8, TYPE_OBJ )
pillar9 = 11
make object box pillar9,400,10000,400
position object pillar9,400,0,1600
texture object pillar9,2
CollisionTypePro( pillar9, TYPE_OBJ )
pillar10 = 12
make object box pillar10,400,10000,400
position object pillar10,1700,0,1600
texture object pillar10,2
CollisionTypePro( pillar10, TYPE_OBJ )
pillar11 = 13
make object box pillar11,1400,10000,400
position object pillar11,400,0,1600
texture object pillar11,2
CollisionTypePro( pillar11, TYPE_OBJ )
pillar12 = 14
make object box pillar12,400,10000,400
position object pillar12,1700,0,2000
texture object pillar12,2
CollisionTypePro( pillar12, TYPE_OBJ )
pillar13 = 15
make object box pillar13,400,10000,400
position object pillar13,400,0,2000
texture object pillar13,2
CollisionTypePro( pillar13, TYPE_OBJ )
pillar14 = 16
make object box pillar14,400,10000,400
position object pillar14,400,0,2400
texture object pillar14,2
CollisionTypePro( pillar14, TYPE_OBJ )
pillar15 = 17
make object box pillar15,400,10000,400
position object pillar15,400,0,2800
texture object pillar15,2
CollisionTypePro( pillar15, TYPE_OBJ )
pillar16 = 18
make object box pillar16,400,10000,400
position object pillar16,400,0,3200
texture object pillar16,2
CollisionTypePro( pillar16, TYPE_OBJ )
pillar17 = 19
make object box pillar17,400,10000,400
position object pillar17,2100,0,2400
texture object pillar17,2
CollisionTypePro( pillar17, TYPE_OBJ )
pillar18 = 20
make object box pillar18,400,10000,400
position object pillar18,2100,0,2800
texture object pillar18,2
CollisionTypePro( pillar18, TYPE_OBJ )
pillar19 = 21
make object box pillar19,400,10000,400
position object pillar19,2100,0,3200
texture object pillar19,2
CollisionTypePro( pillar19, TYPE_OBJ )
pillar20 = 22
make object box pillar20,400,10000,400
position object pillar20,2100,0,3600
texture object pillar20,2
CollisionTypePro( pillar20, TYPE_OBJ )
pillar21 = 23
make object box pillar21,400,10000,400
position object pillar21,2100,0,4000
texture object pillar21,2
CollisionTypePro( pillar21, TYPE_OBJ )
pillar22 = 24
make object box pillar22,400,10000,400
position object pillar22,2100,0,4400
texture object pillar22,2
CollisionTypePro( pillar22, TYPE_OBJ )
pillar23 = 25
make object box pillar23,400,10000,400
position object pillar23,2100,0,4800
texture object pillar23,2
CollisionTypePro( pillar23, TYPE_OBJ )
pillar24 = 26
make object box pillar24,400,10000,400
position object pillar24,2100,0,5200
texture object pillar24,2
CollisionTypePro( pillar24, TYPE_OBJ )
pillar25 = 27
make object box pillar25,400,10000,400
position object pillar25,400,0,3600
texture object pillar25,2
CollisionTypePro( pillar25, TYPE_OBJ )
pillar26 = 28
make object box pillar26,400,10000,400
position object pillar26,400,0,4000
texture object pillar26,2
CollisionTypePro( pillar26, TYPE_OBJ )
pillar27 = 29
make object box pillar27,400,10000,400
position object pillar27,400,0,4400
texture object pillar27,2
CollisionTypePro( pillar27, TYPE_OBJ )
pillar28 = 30
make object box pillar28,400,10000,400
position object pillar28,400,0,4800
texture object pillar28,2
CollisionTypePro( pillar28, TYPE_OBJ )
pillar29 = 31
make object box pillar29,400,10000,400
position object pillar29,400,0,5200
texture object pillar29,2
CollisionTypePro( pillar29, TYPE_OBJ )
health = 100
a = 0
rem main game loop
Do
rem set attack flag to off
attack = 0
rem loop monster1 and get monster's positions
MangleY# = object angle Y(3)
MangleX# = object angle X(3)
loop object 3,1,25
rem set up health bar
set cursor 0,0
box 10,20,health,30,0,255,0,0
rem get last frame
totalz3 = total object frames(3)
totalz = total object frames(1)
rem X print totalz
flX# = object position X(32)
flY# = object position Y(32)
flZ# = object position Z(32)
fl2X# = object position X(floater2)
fl2Y# = object position Y(floater2)
fl2Z# = object position Z(floater2)
print X#
print Y#
print Z#
loop object 1,1,25
Rem Store Object angle Y in aY#
aY# = Object angle Y(1)
If Upkey()=1
XTest# = Newxvalue(X#,CameraAngleY#,3)
ZTest# = Newzvalue(Z#,CameraAngleY#,3)
If XTest#>0 and XTest#<10000 and ZTest#>0 and ZTest#<10000
Move object 1,3
loop object 1,25,50
Endif
if XTest#<=0 and XTest#>=10000 and ZTest#<=0 and ZTest#>=10000
position object 1,X#,0,Z#
endif
Endif
if downkey()=1
move object 1,-3
loop object 1,25,50
endif
if spacekey()=1
loop object 1,50,75
soundInt = sound playing(2)
rem X if soundInt = 0 then play sound 2
attack = 1
endif
if controlkey()=1
health = health - 1
if health<0 then health = 0
endif
if shiftkey()=1
health = health + 1
if health>100 then health = 100
endif
If Leftkey()=1 then Yrotate object 1,Wrapvalue(aY#-2.5)
If Rightkey()=1 then Yrotate object 1,Wrapvalue(aY#+2.5)
rem move monster1
if scancode() = 2
move object 3,1.75
endif
rem move monster1 back
if scancode() = 3
move object 3,-1.75
endif
rem attempt to rotate monster1 on Y axis
if scancode() = 4
Yrotate object 3,wrapvalue(MangleY#+1.5)
endif
if scancode() = 5
Yrotate object 3,wrapvalue(MangleY#-1.5)
endif
rem make monster1 test attack
if scancode() = 6
loop object 3,25,50
soundInt2 = sound playing(3)
if soundInt2 = 0 then play sound 3
endif
if scancode() = 7
show object 3
endif
rem check for defeated monster
if object collision(1,3)
if attack = 1
hide object 3
endif
if attack = 0
health = health - 0.1
loop object 1,75,85
endif
endif
rem check collisions for floater monster
if object collision(1,32)
if attack = 1
hide object 32
endif
if attack = 0
health = health - 0.1
loop object 1,75,85
endif
endif
if object collision(1,33)
if attack = 1
hide object 33
endif
if attack = 0
health = health - 0.1
loop object 1,75,85
endif
endif
gosub floatermove
gosub floatermove2
Rem get player object position and store in X# and Z#
X# = Object position x(1)
Z# = Object position z(1)
rem store monster1 position
monX# = object position x(3)
monZ# = object position z(3)
rem THE PROBLEM MAY BE BEGINNING HERE
rem THIS IS WHERE I AM TRYING TO GET THE ANGLE
rem OF THE OBJECTS SO I CAN COMPARE
rem THEM
rem make enemy turn towards player
pAngleY# = object angle y(1)
MangleY# = object angle y(3)
REM THIS IS WHERE I AM TRYING TO COMPARE
REM THE ANGLES SO THAT THE MONSTER WILL MOVE TO
REM "LOOK" AT THE PLAYER, THEN WILL FOLLOW HIM
REM IF THEY ARE STRAIGHT TOWARDS EACH OTHER
if MangleY# < pAngleY#
Yrotate object 3,wrapvalue(MangleY#-1.5)
if MangleY# = pAngleY#
move object 3,3
endif
endif
if MangleY# > pAngleY#
yrotate object 3,wrapvalue(MangleY#+1.5)
if MangleY# = pAngleY#
move object 3,3
endif
endif
Rem get new camera position and store in cZ# and cX#
cZ# = Newzvalue(Z#,aY#-180,100)
cX# = Newxvalue(X#,aY#-180,100)
Rem position camera
Position Camera cX#,100,cZ#
Rem point the camera at the player object
Point camera X#,50,Z#
rem run Nuclear Glory
RunCollisionPro()
Rem Refresh Screen
Sync
Loop
floatermove:
flAngle# = object angle y(floater)
if flZ# > 190
yrotate object floater,wrapvalue(flAngle#-2.5)
endif
if flX# < 0
yrotate object floater,wrapvalue(flAngle#+2.5)
endif
if flZ# < 0
yrotate object floater,wrapvalue(flAngle#-2.5)
endif
randseed = RND(5)
if randseed = 1 and flZ# > 0 and flX# > 0 and flZ# < 190
yrotate object floater,wrapvalue(flAngle#-2.5)
endif
if randseed = 2 and flZ# > 0 and flX# > 0 and flZ# < 190
yrotate object floater,wrapvalue(flAngle#-2.5)
endif
move object floater, 1
return
floatermove2:
flAngle2# = object angle y(floater2)
if fl2Z# > 190
yrotate object floater2,wrapvalue(flAngle2#-2.5)
endif
if fl2X# < 350
yrotate object floater2,wrapvalue(flAngle2#+2.5)
endif
if fl2X# > 600
yrotate object floater2,wrapvalue(flAngle2#+2.5)
endif
if fl2Z# < 0
yrotate object floater2,wrapvalue(flAngle2#-2.5)
endif
randseed = RND(5)
if randseed = 1 and fl2Z# < 190 and fl2X# >350 and fl2X# < 600 and fl2Z# > 0
yrotate object floater2,wrapvalue(flAngle2#-2.5)
endif
if randseed = 2 and fl2Z# < 190 and fl2X# >350 and fl2X# < 600 and fl2Z# > 0
yrotate object floater2,wrapvalue(flAngle2#-2.5)
endif
move object floater2, 1
return
P.S.- I am using DBpro and Nuclear Glory Collision, but I do not think the NGC is interfering with the placement of the objects, but..hey...maybe I am wrong
"I attribute the quarrelsome nature of the Middle Ages young men entirely to the want of the soothing weed."
-Jerome K. Jerome(1859-1927),Writer