How to draw board

Discussion of Common Lisp

How to draw board

Postby adel » Sat Sep 28, 2013 6:59 am

How I can draw grid ( square board 5x5) using Lisp?
Here is an example (I am sorry my drawing is very bad!!) .. (each cell has to be locked cells but I could not draw this here and I could not upload image that can explain everything)
The board should be consists of + (in corners) and - (in the edges) ( Plus and Minus)

+ - - - - -+- - - -- - -+- - - -- - - -+- - - - - - +- - - - - -+

+ - - - - -+- - -- - - -+- - - - - - -+- - - - - - +- - - - - -+

+ - - - - -+- - -- - - -+- - - - - - -+- - - - - - +- - - - - -+

+ - - - - -+- - -- - - -+- - - - - - -+- - - - - - +- - - - -- +

+ - - - - -+- - -- - - -+- - -- - - - -+- - - - - - +- - - -- - -+

+ - - - - -+- - -- - - -+- - - - - - -+- - - - - - +- - - - - -+
adel
 
Posts: 1
Joined: Fri Sep 13, 2013 4:19 am

Re: How to draw board

Postby pjstirling » Sun Sep 29, 2013 11:40 am

Use nested DOTIMES loops
pjstirling
 
Posts: 80
Joined: Sun Nov 28, 2010 4:21 pm

Re: How to draw board

Postby Pixel_Outlaw » Mon Sep 30, 2013 5:23 pm

Give this a try:

Code: Select all
(defun draw-board (num-across num-down square-width)
  (dotimes (y num-down)
    (dotimes (x num-across)
      (princ "+")
      (dotimes (z square-width)
   (princ "-")))
    (princ "+")
    (format t "~%")))


You could also modify this to draw vertical bars | on the sides but that isn't what your picture showed.
Pixel_Outlaw
 
Posts: 41
Joined: Mon Aug 26, 2013 9:24 pm


Return to Common Lisp

Who is online

Users browsing this forum: Google [Bot] and 3 guests