gophermoves

package module
v0.0.0-...-7901eae Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 4 Imported by: 0

README

Gopher Moves

GopherMoves is a Go package that provides an interface and an example implementation for simulating the movements of a character, particularly designed for a Gopher character.

https://github.com/renanbastos93/gophermoves/assets/8202898/4ecaa097-08e4-4a67-a80f-a311b6e1af67

Table of Contents

Installation

To use GopherMoves in your Go project, you can simply run:

go get -u github.com/renanbastos93/gophermoves

Usage

package main

import "github.com/renanbastos93/gophermoves"

func main() {
	orderMatrix := 5
	g := gophermoves.New(orderMatrix)
	err := g.Start()
	if err != nil {
		panic(err.Error())
	}
}

Interface Methods

The GopherMoves interface provides the following methods:

  • Start() (err error): Initiates movements for the character.
  • Reset(): Redefines the default states of the X and Y positions.
  • Up(): Moves the character upward.
  • Down(): Moves the character downward.
  • Left(): Turns the character to the left.
  • Right(): Turns the character to the right.

Contributing

Feel free to contribute to this project. If you find any issues or have suggestions, please open an issue or submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UpLowerCase    = []byte(`w`)
	DownLowerCase  = []byte(`s`)
	LeftLowerCase  = []byte(`a`)
	RightLowerCase = []byte(`d`)
	ResetLowerCase = []byte(`r`)

	UpUpperCase    = []byte(`W`)
	DownUpperCase  = []byte(`S`)
	LeftUpperCase  = []byte(`A`)
	RightUpperCase = []byte(`D`)
	ResetUpperCase = []byte(`R`)

	QuitLowerCase = []byte(`q`)
	QuitUpperCase = []byte(`Q`)

	QuitUsingCtrlC = []byte{3}
)

Functions

This section is empty.

Types

type Moves

type Moves interface {

	// Start will initiate the play to simulate movements for the character
	Start() (err error)

	// Reset will redefine the default states of the X and Y positions
	Reset()

	// Up moves the character upward
	Up()

	// Down moves the character down
	Down()

	// Left will turn the character to the left
	Left()

	// Right will turn the character to the right
	Right()
}

Moves is an interface that defines methods to simulate movements for the character like Gopher

func New

func New(m int) Moves

New will create and return a new instance that satisfies the Moves interface for Gopher

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL