I have already managed to do many things, but there are some things I don't understand:
1. Some element in the game are not real 3D objects, but 2D sprites, and these sprites would change their sub-images according to their direction. Just like in game Doom I. and II.
But how can I get the actual direction of a game object?
I tried so:
Code: Select all
subimg(0)=monsterrunback(enemy(e).subimg)
subimg(1)=monsterrunbackright(enemy(e).subimg)
subimg(2)=monsterrunright(enemy(e).subimg)
subimg(3)=monsterrunforwardright(enemy(e).subimg)
subimg(4)=monsterrunforward(enemy(e).subimg)
subimg(5)=monsterrunforwardleft(enemy(e).subimg)
subimg(6)=monsterrunleft(enemy(e).subimg)
subimg(7)=monsterrunbackleft(enemy(e).subimg)
tex=subimg(int(entityyaw#(enemy(e).img)*8/360)) '???
entitytexture enemy(e).img,tex
But I get strange results, and besides, when the enemy shoot based on enemy's direction, the bullets often go into wrong direction, so probably I set the direction wrong:
Code: Select all
turnentity enemybullet(numofenbullets).img,entitypitch#(enemy(e).img),entityyaw#(enemy(e).img),entityroll#(enemy(e).img)
Which command gives me the direction of the object?
2. I tried to make a simple program to check these things (angle, direction, etc.), but I can't display the results as a text on the screen. I can display texts hardly and I can't clear the HUD when I write onto it.
Besides, I tried to rotate the cone towards sphere with its tip, but I couldn't done it.
Code: Select all
#Include "openb3d.bi"
#include "fbgfx.bi"
Using FB
ScreenRes 800,600,32,,&h10002
Graphics3d 800,600
dim shared as any ptr hudimage,hudstringtex,camera,imgtohud,cone,sphere
dim shared as integer pitch,yaw,roll
camera=createCamera()
var light=createLight()
cone=CreateCone(16)
PositionEntity cone,0,0,5
sphere=CreateSphere(16)
PositionEntity sphere,-3,0,5
imgtohud=imagecreate(128,32,32)
hudimage=CreateSprite(camera)
MoveEntity hudimage,3.8,2.5,5
EntityOrder hudimage,-1
hudstringtex=CreateTexture(128,32)
EntityTexture hudimage,hudstringtex
Do
roll=0
pitch=0
yaw=0
if multikey(sc_up) then
roll+=1
end if
if multikey(sc_down) then
roll-=1
end if
if multikey(sc_left) then
pitch-=1
end if
if multikey(sc_right) then
pitch+=1
end if
if multikey(sc_e) then
yaw+=1
end if
if multikey(sc_d) then
yaw-=1
end if
'TurnEntity cone,pitch,yaw,roll
do
turnentity cone,0,deltayaw#(cone,sphere),0
loop until (deltayaw#(cone,sphere)>-8) and (deltayaw#(cone,sphere)<8)
draw string imgtohud,(1,1),"P.: "+str(pitch)
BufferToTex hudstringtex,imgtohud,1
draw string imgtohud,(1,10),"Y: "+str(int(entityyaw#(cone)))
BufferToTex hudstringtex,imgtohud,1
draw string imgtohud,(1,20),"R: "+str(roll)
BufferToTex hudstringtex,imgtohud,1
updateworld
renderworld
Flip
Loop Until MultiKey(sc_q)
So, my questions:
1. How can I determine the right directions of the game objects?
2. How can I set the right subimage to the game objects based on those directions?
3. What is the simplest and best way of display texts on the screen? Can I clear the buffer of
hudstringtex or
imgtohud somehow?