Game Development Reference
In-Depth Information
Figure 11-7. The screen coordinates in LÖVE
Drawing Primitives
Now that we've played around a bit with some images, we'll look at vector art—rectangles, circles,
and so on. In many games, these primitives can help create the backdrops without the added
overhead of additional graphics images.
Lines
The simplest of all vector-drawing objects are lines. A line is a series of points that are joined
between two points. The syntax for drawing a line is
love.graphics.line(x1, y1, x2, y2,...)
You can specify a series of points and they will all be drawn. A line object can also be modified via
the LineWidth and LineStyle attributes, either individually, as love.graphics.setLineWidth and
love.graphics.setLineStyle , or at once, as love.graphics.setLine(width, type) . In the code
below, we set the line width to 2 and use the smooth type; we then draw a line from 15, 15 to 70, 90.
love.graphics.setLine(2,"smooth")
love.graphics.line(15, 15, 70,90)
Rectangles
This is the syntax for drawing a rectangle:
love.graphics.rectangle( mode, x, y, width, height )
mode can be either fill , which will fill the rectangle, or line , which will display the rectangle with an
outline and no fill.
 
Search WWH ::




Custom Search