Creating Pac-man scheme/racket coding - Vector conversion

583 Views Asked by At

Well, I'm trying to do a maze-game, Pac-man, I need creation and render of map, for this, I did a "map of vectors" with the different states that I need.

This is the code:

#lang racket
(require 2htdp/image 2htdp/universe
         (only-in racket/draw
                  read-bitmap))

(require math/matrix)
(require math/array)

(define CELL-SIZE 20)
(define E (rectangle CELL-SIZE CELL-SIZE "solid" "black")) 
(define D (circle 3  "solid" "YELLOW"))   
(define W (rectangle CELL-SIZE CELL-SIZE "solid" "blue")) 
(define C (rectangle CELL-SIZE CELL-SIZE "solid" "red"))

(define Initial-Map
  (vector (vector W W W W W W W W W W W W W)
          (vector W C D D D D D D D D D D W)
          (vector W D W D W W W W W D W D W)
          (vector W D W D W D D D W D W D W)
          (vector W D W D D D W D D D W D W)
          (vector W D W W D W W W D W W D W)
          (vector E D D D D D E D D D D D E)
          (vector W D W W D W W W D W W D W)
          (vector W D W D D D W D D D W D W)
          (vector W D W D W D W D W D W D W)
          (vector W D W D D D W D D D W D W)
          (vector W D W D W D D D W D W D W)
          (vector W D D C W D W D W D D D W)
          (vector W W W W W W W W W W W W W)))



(define EMPTY  (rectangle CELL-SIZE CELL-SIZE "solid" "black")) ; Empty
(define DOT  (circle 3  "solid" "white")) ; DOT
(define WALL (rectangle CELL-SIZE CELL-SIZE "solid" "blue"))  ; Wall


(define Scene (empty-scene 400 400 "black"))

(define (paintWorld mundo) (place-image  (vector*->matrix Initial-Map) 100 100 Scene))

(big-bang 4
;(on-key changePacmanM)
;(on-tick automaticMovePacman 0.2)
(to-draw paintWorld)
(state true)
(name "Pacman - Racket"))

This is the problem

Initial-Map is the map vector. How can i render it for the big-bang creation universe function?

I tried to convert vector to matrix with vector*->matrix in order to pass it to place-image:

(place-image (vector*->matrix Initial-Map) 100 100 Scene)

But I get the following error:

place-image: expects an image as first argument, given (mutable-array #[#[(object:image% ...) (object:image% ...) (object:image% ...) (object:image% ...) (object:image% ...)

0

There are 0 best solutions below