> For the complete documentation index, see [llms.txt](https://kree.gitbook.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kree.gitbook.io/documentation/code-snippets/creating-custom-components.md).

# Creating Custom Components

{% tabs %}
{% tab title="Custom Component" %}
{% code title="PlayerMovement.java" %}

```java
public class PlayerMovement extends Component {

    public float movementSpeed = 0.5f;

    public PlayerMovement(float movementSpeed) {
        this.name = "Player Movement";
        this.movementSpeed = movementSpeed;
    }

    @Override
    public void Update() {

        if(gameObject == null)
            return;

        // Left key
        if(Input.isKeyPressed(37)) {
            gameObject.transform.translate(Vector2.left);
        }
        // Right key
        if(Input.isKeyPressed(39)) {
            gameObject.transform.translate(Vector2.right);
        }
        // Up key
        if(Input.isKeyPressed(38)) {
            gameObject.transform.translate(Vector2.up);
        }
        // Down key
        if(Input.isKeyPressed(40)) {
            gameObject.transform.translate(Vector2.down);
        }

    }

    @Override
    public void Render(Graphics g) {

    }


}
```

{% endcode %}
{% endtab %}

{% tab title="Scene (Implementation)" %}
{% code title="SceneNameHere.java" %}

```java
public class SceneNameHere extends Scene {

    private GameObject player = new GameObject(this, "Player");

    public SceneNameHere(Game game) {
        super(game);

    }

    @Override
    public void Initialize() {

        player.setScale(new Vector2(32, 32));
        player.addComponent(new PlayerMovement(0.5f));
        player.addComponent(new MeshRenderer());

    }

    @Override
    public void Update() {

    }

    @Override
    public void Render(Graphics g) {


    }


}
```

{% endcode %}
{% endtab %}
{% endtabs %}
