Skip to content

Commit

Permalink
Add high level api for controls
Browse files Browse the repository at this point in the history
  • Loading branch information
ChillerDragon committed Jul 4, 2024
1 parent 0cb0c36 commit ba1e1e8
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions teeworlds7/user_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,57 @@ func (client *Client) SendMessage(msg messages7.NetMessage) {
//
// client.Game.Input.Direction = -1
// client.SendInput()
//
// see also:
//
// Right()
// Left()
// Stop()
// Jump()
// Fire()
// Hook()
// Aim(x, y)
func (client *Client) SendInput() {
client.SendMessage(client.Game.Input)
}

func (client *Client) Right() {
client.Game.Input.Direction = 1
client.SendInput()
}

func (client *Client) Left() {
client.Game.Input.Direction = -1
client.SendInput()
}

func (client *Client) Stop() {
client.Game.Input.Direction = 0
client.SendInput()
}

func (client *Client) Jump() {
client.Game.Input.Jump = 1
client.SendInput()
}

func (client *Client) Hook() {
client.Game.Input.Hook = 1
client.SendInput()
}

func (client *Client) Fire() {
// TODO: fire is weird do we ever have to reset or mask it or something?
client.Game.Input.Fire++
client.SendInput()
}

func (client *Client) Aim(x int, y int) {
client.Game.Input.TargetX = x
client.Game.Input.TargetY = y
client.SendInput()
}

// see also SendWhisper()
// see also SendChatTeam()
func (client *Client) SendChat(msg string) {
Expand Down

0 comments on commit ba1e1e8

Please sign in to comment.