Пример #1
0
func NewAudioListener() *AudioListener {
	if Listener == nil {
		Listener = new(openal.Listener)
		Listener.SetOrientation(0, 0, -1, 0, 1, 0)
	}
	return &AudioListener{engine.NewComponent(), Listener}
}
Пример #2
0
func NewShipController() *ShipController {
	misslesDirection := [][]engine.Vector{{{0, 1, 0}, {0, 1, 0}},
		{{-0.2, 1, 0}, {0.2, 1, 0}, {0, 1, 0}},
		{{-0.2, 1, 0}, {0.2, 1, 0}, {0, 1, 0}, {-0.2, 1, 0}, {0.2, 1, 0}}}

	misslePositions := []engine.Vector{{-28, 10, 0}, {28, 10, 0}, {0, 20, 0}, {-28, 40, 0}, {28, 40, 0}}

	return &ShipController{engine.NewComponent(), 500000, 250, nil, misslePositions, misslesDirection, 0, len(misslesDirection) - 1,
		time.Now(), nil, nil, true, nil, nil, nil, []engine.Vector{{-0.1, -0.51, 0}, {0.1, -0.51, 0}}, nil}
}
Пример #3
0
func NewAudioSource(clip AudioClip) *AudioSource {
	as := &AudioSource{engine.NewComponent(), openal.NewSource(), false, InverseDistanceClamped, nil, nil, nil, true, false, 0}
	if clip != nil {
		c, e := clip.Clone()
		if e != nil {
			panic(e)
		}
		as.Clip = c
	}
	as.source.SetMinGain(0)
	as.source.SetMaxGain(1)
	if clip.AudioFormat() == Mono16 || clip.AudioFormat() == Mono8 {
		as.Set2D()
	}
	return as
}
Пример #4
0
func NewUIText(font *engine.Font, text string) *UIText {
	if font == nil {
		return nil
	}

	uitext := &UIText{BaseComponent: engine.NewComponent(),
		Font:      font,
		text:      text,
		buffer:    engine.GenBuffer(),
		align:     engine.AlignCenter,
		writeable: false,
		tabSize:   4,
		Color:     engine.Color_White}

	uitext.setString(text)
	input.AddCharCallback(func(rn rune) { uitext.charCallback(rn) })
	return uitext
}
Пример #5
0
func Connect(name string, errChan *chan error) {
	*errChan = make(chan error)
	/*
		addr, err := net.ResolveTCPAddr("tcp", ServerIP)
		if err != nil {
			*errChan <- err
			return
		}
	*/
	//con, err := net.DialTCP("tcp", nil, addr)
	con, err := net.DialTimeout("tcp", ServerIP, time.Second*4)
	if err != nil {
		con, err = net.DialTimeout("tcp", ServerLocalIP, time.Second*4)
		if err != nil {
			*errChan <- fmt.Errorf("Game Server is down :(.")
			return
		}
	}
	tcpCon := con.(*net.TCPConn)
	MyClient = &Client{BaseComponent: engine.NewComponent(), Socket: tcpCon, Name: name, Encoder: gob.NewEncoder(tcpCon), Decoder: gob.NewDecoder(tcpCon), Jobs: make(chan func(), 1000), GameJobs: make(chan func(), 1000)}
	go MyClient.Run()
	LoginErrChan = *errChan
}
Пример #6
0
func NewMouseDebugger() *MouseDebugger {
	return &MouseDebugger{engine.NewComponent()}
}
Пример #7
0
func NewDamageDealer(dmg float32) *DamageDealer {
	return &DamageDealer{BaseComponent: engine.NewComponent(), Damage: dmg}
}
Пример #8
0
func NewResizeScript(minX, mediumX, maxX, minY, mediumY, maxY float32) *ResizeScript {
	return &ResizeScript{BaseComponent: engine.NewComponent(), MinX: minX, MediumX: mediumX, MaxX: maxX, MinY: minY, MediumY: mediumY, MaxY: maxY, Speed: 3}
}
Пример #9
0
func NewSmoothFollow(target *engine.GameObject, speed float32, maxdis float32) *SmoothFollow {
	return &SmoothFollow{engine.NewComponent(), target, speed, maxdis}
}
Пример #10
0
func NewCameraCtl(speed float64) *CameraController {
	return &CameraController{engine.NewComponent(), speed}
}
Пример #11
0
func NewPowerUp(typ Power) *PowerUp {
	return &PowerUp{BaseComponent: engine.NewComponent(), Type: typ}
}
Пример #12
0
func NewUIButton(ClickCallback func(), HoverCallback func(bool)) *UIButton {
	return &UIButton{engine.NewComponent(), ClickCallback, HoverCallback, false}
}
Пример #13
0
func newTweens(t *Tween) *Tweens {
	ts := &Tweens{engine.NewComponent(), make([]*Tween, 0, 2)}
	ts.AddTween(t)
	return ts
}
Пример #14
0
func NewPlayerController() *PlayerController {
	return &PlayerController{engine.NewComponent(), 10, 20000, nil, -1, nil, nil, make([]*engine.GameObject, 0)}
}
Пример #15
0
func NewDestoyable(hp float32, team int) *Destoyable {
	return &Destoyable{BaseComponent: engine.NewComponent(), FullHP: hp, Alive: true, HP: hp, Team: team}
}
Пример #16
0
func NewPlayer() *Player {
	return &Player{BaseComponent: engine.NewComponent()}
}
Пример #17
0
func NewController() *Controller {
	return &Controller{engine.NewComponent(), 100}
}
Пример #18
0
func NewCollider() *Collider {
	return &Collider{engine.NewComponent(), nil}
}
Пример #19
0
func NewMissle(speed float32) *Missle {
	return &Missle{BaseComponent: engine.NewComponent(), Speed: speed}
}
Пример #20
0
func NewRotator() *Rotator {
	return &Rotator{engine.NewComponent()}
}
Пример #21
0
func NewMap(tex *engine.Texture, uv engine.AnimatedUV) *Map {

	return &Map{BaseComponent: engine.NewComponent(),
		Sprite: engine.NewSprite3(tex, uv)}
}
Пример #22
0
func NewPlayerController(player *Player) *PlayerController {
	return &PlayerController{engine.NewComponent(), player, nil, nil, 200}
}
Пример #23
0
func NewEnemeyAI(target *engine.GameObject, typ EnemeyType) *EnemeyAI {
	return &EnemeyAI{BaseComponent: engine.NewComponent(), Target: target, Type: typ}
}
Пример #24
0
func NewBackground(sprite *engine.Sprite) *Background {
	return &Background{BaseComponent: engine.NewComponent(), sprite: sprite}
}