# Use Global Variable to Interact with Sprites

**Programming result**

When you rotate HaloCode around the y-axis, the sun on stage will rotate as well.

**Introduction to HaloCode's Axes**

The axes of HaloCode are as follows:

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-LpgAGxhEgyiKrMmad7z%2F0.png?generation=1569477960038870\&alt=media)

**Create a new variable**

1\. Click Variables category, and then click "Make a Variable". Name the variable "y".

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-LpgAGxirJ31YTyx-fQ6%2F1.gif?generation=1569477960022403\&alt=media)

2\. Add a Variables block set (y) to () and a Sensing block rotation angle around (). Choose "Y" axis.

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-LpgAGxj2zM9rLn7-kw2%2F2.gif?generation=1569477960053580\&alt=media)

**Add event and control**

3\. Add an Events block when button is pressed and a Control block forever.

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-LpgAGxkOeRiZf3bnAqF%2F3.gif?generation=1569477960028966\&alt=media)

**Add a sprite**

4\. Under "Sprites", click "+". Choose "Sun1".

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-LpgAGxl1RDwHAK5acAo%2F4.gif?generation=1569477960070455\&alt=media)

5\. Delete default sprite "Panda".

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-LpgAGxmm3nK7R3pUCXW%2F5.gif?generation=1569477960079238\&alt=media)

**Program the sun**

6\. Add a Motion block turn ↷ () degrees and a Variables block y.

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-LpgAGxnmhG8DS6R2Ncj%2F6.gif?generation=1569477960089907\&alt=media)

7\. Add an Events block when green flag clicked and a Control block forever.

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-LpgAGxouJZP9ZnBhznW%2F7.gif?generation=1569477960073116\&alt=media)

8\. Rotate HaloCode and see what happens.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.pakronics.com.au/halocode-1/code-with-mu-a-simple-python-editor/examples/level-up/use-global-variable-to-interact-with-sprites.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
