hay guys, Im having a problem with a bit of code im trying to construct, and im wondering if someone with a bit/lot more knowledge can point me in the right direction.
firstly, My game engine uses a height map that generates the game map.
then i make a matrix the size of a window(for a better description), of the area you flying over. this is fine so far.
Then i put in some objects and and only show them if their in the viewrange ect....
Now all is ok so far, accept when u near the end of the map.
Now...... the process is, the camera fly's over the map, and moves freely in 3d space, the matrix is centered and follows the camera. When u reach the map thresholds u loop back around to the begining.
EG. map is 300*300
camera is allowed to move 300*tilesize then back to 0
but as u can imagine, when u loop back to 0 or even b4 u do, u cannot see the enemy's on the other edge of the map. and vice verca.
So, im left with a little task of wrapping another window around the map to get distance between me and the mobs.
Now this is the bit that has me stumped. i managed to sorta get x and z past 300 to work(sorta!) but cant figure out how to do it the other way. Or is there still a better way again.
here.... hopefully is the code i have for now that works(sorta)
vx#=camera position x()
vz#=camera position z()
viewrange=14000
vx#=vx#-(viewrange/2)
vz#=vz#-(viewrange/2)
for mob=1 to enemymax
if enemyalive(mob)=1
mx#=enemyposx#(mob)
mz#=enemyposz#(mob)
dx#=mx#-vx#
dz#=mz#-vz#
if abs(dx#)<viewrange and abs(dz#)<viewrange
` show creature
`show object mob
obx#=vx#+dx#
obz#=vz#+dz#
position object mob,obx#,5000,obz#
yrotate object mob,enemyangle(mob)
change mesh mob,0,enemyanim(mob)+50
texture object mob,50
else
` hide creature
position object mob,-1000000,-1000000,-1000000
endif
`**************************************************************
if viewrange+vx#>mapsize
` check if we're looking over the x end of the map
xrange#=viewrange+vx#-mapsize
if mx#<xrange# and dz#<viewrange
` show creature
`show object mob
obx#=vx#+mx#
`obz#=vz#+dz#
position object mob,obx#,5000,mz#
yrotate object mob,enemyangle(mob)
change mesh mob,0,enemyanim(mob)+50
texture object mob,50
else
` hide creature
position object mob,-1000000,-1000000,-1000000
endif
endif
endif
Anyway, any help would be appreciated.
cheers
crighton
aye!