Activity: Coordinate Walker
In this activity, students will investigate the game screen.
Concept: Identify the X, Y coordinates of the Game Screen
Move a walker sprite around the game screen, and use it to identify X
and Y
coordinates.
In order to create games, we need to be able to place Sprites and other objects at various locations on the game screen. In this set of activities, we will relate the screen (x
, y
) coordinates to the 4 corners and middle of the game screen.
Student task #1: Coordinate Walker
Use the coordinate walker example to move around the screen and track X
and Y
coordinates.
Use this code in the simulator to complete the tasks.
- To check the location: run the program, and then press the A button on the game pad (or space bar key on keyboard). This will display the starting location’s
X
andY
coordinates.- Note the two coordinate values for
(X, Y)
- Note the two coordinate values for
- Move the sprite: click on the game pad (or use keyboard
WASD
keys) to move the sprite. Check the coordinates after moving.
What did we learn?
Use X
and/or Y
in your answers
- Describe how coordinates change when moving up and down. Which direction caused the coordinates to increase?
- Describe how coordinates change when moving right and left. Which direction caused the coordinates to increase?
Student Task #2: Map Game Screen
Two dimensional game screen coordinates are represented by values for X
and Y
axis locations.
- Move to the sprite to the top edge of the screen
- What is the
Y
coordinate at the top of the screen?
- Move to each of the corners and map the coordinates as a pair of X and Y values like
(X, Y)
- Restart the game. What are the coordinates at the start?
- Record what the coordinates at the Top Right corner are
- Record what the coordinates at the Bottom Right corner are
- Record what the coordinates at the Bottom Left corner are
- Record what the coordinates at the Top Left corner are
- Record what the Game Screen Dimensions (height by width) are
- Record the results from this task in a simple diagram like the one below.
Challenge: Bring an off-screen sprite back into view
Challenge a peer to bring the sprite back into view after you move the sprite off screen.
- Partner 1: move the walker sprite off past the area of the visible game screen (not too far)
- Partner 2: return the sprite to the screen using only two directions of the game controls
- use the game pad A button to get the hidden sprite coordinates
- pick 1: up or down
Y
direction - pick 1: left or right
X
direction - using only the controller pad keys chosen bring the sprite back onto the screen