// from gameobj moveByTimeFn_accel func (m SPObj) TestMoveByAccel(accelVector go4game.Vector3D) *SPObj { dur := 1.0 / GameConst.FramePerSec m.MoveVector = m.MoveVector.Add(accelVector.Imul(dur)) if m.MoveVector.Abs() > GameConst.MoveLimit[m.ObjType] { m.MoveVector = m.MoveVector.NormalizedTo(GameConst.MoveLimit[m.ObjType]) } m.PosVector = m.PosVector.Add(m.MoveVector.Imul(dur)) return &m }
func makeAccel_wideSpace(a *AIAdv) *go4game.Vector3D { act := ActionAccel var vt go4game.Vector3D for i, o := range a.preparedTargets[act] { if i > 3 { // apply max 3 target break } if o.actFactor > 1 { vt = vt.Add(a.calcBackVector(o.SPObj, o.actFactor)) } } if vt.Abs() < 10 { vt = vt.Add(a.HomePos.Sub(a.me.PosVector)) } return &vt }
func main() { v1 := go4game.Vector3D{0, 0, 0} v2 := go4game.Vector3D{1, -1, 1} d8 := v1.To8Direct(v2) fmt.Printf("%v %v %v\n", v1, v2, d8) hr := go4game.HyperRect{ go4game.Vector3D{-10, -10, -10}, go4game.Vector3D{10, 10, 10}, } nhr := hr.MakeCubeBy8Driect(v1, d8) fmt.Printf("%v %v %v isin %v\n", hr, nhr, d8, v2.IsIn(nhr)) }
func (a *AIAdv) AimAdjedIntoCube(estpos *go4game.Vector3D, o *SPObj, bulletType GameObjectType) *go4game.Vector3D { if !estpos.IsIn(GameConst.WorldCube2) && o.ObjType != GameObjMain { return nil } lenori := a.me.PosVector.LenTo(*estpos) if o.ObjType == GameObjMain { changed := estpos.MakeIn(GameConst.WorldCube) if changed != 0 { //log.Printf("target %v bounce %b", o.ID, changed) } } lennew := a.me.PosVector.LenTo(*estpos) lenrate := lennew / lenori vt := estpos.Sub(a.me.PosVector).NormalizedTo(GameConst.MoveLimit[bulletType]).Imul(lenrate) return &vt }