{"size": 1570, "ext": "scrbl", "max_stars_repo_path": "scribblings/draw-section.scrbl", "max_stars_repo_name": "aowens-21/puzzler", "max_stars_repo_stars_event_min_datetime": "2020-04-23T09:12:25.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-05T22:28:06.000Z", "max_issues_repo_path": "scribblings/draw-section.scrbl", "max_issues_repo_name": "aowens-21/puzzler", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "scribblings/draw-section.scrbl", "max_forks_repo_name": "aowens-21/puzzler", "max_forks_repo_forks_event_min_datetime": "2020-04-27T14:03:51.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-05T21:37:58.000Z"}
{"max_stars_count": 7, "max_issues_count": null, "max_forks_count": 2, "avg_line_length": 35.6818181818, "max_line_length": 186, "alphanum_fraction": 0.7407643312}
#lang scribble/manual

@title{Drawing and Images}

Every game you build with Puzzler will have some images which represent entities in the game. In our @seclink["sokoban"]{Sokoban game}, for example, we had an image for
the player as well as an image for the boxes the player pushes around. Managing which images map to which game entities is the responsibility of our game's
@italic{draw section}.

@section{Draw Rules}

The Puzzler draw section looks like this:

@verbatim{
 draw:
 <draw_rule>
 ...
}

Where @italic{<draw_rule>} is of the form @italic{"<entity_character>" -> "<image_path>"}. Remember that in Puzzler every game entity is represented on the map as a single character like
"P" or "X". So, for example, if we wanted to draw some image @italic{"player.png"} for our game entity "P", we would do the following:

@verbatim{
 draw:
 "P" -> "player.png"
}

This can be read as something like "P draws player.png". It is important to remember that @bold{image paths are defined in relation to where the Puzzler game is executing}.

@section{Built-Ins}

There is one special case of draw rules in Puzzler: the reserved word @italic{"rect"}. Any entity which maps to "rect" in a draw rule will be drawn as a black box
the same size as a single grid square. In the Sokoban example we had:

@verbatim{
 draw:
 "P" -> "player.png"
 "B" -> "rect"
}

The first draw rule works normally and reads the image "player.png" from the current directory, but the second draw rule uses the built in shape "rect" to draw black boxes for all of the
well, boxes, in the game.


