Esempio n. 1
0
func (game *Game) updateBoards() {
	var board1velocity, board2velocity gt2d.Vector2D

	if game.keysDown[wde.KeyW] {
		board1velocity.Y = -game.Board1.MaxVelocity
	} else if game.keysDown[wde.KeyS] {
		board1velocity.Y = game.Board1.MaxVelocity
	}

	if game.keysDown[wde.KeyD] {
		board1velocity.X = game.Board1.MaxVelocity
	} else if game.keysDown[wde.KeyA] {
		board1velocity.X = -game.Board1.MaxVelocity
	}

	if game.keysDown[wde.KeyUpArrow] {
		board2velocity.Y = -game.Board2.MaxVelocity
	} else if game.keysDown[wde.KeyDownArrow] {
		board2velocity.Y = game.Board2.MaxVelocity
	}

	if game.keysDown[wde.KeyLeftArrow] {
		board2velocity.X = -game.Board2.MaxVelocity
	} else if game.keysDown[wde.KeyRightArrow] {
		board2velocity.X = game.Board2.MaxVelocity
	}

	game.Board1.Move(board1velocity)
	game.Board2.Move(board2velocity)
}
Esempio n. 2
0
// For our shitty simulator, v1 won't change. v2 gets reflected and some extra
// speed added. The MAX V is 15 15.
func collideAndChangeVelocity(v1 *gt2d.Vector2D, v2 *gt2d.Vector2D) {
	x := abs(v2.X) + abs(v1.X)/4
	y := v2.Y + v1.Y/2

	if x > MAX_BULLET_V {
		x = MAX_BULLET_V
	}

	// so bad. We need a limit functionality.
	if y > MAX_BULLET_V {
		y = 15
	} else if y < -MAX_BULLET_V {
		y = -MAX_BULLET_V
	}

	if v2.X < 0 {
		v2.X = x
	} else {
		v2.X = -x
	}

	v2.Y = y
}