Aliens Activity 1: Setting up the graphics canvas

gmalone's picture

File: aliens_activity01_setup-graphics.slogo

This file contains the most basic setup aspects needed when getting started writing a game in StarLogo.

1) For this particular game, the graphics canvas (the large black play area) has been set to a patch size of 32 (using the slider at the top of the play window), which means that each location on the play area grid is a 32 x 32 pixels square area. That will allow our aliens and projectiles and other objects to have a lot of graphic detail, and they will be somewhat large.

2) The size of the graphics canvas has been set to 19 x 19 patches (or squares).

Become well-oriented with the layout of the graphics canvas.

The x,y coordinates of key points on the graphics canvas are:

Center of canvas (0,0)
Upper left corner (-9,9)
Top center (0,9)
Upper right corner (9,9)
Bottom left corner (-9,-9)
Bottom center (0,-9)
Bottom right corner (9,-9)

3) A simple procedure called "startup" has been written in the Observer Procedures area, which is under the Observer tab in the Control Center. The startup procedure contains:

to startup
clear-graphics ; clear the graphics canvas to black
end

Anytime you create a "to startup" procedure in the Observer area, that procedure will automatically be executed when you first load the program. You can also create a button in the graphics area which will essentially restart the program by calling the "startup" procedure.

The "clear-graphics" command is a built-in StarLogo command.

AttachmentSize
01-aliens_setup-graphics.slogo15.94 KB