Example #1
0
func (sp *CameraController) Update() {
	t := sp.GameObject().Transform()

	if input.KeyDown('A') {
		t.Translatef(float32(-sp.Speed*engine.DeltaTime()), 0)
	}
	if input.KeyDown('D') {
		t.Translatef(float32(sp.Speed*engine.DeltaTime()), 0)
	}
	if input.KeyDown('S') {
		t.Translatef(0, float32(-sp.Speed*engine.DeltaTime()))
	}
	if input.KeyDown('W') {
		t.Translatef(0, float32(sp.Speed*engine.DeltaTime()))
	}
	if input.KeyDown('E') {
		engine.CurrentCamera().SetSize(engine.CurrentCamera().Size() + float32(engine.DeltaTime()))
	}
	if input.KeyDown('Q') {
		engine.CurrentCamera().SetSize(engine.CurrentCamera().Size() - float32(engine.DeltaTime()))
	}

	if input.KeyDown('Z') {
		a := t.Angle()
		t.SetWorldRotationf(a + float32(engine.DeltaTime())*10)
	}
	if input.KeyDown('X') {
		a := t.Angle()
		t.SetWorldRotationf(a - float32(engine.DeltaTime())*10)
	}
}
Example #2
0
func (m *MouseDebugger) Update() {
	if input.MouseDown(input.MouseMiddle) {
		if queenDead {
			mousePosition := m.Transform().WorldPosition()

			c := cookie.Clone()
			//c.Tag = CookieTag
			c.Transform().SetParent2(GameSceneGeneral.Layer2)
			size := 25 + rand.Float32()*100
			c.Transform().SetPosition(mousePosition)
			c.Transform().SetScalef(size, size)
		}
	}
	if input.MouseDown(input.MouseRight) {

		mousePosition := m.Transform().WorldPosition()

		b := defender.Clone()
		/*
			phx := b.AddComponent(NewPhysics(false, 50, 50)).(*Physics)
			phx.Shape.SetFriction(0.5)
			//phx.Shape.Group = 2
			phx.Shape.SetElasticity(0.5)
		*/
		b.Transform().SetParent2(GameSceneGeneral.Layer2)
		b.Transform().SetWorldPosition(mousePosition)
		b.Transform().SetScalef(50, 50)

	}

	if input.KeyPress('R') {
		MyClient.SendRespawn()
	}

	if input.MouseWheelDelta != 0 && engine.Debug {
		engine.CurrentCamera().SetSize(engine.CurrentCamera().Size() + float32(-input.MouseWheelDelta))
	}

	if queenDead {
		if input.KeyPress(input.KeyF1) {
			PowerUpShip(HP)
		}
		if input.KeyPress(input.KeyF2) {
			PowerUpShip(Damage)
		}
		if input.KeyPress(input.KeyF3) {
			PowerUpShip(Range)
		}
		if input.KeyPress(input.KeyF4) {
			PowerUpShip(Speed)
		}
	}
}
Example #3
0
func (sp *SmoothFollow) LateUpdate() {
	camera := engine.CurrentCamera()
	if camera != nil {
		myPos := sp.Target.Transform().Position()
		camPos := camera.Transform().Position()

		if sp.Speed > 0 {
			camPos = engine.Lerp(camPos, myPos, float32(engine.DeltaTime())*sp.Speed)
			disX := camPos.X - myPos.X
			disY := camPos.Y - myPos.Y
			if float32(math.Abs(float64(disX))) > sp.MaxDis {
				if disX < 0 {
					camPos.X = myPos.X - sp.MaxDis
				} else {
					camPos.X = myPos.X + sp.MaxDis
				}
			}
			if float32(math.Abs(float64(disY))) > sp.MaxDis {
				if disY < 0 {
					camPos.Y = myPos.Y - sp.MaxDis
				} else {
					camPos.Y = myPos.Y + sp.MaxDis
				}
			}
		} else {
			camPos = myPos
		}
		camera.Transform().SetPosition(camPos)
	}
}