Level(ii,jj) = image(ii, jj) % Here maybe convert blue to 1, etc yourself. I have not tested this at all, but here is my try: level = zeros(300) Looping though the image data and copying it into a matrix (maybe converting colors into your 0/1/2/3 values in the meanwhile) is the next step. RgbColor = impixel(image, column, row) ' Get the pixel like that if it is colorful image. GrayLevel = image(row, column) ' Get the pixel like that if it is grayscale image. Something like this: image = imread('map.png') If I understood the problem correctly, you can load the matrix data from an image (which can easily be drawn in a photo-editing application) into an new matrix, getting the best of both worlds. %create location of filled in walls(represented by 1's)Ĭase 0 %represents an empty black space for PACMAN & Ghosts to move throughĬase 2 %represents the location of the fruit % the functionality of this function is to generate the walls that Any suggestions about how to continue? Any response would be greatly appreciate and below is the sample code that I have attempted to create so far: function level = LevelOne() However, in trying to do latter method, I am having an issue assigning a color to each specific index of the 300 x 300 matrix in a switch-case-otherwise method. Another method I believe would work would be to just create the map myself with 0's,1's, and 2's which represent the location of black empty pixels, blue walls(filled), and dots(yellow), respectively. png file that has the background in class uint8 RGB, but this case does not allow me to register the walls that impede the path of PACMAN and the ghosts. So I am currently in the process of making PACMAN on MATLAB, but cannot seem to figure out how to start the generation of the map on the main figure.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |