Title: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on February 22, 2011, 10:51:20 pm Ok, well I got this one working ok,...it is not much,
the Pac Man just moves up and down, side to side, with arrow keys. I would like to figure out how to make hime face down, or up, when he is moved up or down, I may need to add these to the sprite sheet,.Or Can he be rotated useing _putimage ? sprite at http://dl.dropbox.com/u/15387474/SprtSheet2F.PNG Code: REM Get sprite at http://dl.dropbox.com/u/15387474/SprtSheet2F.PNG DEFLNG A-Z SCREEN 12 WorkPage& = _LOADIMAGE("Sprtsheet2f.png") 'create the sprite sheet page _COPYPALETTE WorkPage&, 0 FrameNum& = 0: x1 = 100: y1 = 100: direction = 1: flap = 0: Active = 0: PRINT " use arrow keys, to move side,to side, up down. Esacpekey exits" SLEEP 2 DO _DISPLAY _LIMIT 20 GOSUB Getkey CLS 'need to clear the page ready for new image GOSUB Showframe COLOR 14 LOCATE 20, 1: PRINT " Hello World, now just give me some dots to eat" '// I would like to see how to make him eat the above text. PLAY "MB <a15c20e15>" '//you can remark this out if it annoys you LOOP UNTIL INP(&H60) = 1 SLEEP SYSTEM Getkey: IF _KEYDOWN(20480) THEN y1 = y1 + 4 IF _KEYDOWN(18432) THEN y1 = y1 - 4 IF _KEYDOWN(19200) THEN x1 = x1 - 4: direction = 2 END IF IF _KEYDOWN(19712) THEN x1 = x1 + 4: direction = 1 END IF _DELAY .05 RETURN Showframe: SELECT CASE FrameNum& CASE 0 IF direction = 1 THEN _PUTIMAGE (x1, y1)-(x1 + 94, y1 + 94), WorkPage&, 0, (1, 1)-(94, 94) ELSE _PUTIMAGE (x1, y1)-(x1 + 94, y1 + 94), WorkPage&, 0, (94, 1)-(1, 94) END IF CASE 1 IF direction = 1 THEN _PUTIMAGE (x1, y1)-(x1 + 94, y1 + 94), WorkPage&, 0, (91, 0)-(188, 94) ELSE _PUTIMAGE (x1, y1)-(x1 + 94, y1 + 94), WorkPage&, 0, (188, 0)-(94, 94) END IF END SELECT blink = blink + 1 IF blink = 3 THEN blink = 0 FrameNum& = FrameNum& + 1 END IF IF FrameNum& = 2 THEN FrameNum& = 0 RETURN Title: Re: PacMan2f This one moves with arrow keys Post by: guest on February 23, 2011, 09:25:16 am Code: REM Get sprite at http://dl.dropbox.com/u/15387474/SprtSheet2F.PNG DEFLNG A-Z Video& = _NEWIMAGE(640, 480, 32) WorkPage& = _LOADIMAGE("Sprtsheet.png", 32) 'create the sprite sheet page SCREEN Video& FrameNum& = 0: x1 = 100: y1 = 100: direction = 1: flap = 0: Active = 0: PRINT " use arrow keys, to move side,to side, up down. Esacpekey exits" SLEEP 2 DO _DISPLAY _LIMIT 20 GOSUB Getkey CLS 'need to clear the page ready for new image GOSUB Showframe COLOR 14 LOCATE 20, 1: PRINT " Hello World, now just give me some dots to eat" '// I would like to see how to make him eat the above text. 'PLAY "MB <a15c20e15>" '//you can remark this out if it annoys you LOOP UNTIL INP(&H60) = 1 SLEEP SYSTEM Getkey: IF _KEYDOWN(20480) THEN y1 = y1 + 4 IF _KEYDOWN(18432) THEN y1 = y1 - 4 IF _KEYDOWN(19200) THEN x1 = x1 - 4: direction = 2 END IF IF _KEYDOWN(19712) THEN x1 = x1 + 4: direction = 1 END IF _DELAY .05 RETURN Showframe: SELECT CASE FrameNum& CASE 0 IF direction = 1 THEN _PUTIMAGE (x1, y1)-(x1 + 94, y1 + 94), WorkPage&, 0, (1, 1)-(94, 94) ELSE _PUTIMAGE (x1, y1)-(x1 + 94, y1 + 94), WorkPage&, 0, (94, 1)-(1, 94) END IF CASE 1 IF direction = 1 THEN _PUTIMAGE (x1, y1)-(x1 + 94, y1 + 94), WorkPage&, 0, (91, 0)-(188, 94) ELSE _PUTIMAGE (x1, y1)-(x1 + 94, y1 + 94), WorkPage&, 0, (188, 0)-(94, 94) END IF END SELECT blink = blink + 1 IF blink = 3 THEN blink = 0 FrameNum& = FrameNum& + 1 END IF IF FrameNum& = 2 THEN FrameNum& = 0 RETURN Note the removal of screen 12 and creation of a 32bit window the size of screen 12. Keep in mind if we make new graphics to show pac man upward and downward make them to the existing size of the current pics and they will slot into the code very easy. The current pics are wider than they are high Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on February 23, 2011, 09:08:56 pm Hi all, Ok, I cut the code, since it is in the previous post, ok this is a little odd, as it did work on my computer,.(mine), I tested it agian, and what I posted dose work,...Also your version, works,...So I wonder why, it would work on my computer but not yours ?,..if you have any ideas, let me know...However, since both work on my computer, and yours is ready for a new spritesheet, Which also based on your statement, apparently there is a mistake in my images, because they are supposed to be 94 x 94, I bet I made a mistake, when I edited my sprite sheet, because I took the 2 out of a 4 frame sheet, I must have cut them a little short,..I couldn't get that one to work Garry. Here's my modded one that does work. Note the removal of screen 12 and creation of a 32bit window the size of screen 12. Keep in mind if we make new graphics to show pac man upward and downward make them to the existing size of the current pics and they will slot into the code very easy. The current pics are wider than they are high. OlDosLover. Anyway thanks for the new code, and I agree, the best thing to do is make a new sprite sheet, but useing the existing sizes,...I also have the one, you e-mailed me,.. for now thats about it from Garry Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on February 25, 2011, 01:58:11 pm I tried a little bit, to fit the 6 image sprite, into the code,you posted, but am not able to get the 2 frames faceing up and down, to show, Don't know if you can understand, and thinking about it now, it seems I will actually need 8 fromes, and 2 more CASES, similar, to the original, from the way I understand this, one CASE, is for it moveing right, the other moveing left, the same, it seems would hold true for the up and the down, like wise, 4 more _putimage lines,..Also the _keydown, will need to be changed, on the 2 lines that are related to the up and the down. I am wondering, if I make sense to you, Am I on the right track ? Later, I still am going to make another sprite sheet,.... If I am on the right track, I may get it worked out. I did not have time to try what I was thinking yet.Guess thats about it for now. from Garry Title: Re: PacMan2f This one moves with arrow keys Post by: guest on February 26, 2011, 09:48:09 am Quote create a screen for all output graphics load the pacman graphics point the video screen to the monitor top of loop gosub getkey gosub showframe bottom of loop system or program end getkey if down key pressed then y = y + 4 direction = 4 if up key pressed then y =y - 4 direction = 3 if left key pressed then x = x - 4 direction = 2 if right key pressed then x = x + 4 direction = 1 showframe select case direction case =1 put right facing pac man to video screen case =2 put left facing pac man to video screen case =3 put up facing pac man to video screen case =4 put down facing pac man to video screen The only thing not accounted for in this "skeleton code" is the frame of animation with pac mans mouth open or closed. Thats easy to accommodate as he always goes from closed to open ( that variable is 1 o r 2 only) so inside of the select case and inside the case = we need an IF ... THEN test to point to correct graphic frame of animation. eg Quote case =4 if pac open then put down open facing pac man to video screen else put down closed facing pac man to video screen Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on February 27, 2011, 12:14:43 pm Thanks Oldoslover,
Quote Posted by: OlDosLover I may be able to figure this out, now. I don't have my "tablet",here, and do not like useing the mouse to draw, much, they come out alot nicer useing the tablet and "pen". So more in the week, I can try this code. Sometimes that helps me Insert Quote Hi all, Send me the new sprite sheet and ill set it up for you. We will need to add two new values to direction variable. Namely 3=up , 4 = down and the code will have to be adjusted to accomodate this. For example the select case will need addition to draw the correct up and down graphic. OlDosLover. alot, if I see more or less how the code is written, when I make the sprites,... Any way just to let you know I have seen this, but it may be a few days, before I respond with the sprite sheet, and any question, if I can't get to work. Apart from being a little wider, on the sprite sheet I have, I noticed I had forgotten, to put in the image with the mouth closed, in the faceing down images, they are all with the mouth open!..so guess thats about it. from Garry Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on February 28, 2011, 07:50:37 am http://dl.dropbox.com/u/15387474/OldDosLoverSprtSheet1.PNG
Above is the new sprite, I almost had it, but when I got up to Case 3 and 4 I started getting errors, at one point I had some interesting effects,... But still did not get it right. I decided not to post the code I made, so as not to creat confusion, as it still dose not work. The sprite sheet is a little rough still, but should work for a code sample, 94 x 94 each frame. If you have time, it would be nice to see a good sample, if not I will keep trying, as I did get close,... thanks from Garry Title: Re: PacMan2f This one moves with arrow keys Post by: guest on February 28, 2011, 06:43:20 pm Here's a PacMan MAP maker that creates a graphical map 800 x 600. The size of the corridor is 30 pixels. Pacman is 28 pixels leaving 1 pixel either side of pacman for collision detection with point. Currently saves the map to PacMap0.bmp. The grid is NOT copied to the saved file!. Map is 25 cells wide by 19 cells deep. To draw more maps rename the original before creating another new map. Code: REM Best version yet. DEFLNG A-Z DIM SHARED mx, my, mbl, mbr Video& = _NEWIMAGE(800, 600, 32) 'page we actually draw on Grid& = _NEWIMAGE(800, 600, 32) 'grid to place over monitor SCREEN _NEWIMAGE(800, 600, 32) 'what we see Yellow& = _RGB32(255, 255, 0) MSBlue& = _RGB32(123, 104, 238) Black& = _RGB32(0, 0, 0) GOSUB Makemap DO _CLEARCOLOR Black&, Grid& _PUTIMAGE , Grid&, 0 'copy yellow lines of grid only _PUTIMAGE , Video&, 0 MousePoll r = INT(mx \ 30) 'row r1 = r * 30 'x1 r2 = r1 + 30 'x2 c = INT(my \ 30) 'column c1 = c * 30 'y1 c2 = c1 + 30 'y2 IF mbl = -1 THEN GOSUB LFillbox IF mbr = -1 THEN GOSUB RFillbox _DEST 0 LOCATE 1, 95: PRINT mx LOCATE 2, 95: PRINT my LOCATE 4, 95: PRINT r + 1 LOCATE 5, 95: PRINT c + 1 LOOP UNTIL _KEYDOWN(27) SaveImage Video&, "PacMap0.bmp" _DEST 0 LOCATE 10, 37: PRINT "FILE SAVED AS PacMap0.bmp" SOUND 1500, 1: SOUND 2000, 1 SLEEP SCREEN 0 _FREEIMAGE Video& _FREEIMAGE Grid& SYSTEM '------------------------------ SUBS ------------------- RFillbox: IF mx < 748 THEN IF my < 566 THEN _DEST Video& LINE (r1, c1)-(r2, c2), Black&, BF 'erase box END IF END IF RETURN LFillbox: IF mx < 748 THEN IF my < 566 THEN _DEST Video& LINE (r1, c1)-(r2, c2), MSBlue&, BF 'fill box END IF END IF RETURN Makemap: _DEST Grid& FOR x = 0 TO 740 STEP 30 FOR y = 0 TO 560 STEP 30 LINE (x, y)-(x + 30, y + 30), Yellow&, B NEXT y NEXT x RETURN SUB SaveImage (image AS LONG, filename AS STRING) bytesperpixel& = _PIXELSIZE(image&) IF bytesperpixel& = 0 THEN PRINT "Text modes unsupported!": END IF bytesperpixel& = 1 THEN bpp& = 8 ELSE bpp& = 24 x& = _WIDTH(image&) y& = _HEIGHT(image&) b$ = "BM????QB64????" + MKL$(40) + MKL$(x&) + MKL$(y&) + MKI$(1) + MKI$(bpp&) + MKL$(0) + "????" + MKL$(0) + MKL$(0) + MKL$(0) + MKL$(0) 'partial BMP header info(???? to be filled later) IF bytesperpixel& = 1 THEN FOR c& = 0 TO 255 ' read BGR color settings from JPG image + 1 byte spacer(CHR$(0)) cv& = _PALETTECOLOR(c&, image&) ' color attribute to read. b$ = b$ + CHR$(_BLUE32(cv&)) + CHR$(_GREEN32(cv&)) + CHR$(_RED32(cv&)) + CHR$(0) 'spacer byte NEXT END IF MID$(b$, 11, 4) = MKL$(LEN(b$)) ' image pixel data offset(BMP header) lastsource& = _SOURCE _SOURCE image& IF (x& AND 3) THEN padder$ = SPACE$(4 - (x& AND 3)) FOR py& = y& - 1 TO 0 STEP -1 ' read JPG image pixel color data r$ = "" FOR px& = 0 TO x& - 1 c& = POINT(px&, py&) IF bytesperpixel& = 1 THEN r$ = r$ + CHR$(c&) ELSE r$ = r$ + LEFT$(MKL$(c&), 3) NEXT px& d$ = d$ + r$ + padder$ NEXT py& _SOURCE lastsource& MID$(b$, 35, 4) = MKL$(LEN(d$)) ' image size(BMP header) b$ = b$ + d$ ' total file data bytes to create file MID$(b$, 3, 4) = MKL$(LEN(b$)) ' size of data file(BMP header) IF LCASE$(RIGHT$(filename$, 4)) <> ".bmp" THEN ext$ = ".bmp" f& = FREEFILE OPEN filename$ + ext$ FOR OUTPUT AS #f&: CLOSE #f& ' erases an existing file OPEN filename$ + ext$ FOR BINARY AS #f& PUT #f&, , b$ CLOSE #f& END SUB SUB MousePoll () DO WHILE _MOUSEINPUT mx = _MOUSEX: my = _MOUSEY: mbl = _MOUSEBUTTON(1): mbr = _MOUSEBUTTON(2) LOOP END SUB SUB ButtonRelease () IF mbl = 0 AND mbr = 0 THEN EXIT SUB WHILE mbl = -1 MousePoll WEND WHILE mbr = -1 MousePoll WEND END SUB Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on February 28, 2011, 07:20:51 pm I was just fooling around with the code, and Pacy001.bmp, that you posted,
when you posted the map maker, which I have not tried yet. This is great!, all though it looks easy enough to follow, it is quite a bit different, then what I imagined,....Sorry about the image I posted not working,...Guess I need to work on that, too. I think, maybe I need a new mouse, when I am trying to paste something, it is really hard to get it on the exact pixel number I want,. or practice,..! I need to lie down a while, as I just got home, hopefully later tonight I can look at the map too,... thanks a bunch, from Garry Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on February 28, 2011, 10:59:58 pm OK, thats, fine with me,...I was just now, "fooling around" with, the
sample you wrote,....I had some code CG gave me, that helped me ,eat some text I put in,...also I had been trying to do some thing with PLAY, but not very good results, the eating some text, yes I got good results, but useing play no,. ...I like the idea of useing midi, I'll see what I can do there,...I was just thinking, if you want to see what I did,..? But I would post it separate, so we can continue with this thread, as the Game thread,...I don't want to post my "expeiments", as it could really confuse things,... Do you have the DOS version of PAC MAN ? I have one if you want to see it, but I would like to try to something different, so as not to be "copying" his (the author), He did do a excelent job,I don't hae his name handy. But yea, I like the idea, of continueing with this... from Garry P.S. I posted links to the Dos version, MsPack, and PacMan here: http://weeklyqbasicandqb64lesson.smfforfree.com/index.php/topic,51.0.html Title: Re: PacMan2f This one moves with arrow keys Post by: guest on March 01, 2011, 12:48:23 pm Heres an update to the editor. I decided to make a ascii data saving routine to a file. This is so the level can be imbedded into the program , saving loading and finding the individual level files. Also there are 2 ways to do this game 1] Pixel collision 2] Array as map collision The first evolution will be Array as map. The idea is the map is read into an array. To plot movement if you moving right, you simply check the next cell for wall,enemy,or prize etc. Makes it easier to determine all valid directions as you plot all 4 possible directions the hero is able to travel. They are blocked or open. Blocked is a wall open is free or emeny or prize etc. Hope you understand. Will finish the convert to string and actual write to file tomorrow. Code: REM Best version yet. DEFLNG A-Z DIM SHARED mx, my, mbl, mbr DIM SHARED PacMap(19, 25) Video& = _NEWIMAGE(800, 600, 32) 'page we actually draw on Grid& = _NEWIMAGE(800, 600, 32) 'grid to place over monitor Text& = _NEWIMAGE(800, 600, 32) SCREEN _NEWIMAGE(800, 600, 32) 'what we see Yellow& = _RGB32(255, 255, 0) MSBlue& = _RGB32(123, 104, 238) Black& = _RGB32(0, 0, 0) Blok$ = CHR$(176): Blank$ = CHR$(32) GOSUB Makemap DO _CLEARCOLOR Black&, Grid& _PUTIMAGE , Grid&, 0 'copy yellow lines of grid only _PUTIMAGE , Video&, 0 MousePoll r = INT(mx \ 30) 'row r1 = r * 30 'x1 r2 = r1 + 30 'x2 c = INT(my \ 30) 'column c1 = c * 30 'y1 c2 = c1 + 30 'y2 IF mbl = -1 THEN GOSUB LFillbox IF mbr = -1 THEN GOSUB RFillbox IF _KEYDOWN(32) THEN _PUTIMAGE , Text&, 0 END IF _DEST 0 LOCATE 1, 95: PRINT mx LOCATE 2, 95: PRINT my LOCATE 4, 95: PRINT r + 1 LOCATE 5, 95: PRINT c + 1 LOOP UNTIL _KEYDOWN(27) SaveImage Video&, "PacMap0.bmp" _DEST 0 LOCATE 10, 37: PRINT "FILE SAVED AS PacMap0.bmp" SOUND 1500, 1: SOUND 2000, 1 SLEEP 1 SCREEN 0 cycle = 0 FOR c = 0 TO 18 FOR r = 0 TO 24 LOCATE c + 1, r + 1 'z = PacMap(c, r) z = PacMap(c, r) IF z = 0 THEN PRINT CHR$(32) ELSE PRINT CHR$(z) _DELAY .1 cycle = cycle + 1 LOCATE 1, 40: PRINT cycle NEXT r NEXT c SLEEP _FREEIMAGE Video& _FREEIMAGE Grid& _FREEIMAGE Text& SYSTEM '------------------------------ SUBS ------------------- RFillbox: IF mx < 748 THEN IF my < 566 THEN _DEST Video& LINE (r1, c1)-(r2, c2), Black&, BF 'erase box _DEST Text& LOCATE c + 1, r + 1: PRINT Blank$ PacMap(c, r) = 32 END IF END IF RETURN LFillbox: IF mx < 748 THEN IF my < 566 THEN _DEST Video& LINE (r1, c1)-(r2, c2), MSBlue&, BF 'fill box _DEST Text& LOCATE c + 1, r + 1: PRINT Blok$ PacMap(c, r) = 176 END IF END IF RETURN Makemap: _DEST Grid& FOR x = 0 TO 740 STEP 30 FOR y = 0 TO 560 STEP 30 LINE (x, y)-(x + 30, y + 30), Yellow&, B NEXT y NEXT x RETURN SUB SaveImage (image AS LONG, filename AS STRING) bytesperpixel& = _PIXELSIZE(image&) IF bytesperpixel& = 0 THEN PRINT "Text modes unsupported!": END IF bytesperpixel& = 1 THEN bpp& = 8 ELSE bpp& = 24 x& = _WIDTH(image&) y& = _HEIGHT(image&) b$ = "BM????QB64????" + MKL$(40) + MKL$(x&) + MKL$(y&) + MKI$(1) + MKI$(bpp&) + MKL$(0) + "????" + MKL$(0) + MKL$(0) + MKL$(0) + MKL$(0) 'partial BMP header info(???? to be filled later) IF bytesperpixel& = 1 THEN FOR c& = 0 TO 255 ' read BGR color settings from JPG image + 1 byte spacer(CHR$(0)) cv& = _PALETTECOLOR(c&, image&) ' color attribute to read. b$ = b$ + CHR$(_BLUE32(cv&)) + CHR$(_GREEN32(cv&)) + CHR$(_RED32(cv&)) + CHR$(0) 'spacer byte NEXT END IF MID$(b$, 11, 4) = MKL$(LEN(b$)) ' image pixel data offset(BMP header) lastsource& = _SOURCE _SOURCE image& IF (x& AND 3) THEN padder$ = SPACE$(4 - (x& AND 3)) FOR py& = y& - 1 TO 0 STEP -1 ' read JPG image pixel color data r$ = "" FOR px& = 0 TO x& - 1 c& = POINT(px&, py&) IF bytesperpixel& = 1 THEN r$ = r$ + CHR$(c&) ELSE r$ = r$ + LEFT$(MKL$(c&), 3) NEXT px& d$ = d$ + r$ + padder$ NEXT py& _SOURCE lastsource& MID$(b$, 35, 4) = MKL$(LEN(d$)) ' image size(BMP header) b$ = b$ + d$ ' total file data bytes to create file MID$(b$, 3, 4) = MKL$(LEN(b$)) ' size of data file(BMP header) IF LCASE$(RIGHT$(filename$, 4)) <> ".bmp" THEN ext$ = ".bmp" f& = FREEFILE OPEN filename$ + ext$ FOR OUTPUT AS #f&: CLOSE #f& ' erases an existing file OPEN filename$ + ext$ FOR BINARY AS #f& PUT #f&, , b$ CLOSE #f& END SUB SUB MousePoll () DO WHILE _MOUSEINPUT mx = _MOUSEX: my = _MOUSEY: mbl = _MOUSEBUTTON(1): mbr = _MOUSEBUTTON(2) LOOP END SUB SUB ButtonRelease () IF mbl = 0 AND mbr = 0 THEN EXIT SUB WHILE mbl = -1 MousePoll WEND WHILE mbr = -1 MousePoll WEND END SUB Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on March 01, 2011, 09:02:28 pm .
Quote you simply check the next cell for wall,enemy,or prize etc. Makes it easier to determine all valid Not sure I understand all of this,..I just got home, kind of late. What I don't understand, the "checking", (do you mean "clicking" with the mouse, it then fills the box ,at this point with the wall),? But if you want concentrate onQuote Will finish the convert to string and actual write to file tomorrow. Then it may be self explaining, or you can give more detailed explanation...But what you have so far looks good, and as a .bmp it can also be edited useing paint. We will need enemys(ghosts), and like you say prizes, also, I need to look for some midi, stuff, or can also wav be used ?So this is more of a comment right now, you don't need to take the time to do a long detailed explanation, at this point,..I am going to start a new instance of qb64, Down load a new one, so I have a qb64 folder dedicated to this,...My current folder has so much in it , it is takeing me forever to find things, and I all ready have a bunch of Pacmans(previous). Guess thats about it for now. from Garry Title: Re: PacMan2f This one moves with arrow keys Post by: guest on March 02, 2011, 07:09:25 am Ok Garry heres an in depth explanation of how this works. Quote Pac Man Map Next step is to get the map saved as data statements that can be imbedded in the code as a levelHow does the map , Array and the image onscreen all relate to each other? This is the cruz of the problem of getting everything to work in co-ordination. Imagine a page of text. We divide this page (as programmers) into rows and columns. Each individual letter exists in a "cell" on a particular line on the page. We can know its address by its row and column. If we set the graphical map up as the page of text then they replicate each other. Instead of row and column we use pixel in x axis and pixel in y axis. And to represent a "cell" thats just a collection of pixels wide(x axis) by pixels deep (y axis). Now if we set the Array up as like the text page thats rows and columns then thats a two dimention Array. This means the individual "cells" are represented like row and column idea. Inside each "cell" is the number to represent what exists as a symbol at that address onscreen. The editor's grid is based on "cells" in row and column form. A row is a collection of columns. So thats 19 rows of 25 columns. Thats 475 individual "cells". In the editor you fill a cell with color blue to indicate a wall. In the actual text page that wall is converted into character 176. In the Array that address holds the number 176. And so you build your map being careful to make each corridor only one cell wide. In fact the entire map MUST have no double empty cell spaces. The symbols that represent the objects in our game are 1] Wall = Ascii Characters 176 2] PacMan = 3] Red ghost = 4] Blue ghost = 5] White ghost = 6] Yellow ghost = 7] Fruit = 8] Empty =Ascii characters 32 So in the Array the number 176 is converted into the ASCII character code by the text page which is the equivalent of the graphic. So the 3 pages all represent the contents of each "cell" with data that is native to their style. Array is numbers Graphic is pixels Text is characters Now to complicate this even more the fact is once you can convert from one page to another then you can edit in any of the 3 pages and update the other two pages with the correct form of data that that page needs. One only has to write the code that does the conversion. In this editor i decided that the map would be composed with the graphic page. Each entry on this page is updated to the Array and the Text. Only the Graphic and Text is saved by the program. At run time the array can be created and filled by reading the Text page. Also the graphic can be recreated by the same method at run time. Ok so you have your Array filled with the data off the Text page. Inside the Array somewhere is the symbol to represent pac man. We find it by scanning the rows and columns of the array. Once found that address is the key to how we move him. For arguements sake we say he is at row10 and column10. If we want him to move east then we scan address row10,column11. If we want to move north we scan address row9,column10 If we want to move south we scan address row11,column10 If we want to move west we scan address row10,column9 So based off what each directions neighbouring "cell" has as its contents we can create in game logic to decide what should and does happen. This idea is alos used to replicate random movement by the ghosts. When a ghost comes to an intersection we use a random choice to decide new direction. With pac man its not random. While a corridor is empty he continually moves until he hits a wall or the user enters a key to ask to change direction. After this we need to create some random direction generator After this we need to create a find path to pac man function Title: Re: PacMan2f This one moves with arrow keys Post by: guest on March 02, 2011, 02:08:11 pm Heres an update that has instructions and saves map as both BMP and TXT data statements ready to cut and paste into a program. Remember the BMP file is overwritten and the TXT file gets added to. Best bet is to rename both files before you draw another map. Code: REM Best version yet. DEFLNG A-Z DIM SHARED mx, my, mbl, mbr DIM SHARED PacMap(19, 25) Video& = _NEWIMAGE(800, 600, 32) 'page we actually draw on Grid& = _NEWIMAGE(800, 600, 32) 'grid to place over monitor Text& = _NEWIMAGE(800, 600, 32) SCREEN _NEWIMAGE(800, 600, 32) 'what we see GOSUB Init Yellow& = _RGB32(255, 255, 0) MSBlue& = _RGB32(123, 104, 238) Black& = _RGB32(0, 0, 0) Blok$ = CHR$(176): Blank$ = CHR$(32) GOSUB Makemap _MOUSESHOW DO _CLEARCOLOR Black&, Grid& _PUTIMAGE , Grid&, 0 'copy yellow lines of grid only _PUTIMAGE , Video&, 0 MousePoll r = INT(mx \ 30) 'row r1 = r * 30 'x1 r2 = r1 + 30 'x2 c = INT(my \ 30) 'column c1 = c * 30 'y1 c2 = c1 + 30 'y2 IF mbl = -1 THEN GOSUB LFillbox IF mbr = -1 THEN GOSUB RFillbox IF _KEYDOWN(32) THEN _PUTIMAGE , Text&, 0 END IF _DEST 0 LOCATE 1, 95: PRINT mx LOCATE 2, 95: PRINT my LOCATE 4, 95: PRINT r + 1 LOCATE 5, 95: PRINT c + 1 LOOP UNTIL _KEYDOWN(27) GOSUB Savgrapmap 'save a bmp of it _DEST 0 LOCATE 10, 37: PRINT "FILE SAVED AS PacMap0.BMP" LOCATE 13, 37: PRINT "FILE SAVED AS PacMap0.TXT" SOUND 1500, 1: SOUND 2000, 1 SLEEP 1 GOSUB Savdatamap 'save as data statements in text SLEEP _FREEIMAGE Video& _FREEIMAGE Grid& _FREEIMAGE Text& SYSTEM '------------------------------ SUBS ------------------- Init: PRINT "Use left mice button to color cell blue" PRINT "Use right mice button to erase cell color to black" PRINT "When finished drawing press ESCAPE" PRINT "Program will save a copy as BMP named PacMap0.BMP" PRINT "Program will save a copy as DATA statements in text form named PacMap0.TXT" PRINT "Press any key" dummy$ = INPUT$(1) CLS RETURN Savgrapmap: SaveImage Video&, "PacMap0.bmp" RETURN Savdatamap: SCREEN 0 Temp$ = "": Comma$ = ",": Savfilename$ = "PacMap0.txt" cycle = 0 FOR c = 0 TO 18 FOR r = 0 TO 24 LOCATE c + 1, r + 1 z = PacMap(c, r) IF z = 0 THEN z = 32 PRINT CHR$(32) ELSE PRINT CHR$(z) END IF temp1$ = LTRIM$(STR$(z)) Temp$ = Temp$ + temp1$ + Comma$ NEXT r GOSUB Txtsaver Temp$ = "" NEXT c Temp$ = "" RETURN Txtsaver: z = LEN(Temp$) Temp$ = LEFT$(Temp$, z - 1) Temp$ = "DATA " + Temp$ OPEN Savfilename$ FOR APPEND AS #1 PRINT #1, Temp$ CLOSE #1 RETURN RFillbox: IF mx < 748 THEN IF my < 566 THEN _DEST Video& LINE (r1, c1)-(r2, c2), Black&, BF 'erase box _DEST Text& LOCATE c + 1, r + 1: PRINT Blank$ PacMap(c, r) = 32 END IF END IF RETURN LFillbox: IF mx < 748 THEN IF my < 566 THEN _DEST Video& LINE (r1, c1)-(r2, c2), MSBlue&, BF 'fill box _DEST Text& LOCATE c + 1, r + 1: PRINT Blok$ PacMap(c, r) = 176 END IF END IF RETURN Makemap: _DEST Grid& FOR x = 0 TO 740 STEP 30 FOR y = 0 TO 560 STEP 30 LINE (x, y)-(x + 30, y + 30), Yellow&, B NEXT y NEXT x RETURN SUB SaveImage (image AS LONG, filename AS STRING) bytesperpixel& = _PIXELSIZE(image&) IF bytesperpixel& = 0 THEN PRINT "Text modes unsupported!": END IF bytesperpixel& = 1 THEN bpp& = 8 ELSE bpp& = 24 x& = _WIDTH(image&) y& = _HEIGHT(image&) b$ = "BM????QB64????" + MKL$(40) + MKL$(x&) + MKL$(y&) + MKI$(1) + MKI$(bpp&) + MKL$(0) + "????" + MKL$(0) + MKL$(0) + MKL$(0) + MKL$(0) 'partial BMP header info(???? to be filled later) IF bytesperpixel& = 1 THEN FOR c& = 0 TO 255 ' read BGR color settings from JPG image + 1 byte spacer(CHR$(0)) cv& = _PALETTECOLOR(c&, image&) ' color attribute to read. b$ = b$ + CHR$(_BLUE32(cv&)) + CHR$(_GREEN32(cv&)) + CHR$(_RED32(cv&)) + CHR$(0) 'spacer byte NEXT END IF MID$(b$, 11, 4) = MKL$(LEN(b$)) ' image pixel data offset(BMP header) lastsource& = _SOURCE _SOURCE image& IF (x& AND 3) THEN padder$ = SPACE$(4 - (x& AND 3)) FOR py& = y& - 1 TO 0 STEP -1 ' read JPG image pixel color data r$ = "" FOR px& = 0 TO x& - 1 c& = POINT(px&, py&) IF bytesperpixel& = 1 THEN r$ = r$ + CHR$(c&) ELSE r$ = r$ + LEFT$(MKL$(c&), 3) NEXT px& d$ = d$ + r$ + padder$ NEXT py& _SOURCE lastsource& MID$(b$, 35, 4) = MKL$(LEN(d$)) ' image size(BMP header) b$ = b$ + d$ ' total file data bytes to create file MID$(b$, 3, 4) = MKL$(LEN(b$)) ' size of data file(BMP header) IF LCASE$(RIGHT$(filename$, 4)) <> ".bmp" THEN ext$ = ".bmp" f& = FREEFILE OPEN filename$ + ext$ FOR OUTPUT AS #f&: CLOSE #f& ' erases an existing file OPEN filename$ + ext$ FOR BINARY AS #f& PUT #f&, , b$ CLOSE #f& END SUB SUB MousePoll () DO WHILE _MOUSEINPUT mx = _MOUSEX: my = _MOUSEY: mbl = _MOUSEBUTTON(1): mbr = _MOUSEBUTTON(2) LOOP END SUB SUB ButtonRelease () IF mbl = 0 AND mbr = 0 THEN EXIT SUB WHILE mbl = -1 MousePoll WEND WHILE mbr = -1 MousePoll WEND END SUB Next comes the TXT file loader that creates the map graphically. Title: Re: PacMan2f This one moves with arrow keys Post by: guest on March 02, 2011, 02:52:57 pm Heres an example map and code to display it. Note the "cell" created is just a block as yet. Graphic pics could be loaded and placed at same places. Code: REM Demo of Pac Map. Next comes an example map with a moveable PacMan.DEFLNG A-Z DIM SHARED mx, my, mbl, mbr DIM SHARED PacMap(19, 25) SCREEN _NEWIMAGE(800, 600, 32) 'what we see GOSUB Filldim DO LOOP UNTIL _KEYDOWN(27) SLEEP SCREEN 0 SYSTEM Filldim: FOR c = 0 TO 18 FOR r = 0 TO 24 READ Z PacMap(c, r) = Z 'PacMap(r, c) = Z IF Z = 176 THEN LINE (r * 30, c * 30)-((r * 30) + 29, (c * 30) + 29), _RGB32(255, 255, 0), BF END IF NEXT r NEXT c RETURN '-------------------------- MAP -------------------------------------- DATA 176,176,176,176,176,176,176,176,176,176,176,176,32,176,176,176,176,176,176,176,176,176,176,176,176 DATA 176,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,176 DATA 176,32,176,176,176,176,176,176,176,176,176,32,176,32,176,176,176,176,176,176,176,176,176,32,176 DATA 176,32,176,32,32,32,32,32,32,32,32,32,176,32,176,32,32,32,32,32,32,32,176,32,176 DATA 176,32,176,32,176,176,176,176,32,176,176,32,176,32,176,32,176,176,176,176,176,32,176,32,176 DATA 176,32,176,32,176,32,32,32,32,32,176,32,176,32,176,32,32,32,32,32,32,32,176,32,176 DATA 176,32,176,32,176,32,176,176,32,176,176,32,176,32,176,32,176,32,176,32,176,32,32,32,176 DATA 176,32,32,32,176,32,32,32,32,32,32,32,32,32,32,32,176,32,176,32,176,32,176,32,176 DATA 176,32,176,32,176,32,176,176,176,32,176,176,32,176,176,32,32,32,176,32,32,32,176,32,176 DATA 32,32,176,32,32,32,32,32,32,32,176,32,32,32,176,32,176,176,176,176,176,32,176,32,32 DATA 176,32,176,32,176,32,176,176,176,32,176,176,176,176,176,32,32,32,176,32,32,32,176,32,176 DATA 176,32,32,32,176,32,32,32,32,32,32,32,32,32,32,32,176,32,176,32,176,32,176,32,176 DATA 176,32,176,32,176,32,176,176,32,176,176,32,176,32,176,32,176,32,176,32,176,32,32,32,176 DATA 176,32,176,32,176,32,32,32,32,32,176,32,176,32,176,32,32,32,32,32,32,32,176,32,176 DATA 176,32,176,32,176,176,176,176,32,176,176,32,176,32,176,32,176,176,176,176,176,32,176,32,176 DATA 176,32,176,32,32,32,32,32,32,32,32,32,176,32,176,32,32,32,32,32,32,32,176,32,176 DATA 176,32,176,176,176,176,176,176,176,176,176,32,176,32,176,176,176,176,176,176,176,176,176,32,176 DATA 176,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,176 DATA 176,176,176,176,176,176,176,176,176,176,176,176,32,176,176,176,176,176,176,176,176,176,176,176,176 Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on March 02, 2011, 11:58:07 pm I got a little side tracked tonight, but did look at these,..and tried them,
On the map maker ( editor ) I am haveing soem trouble, with it fitting onmy screen. It dose work, though,...usually for me , if I use alt-enter, to get full screen, the program, then fits in my screen, the trouble is when I did this, on this, I lose my mouse, arrow, so I can't see where the mouse is, only by the pixel coordinates, that are shown, on the upper right, I can tell where it is. It is real late and I am tired,..I am thinking I could change Quote SCREEN _NEWIMAGE(800, 600, 32) 'what we see to a smaller size, ?I may just try that now before I go to sleep. from Garry Note,..just changeing this, didn't work. Also,the mouse dissapearing if I use full screen, Any ideas ? This did not occur with the 1st "best version yet " map maker,...before you had the text file saver. But it dose work fine as far as creating both the :bmp and txt file , and saveing them. form Garry Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on March 04, 2011, 07:43:16 pm Ok, I added _MOUSESHOW above the DO line and it now works fine useing
full screen, Note: MOUSESHOW by itself gets a syntex error message, it need the _MOUSESHOW, I was able to guess that, as many or most of the new, keywords, and comands start with the _KEYWORD thanks from Garry Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on March 06, 2011, 02:21:50 pm Hi all, I did some searches, for midi sound affects, or music, and allthough I found lots of stuff, nothing that I really like. I am working on something, now,Say hello to our NEW PROJECT Garry. Together we will make this a good game. Round up some midi music for us please! OlDosLover. First will be a background sort of "theme", and then separate, some sounds, useing orchresta effects (horns,bass,etc), that will be for when PacMan eats a enemy (ghost), ...when I have them ready I will post the samples....Also I am thinking about some thing to go with the catch the bunny game, but that will get posted, there,...separate. From Garry posted, Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on March 06, 2011, 08:46:35 pm Here is one midi, I like it, I let it play, at the same time as I had the PacyMan.bas running, it could be the ,"background music", if yu like it,
I do, but every one has theyre own tastes,...the only problem for me is I don't know how to put it in so it plays, while the program runs. This is the a link to the post, with the code sample you made: which is what I am useing: http://weeklyqbasicandqb64lesson.smfforfree.com/index.php/topic,35.msg147.html#msg147 And here is the midi. http://dl.dropbox.com/u/15387474/PacMan2.rar If you prefer, post the sample in "my experiment" If you have time, and thanks, hope you like it. I will work on some others, short,"bursts", for like when a enemy is "eaten", and or the dots, ( I think for the dots, either a short "chirp",or beep,) I'll post a sample, later. from Gary P.S. if we do this right, we could come up with something where people can put in theyre own "background music or sounds", customize so to speak, in my case, after awhile I get bored, with always the same sounds, evry time I play a game,...I say we, but you are doing most ogf the hardest part with the code!.... from Garry edit : sorry I thought I had changed this to .rar, now I did Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on March 06, 2011, 10:02:54 pm ok, it will just be a few minuets, I just got back
frm Garry Here it is zipped: http://dl.dropbox.com/u/15387474/PacMan2.rar from Garry Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on March 07, 2011, 11:52:35 pm Hello, Here is 3 more midis, in a zipped RAR folder, these could be used in this,
or in "My experiment" Whichever one you like, http://dl.dropbox.com/u/15387474/midis.rar from Garry Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on March 08, 2011, 01:08:59 am Ok, good,
I had been trying to get some other programs, to play the midi,... and although it plays, it dose not play the entire time the prgram runs,...just once, and then it stops....So I thin I need some help in the correct way, to place Code: mid1& = _SNDOPEN("hi_hat.mid", "vol") in a program, all though it worked in "my experiment", in others no go. Maybe tommorow, I am real tired now..._SNDVOL mid1&, 0.7 _SNDPLAY mid1& from Garry Title: Re: PacMan2f This one moves with arrow keys Post by: guest on March 08, 2011, 01:22:23 am You have to poll for soundplaying. The _SNDPLAYING function returns whether a sound is being played. Uses a handle from the _SNDOPEN or _SNDCOPY functions. Syntax: playing% = _SNDPLAYING (handle&) Description: Returns 0 if a sound is not playing or -1 if it is. If a sound is paused, _SNDPLAYING will return 0. So if you compose a loop and have a place inside that loop that checks if sound is playing then if the sound stops soundplaying returns a zero so based off that zero you branch to load and play the sound again. Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on March 08, 2011, 01:44:39 am You have to poll for soundplaying. The _SNDPLAYING function returns whether a sound is being played. Uses a handle from the _SNDOPEN or _SNDCOPY functions. Syntax: playing% = _SNDPLAYING (handle&) Description: Returns 0 if a sound is not playing or -1 if it is. If a sound is paused, _SNDPLAYING will return 0. Code: '-----------------------------------------------------code for sound OK, This works too, my error was not includeing the _soundloop , that is why it was only playing once, the other thing, the high_hat.mid has a real long space of silence, in the middle, one may think it is not going to continue, but it dose. I did not write the 3 I just posted. volume = 1 ' full volume gamestart = False ' no game yet intromusic = _SNDOPEN("munchies.mid", "VOL") ' open intro music _SNDVOL intromusic, volume ' set music volume _SNDLOOP intromusic ' PRINT "This is my Music" I tried the munchies.mid with UnseensGDK, "Garrysgame"(catch the bunny) It worked, but I did not have the _sndloop in it so it did not keep playing continuesly. So if you compose a loop and have a place inside that loop that checks if sound is playing then if the sound stops soundplaying returns a zero so based off that zero you branch to load and play the sound again. This makes sense, and explains why I could not put the sound inside the main loop. It is hard when I am so tired, well I will "dream" on this, I think I understand better. Thanks and see you later from Garry Title: Re: PacMan2f This one moves with arrow keys Post by: guest on March 08, 2011, 01:53:10 am Code: REM DEFLNG A-Z CHDIR "c:\windows\media\" 'xp files reside here or put file in qb64 main folder mid1& = _SNDOPEN("hi_hat.mid", "vol") _SNDVOL mid1&, 0.7 SCREEN 12 DO _LIMIT 100 x1 = INT(RND * 600) + 20 y1 = INT(RND * 400) + 20 r = INT(RND * 10) + 1 tint = INT(RND * 15) + 1 PSET (x1, y1), tint CIRCLE (x1, y1), r, tint IF NOT _SNDPLAYING(mid1&) THEN _SNDPLAY mid1& END IF IF _KEYDOWN(27) THEN EXIT DO END IF _DISPLAY LOOP _SNDSTOP mid1& _SNDCLOSE mid1& SLEEP SYSTEM Title: Re: PacMan2f This one moves with arrow keys Post by: Jim Tester on March 09, 2011, 10:24:45 pm I am going to make a enemy (ghost), if I use 54 x 54 pixels , for the sprite,
is that correct . Here it is, Sorry I forgot to zip it, I am not thinking very clearly tonight. http://dl.dropbox.com/u/15387474/Ghost.bmp From Garry ( Jim tester ) Title: Re: PacMan2f This one moves with arrow keys Post by: guest on March 10, 2011, 04:15:36 pm Here is an update that alows movement off the arrow keys. This is more a demonstration or proof of concept. This wont be the final version. Code: REM Demo of Pac Map. DEFLNG A-Z SCREEN _NEWIMAGE(800, 600, 32) 'what we see DIM SHARED mx, my, mbl, mbr DIM SHARED PacMap(19, 25) DIM SHARED Pacrow, Paccol, Pacsym, N, S, E, W, NN, SS, EE, WW Pacsym = 10: Pacrow = 1: Paccol = 7 GOSUB Filldim GOSUB Placepac 'NOTE row and column start at 0 DO _LIMIT 15 CLS GOSUB Showmap GOSUB Movpac LOCATE 33, 1: PRINT Pacrow, Paccol, N, E, S, W LOCATE 34, 1: PRINT NN, EE, SS, WW _DISPLAY LOOP UNTIL _KEYDOWN(27) SLEEP SCREEN 0 SYSTEM Movpac: 'make a backup of PAC row and column OlDPacrow = Pacrow: OldPaccol = Paccol 'we need to know what is above,below,to right and left for possible unblocked movement 'if any of NSEW is a limit on the map make it invalid as -1 N = Pacrow - 1 IF N < 0 THEN N = -1 S = Pacrow + 1 IF S > 18 THEN S = -1 E = Paccol + 1 IF E > 24 THEN E = -1 W = Paccol - 1 IF W < 0 THEN W = -1 'now if NSEW are valid see whats in those "cells" IF N <> -1 THEN NN = PacMap(N, Paccol) IF S <> -1 THEN SS = PacMap(S, Paccol) IF E <> -1 THEN EE = PacMap(Pacrow, E) IF W <> -1 THEN WW = PacMap(Pacrow, W) IF _KEYDOWN(20480) THEN 'down arrow key IF SS <> 176 THEN 'test for wall IF S <> -1 THEN 'test for map limit Pacrow = Pacrow + 1 END IF END IF END IF IF _KEYDOWN(18432) THEN 'up arrow key IF NN <> 176 THEN IF N <> -1 THEN Pacrow = Pacrow - 1 END IF END IF END IF IF _KEYDOWN(19200) THEN 'left arrow key IF WW <> 176 THEN IF W <> -1 THEN Paccol = Paccol - 1 END IF END IF END IF IF _KEYDOWN(19712) THEN 'right arrow key IF EE <> 176 THEN IF E <> -1 THEN Paccol = Paccol + 1 END IF END IF END IF IF Pacrow <> OlDPacrow OR Paccol <> OldPaccol THEN 'remove pac man from old position z = PacMap(OlDPacrow, OldPaccol) ''extract old pac man z = z - Pacsym ''suntract pacman symbol from it (42 - 10 = 32) PacMap(OlDPacrow, OldPaccol) = z ''place z back inside map 'add new pac to new position z = PacMap(Pacrow, Paccol) ''extract whats at this new row and column (should be 32) z = z + Pacsym ''add pacman symbol to it (32 +10 = 42) PacMap(Pacrow, Paccol) = z ''place in back inside map END IF RETURN Showmap: FOR c = 0 TO 18 FOR R = 0 TO 24 z = PacMap(c, R) SELECT CASE z CASE 32 CASE 42 LINE (R * 30, c * 30)-((R * 30) + 29, (c * 30) + 29), _RGB32(255, 255, 0), BF CASE 176 LINE (R * 30, c * 30)-((R * 30) + 29, (c * 30) + 29), _RGB32(0, 0, 255), BF END SELECT NEXT R NEXT c RETURN Filldim: FOR c = 0 TO 18 FOR R = 0 TO 24 READ z PacMap(c, R) = z 'PacMap(r, c) = Z IF z = 176 THEN LINE (R * 30, c * 30)-((R * 30) + 29, (c * 30) + 29), _RGB32(0, 0, 255), BF END IF NEXT R NEXT c RETURN Placepac: 'extract whats at this row and column (should be 32) z = PacMap(Pacrow, Paccol) 'add pacman symbol to it (32 +10 = 42) z = z + Pacsym 'place in back inside map PacMap(Pacrow, Paccol) = z RETURN '-------------------------- MAP -------------------------------------- DATA 176,176,176,176,176,176,176,176,176,176,176,176,32,176,176,176,176,176,176,176,176,176,176,176,176 DATA 176,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,176 DATA 176,32,176,176,176,176,176,176,176,176,176,32,176,32,176,176,176,176,176,176,176,176,176,32,176 DATA 176,32,176,32,32,32,32,32,32,32,32,32,176,32,176,32,32,32,32,32,32,32,176,32,176 DATA 176,32,176,32,176,176,176,176,32,176,176,32,176,32,176,32,176,176,176,176,176,32,176,32,176 DATA 176,32,176,32,176,32,32,32,32,32,176,32,176,32,176,32,32,32,32,32,32,32,176,32,176 DATA 176,32,176,32,176,32,176,176,32,176,176,32,176,32,176,32,176,32,176,32,176,32,32,32,176 DATA 176,32,32,32,176,32,32,32,32,32,32,32,32,32,32,32,176,32,176,32,176,32,176,32,176 DATA 176,32,176,32,176,32,176,176,176,32,176,176,32,176,176,32,32,32,176,32,32,32,176,32,176 DATA 32,32,176,32,32,32,32,32,32,32,176,32,32,32,176,32,176,176,176,176,176,32,176,32,32 DATA 176,32,176,32,176,32,176,176,176,32,176,176,176,176,176,32,32,32,176,32,32,32,176,32,176 DATA 176,32,32,32,176,32,32,32,32,32,32,32,32,32,32,32,176,32,176,32,176,32,176,32,176 DATA 176,32,176,32,176,32,176,176,32,176,176,32,176,32,176,32,176,32,176,32,176,32,32,32,176 DATA 176,32,176,32,176,32,32,32,32,32,176,32,176,32,176,32,32,32,32,32,32,32,176,32,176 DATA 176,32,176,32,176,176,176,176,32,176,176,32,176,32,176,32,176,176,176,176,176,32,176,32,176 DATA 176,32,176,32,32,32,32,32,32,32,32,32,176,32,176,32,32,32,32,32,32,32,176,32,176 DATA 176,32,176,176,176,176,176,176,176,176,176,32,176,32,176,176,176,176,176,176,176,176,176,32,176 DATA 176,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,176 DATA 176,176,176,176,176,176,176,176,176,176,176,176,32,176,176,176,176,176,176,176,176,176,176,176,176 Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on March 10, 2011, 06:54:10 pm Quote Hi all, Garry we need: 1] PacMan crunch sound (eat dot) 2] Pac Man eat ghost sound 3] Ghost attack sound 4] Pac Man die sound 5] Background music. The ghost graphics can be 40 x 40 as we will scale them down. I think my Pac Man is 30 x 30. OlDosLover. Ok, in response, to your Pm,yes this better, as the reader, can look at the previous posts, if neccesary, while posting,... Ok on the sounds,... Quote 1] Each graphic be 20 pixels by 20 pixels in size. This is the size on the screen ? 1.---The ghosts, Ok on 40 x 40 the sample had been 54 x 54 , and is saved as 256 bmp, is 256 ok ?, or please advise,... 2. screen resolution 800x600, ok with me, 3...ok 4.___My feelings on the levels, 3 to start, this depends much on you,...the original, game is something like 35 levels....but that is a lot of work, I think with 3 levels, one would have a pretty good idea, as to how to create and add more if they wish, or dose this need to be decided at the beginning ? If so, can it be started, with the plan to eventually have 25 levels, but run ok, with just 2 or 3, to start ? Do I make sense ? 5.___oops sorry, ..then 25 total, possible,...and I think 3 unique, layouts, 6. Perhaps, can we make that optional,...on the lives ? 5 being the max ? The orginal has 4, pills, guess that could be the same 4,..on the rewards, need to think a litle more, , also the score, bombs is a new "twist",...What about, 3 "bombs", or like in the SMEGABUG (terry Richies) wormholes, with the bomb, pacman can "blast! a hole, in the wall of the maze, to escape the ghosts, if that is possible or not too complicated, in the original, I always found it very frustrateing, when the ghosts "trap" me, it would be nice to have a "bomb", so I could blast a hole in the wall, and escape..... Ok guess, thats about it for now,... PS:I tried this Quote Hi all, Looks good,....I saved it as Pacmanstage2.basHere is an update that alows movement off the arrow keys. This is more a demonstration or proof of concept. This wont be the final version. from Garry Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on March 10, 2011, 08:24:58 pm Quote Final sprite sheet will be 32 bit with 20 x 20 sptites. I was just looking, my version of MS paint dose not show a option for 32 bit24 bit, 16colors, 256colors, monochrome, png ,jpeg,tiff,Gif, is all the options ? Is 24bit ok, I just checked paintshop pro, and it is bacsicly the same ? From Garry Edit: I did a google, on mspaint 32 bit, Are you useing windows 7 ?...but it also looks like there is a way to upgrade mine,... from Garry Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on March 11, 2011, 12:15:00 am Ok, thats good.
Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on March 13, 2011, 11:51:04 pm Here are 4 new ghosts,..on sa sprite sheet, if they seem ok, I can do the other 12, and put them all on one sheet (all 16) or Is it better 1 Sprt sheet for each 4 ? They are pretty big, to make it easy for me to edit, and draw them.You will notice the ghost seems a little smaller, in the up,or front faceing view, thats ok, I am hopeing it will give a slight effect, of changeing size, the frame is still the same size square.But if you don't like it, I can change it, the other colors would be basicly the same, if these work well.
The Fullsize Sprt sheet http://dl.dropbox.com/u/15387474/GhostSprts_blu.bmp ----------------------------------------------------- Attached are some little ones, that are 20 x 20 frames, but when I reduced them, it may not have scaled right....don't know if the frames will work right. from Garry Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on March 14, 2011, 12:53:03 am You may be right, but I think I like these,to be honest, it is hard to tell,until it is the maze and moveing around, would that be to hard at this point ? to just do the one ( 4 frames),.. no real need for the pacman, but that would be interesting too,...When I see how this one looks inside the walls, and when he goes up or down,left or right,...I will know more clearly, which is why I kind of want to wait on the others,...Also, the others, the colors, I was thinking pink, red, and a Darker Blue (but that still show on the black well), will that be anyproblem, in relation to color blindness ? I guess green is not a good option ?
from Garry Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on March 14, 2011, 01:43:48 am Not sure on the yellow, the others yes, I am going to look now, before I go to sleep,...
from Garry Title: Re: PacMan2f This one moves with arrow keys Post by: guest on March 15, 2011, 07:31:41 am Here's a demo with your ghosts Garry. I reduced the overall size of the graphic sheet to 800,200. This makes each individual graphic 200 x 200. Here the link to the graphic:http://dl.dropbox.com/u/10291175/GhostBlue1.rar (http://dl.dropbox.com/u/10291175/GhostBlue1.rar) Code: REM DEFLNG A-Z Sprite& = _LOADIMAGE("GhostBlue1.bmp", 32) Video& = _NEWIMAGE(800, 600, 32) SCREEN Video& _PUTIMAGE (50, 199)-(750, 399), Sprite&, Video& LINE (50, 199)-(750, 399), _RGB32(255, 255, 0), B PAINT (10, 10), _RGB32(255, 255, 255) x = 10: y = 10: State = 1 DO _LIMIT 100 _PUTIMAGE (50, 199)-(750, 399), Sprite&, Video& LINE (50, 199)-(750, 399), _RGB32(255, 255, 0), B SELECT CASE State CASE IS = 1 x = x + 1 IF x >= 750 THEN x = 750: State = 2 END IF _PUTIMAGE (x, y)-(x + 40, y + 40), Sprite&, Video&, (0, 0)-(199, 199) CASE IS = 2 y = y + 1 IF y >= 550 THEN y = 550: State = 3 END IF _PUTIMAGE (x, y)-(x + 40, y + 40), Sprite&, Video&, (200, 0)-(399, 199) CASE IS = 3 x = x - 1 IF x <= 10 THEN x = 10: State = 4 END IF _PUTIMAGE (x, y)-(x + 40, y + 40), Sprite&, Video&, (400, 0)-(599, 199) CASE IS = 4 y = y - 1 IF y <= 10 THEN y = 10: State = 1 END IF _PUTIMAGE (x, y)-(x + 40, y + 40), Sprite&, Video&, (600, 0)-(799, 199) END SELECT _DISPLAY LOOP UNTIL _KEYDOWN(27) SLEEP SYSTEM Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on March 15, 2011, 07:54:45 pm Not sure on the yellow, the others yes, I am going to look now, before I go to sleep,... I had forgotten, the colors are,RED, ORANGE, BLUE, PINKfrom Garry The moveing ghost,...thats pretty good, and I can use the same, code to view the others,.... I think I would like to make the ghost, with more movement,.if you notice in the game I sent you for Dos, they litlle "feet" like things, at the bottom,..I am thinking these (originals) are done with data bit map. ,I suspect,...it is a little hard to explain, especially since I don't know exactly how the effect is accomplished,... If I make a few more frames,so we have a animation, giveing a rippleing effect, of the bottom part or the ghost, and the eyes moveing. I hope I make sense,.... Your code is fine, for these, but to be honest, I am not to happy with them, (the ghosts) I am going to make some new ones, not sure, how soon, as I have to go out of town, tommorow, for a job we are doing, it may be the weekend before, I can do it,... I will make a gif, animation, but the .png images that are use to make the animation, are easily converted to .bmp and then put on a sprite sheet, actually, useing Unseens sprite sheet maker , BMP or PNG dose not matter, the sprite sheet is saved as BMP. Anyway, THANKS!, because now, I have a very clear idea of how to do this Ghost,....the next ones will be "perfect",..! ( I hope) I am sort of "thinking out loud. I have already seen in some of your DEMOS, you will know how, to load the sprite, (sprite sheet), with _putimage....and the ghost will have the movments, "rippleing" or "shimmering" effect I am after.I did notice also in the original game, like yu said, they eye movement, and also, the ghosts, do not rotate,...they are the same,..just the "feet" thingys, and the eyes, are moveing,... Guess thats about it, thanks, on this "mini program", it definately worked, for what I needed to see.... from Garry Title: Re: PacMan2f This one moves with arrow keys Post by: guest on March 15, 2011, 08:54:07 pm ere are some freeware pac man graphics i got off the net. Id suggest we modify and use them. Here's the link. http://dl.dropbox.com/u/10291175/pacman_gfx_starter_kit_968.rar (http://dl.dropbox.com/u/10291175/pacman_gfx_starter_kit_968.rar) Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on March 17, 2011, 07:31:03 pm I had not noticed, you updated the link for some pacman sprites,intil just now,
so I will try it in a minuete. I did these last night,.... This is the sprite sheet,... http://dl.dropbox.com/u/15387474/newghost_blu.bmp This is the animation http://dl.dropbox.com/u/15387474/ghost2.gif What I am especially interested in, now is similar code, as before, but to load the animation,...Do I make sense ?...If that is not to much trouble,... If the sizes need to be changed, let me know. from Garry Title: Re: PacMan2f This one moves with arrow keys Post by: Guest on March 19, 2011, 10:45:25 am Here's an example of the new PacMan graphics. They are 40x40 and once decided the exact size they will be scaled to we will incorporate them. I was thinking of 20x20 but that may be too small. We may have to go a bigger window like 1200 x 800 and keep them as 40x40. Anyway here's a demo of them. Code: REM Here's the url to the image:http://dl.dropbox.com/u/10291175/PacManSS-2-40x40.rar (http://dl.dropbox.com/u/10291175/PacManSS-2-40x40.rar)DEFLNG A-Z Sprites& = _LOADIMAGE("Pacmanss-2-40x40.bmp", 32) Video& = _NEWIMAGE(640, 480, 32) SCREEN Video& GPlace = 1: gx = 320: gy = 10: GCycle = 0 PPlace = 1: px = 320: py = 100: PCycle = 0 DO _LIMIT 30 GOSUB GMove GOSUB PMove CLS GCycle = GCycle + 1: IF GCycle = 3 THEN GCycle = 1 PCycle = PCycle + 1: IF PCycle >= 4 THEN PCycle = 1 'move ghost SELECT CASE GPlace CASE 1 '-----------------------------------------------------------------------------Face right IF GCycle = 1 THEN _PUTIMAGE (gx, gy)-(gx + 39, gy + 39), Sprites&, Video&, (82, 0)-(121, 39) ELSE _PUTIMAGE (gx, gy)-(gx + 39, gy + 39), Sprites&, Video&, (123, 0)-(162, 39) END IF CASE 2 '-----------------------------------------------------------------------------Face down IF GCycle = 1 THEN _PUTIMAGE (gx, gy)-(gx + 39, gy + 39), Sprites&, Video&, (246, 0)-(285, 39) ELSE _PUTIMAGE (gx, gy)-(gx + 39, gy + 39), Sprites&, Video&, (287, 0)-(326, 39) END IF CASE 3 '-----------------------------------------------------------------------------Face left IF GCycle = 1 THEN _PUTIMAGE (gx, gy)-(gx + 39, gy + 39), Sprites&, Video&, (0, 0)-(39, 39) ELSE _PUTIMAGE (gx, gy)-(gx + 39, gy + 39), Sprites&, Video&, (41, 0)-(80, 39) END IF CASE 4 '-----------------------------------------------------------------------------Face up IF GCycle = 1 THEN _PUTIMAGE (gx, gy)-(gx + 39, gy + 39), Sprites&, Video&, (164, 0)-(203, 39) ELSE _PUTIMAGE (gx, gy)-(gx + 39, gy + 39), Sprites&, Video&, (205, 0)-(244, 39) END IF END SELECT 'move pac man SELECT CASE PPlace CASE 1 IF PCycle = 1 THEN _PUTIMAGE (px, py)-(px + 39, py + 39), Sprites&, Video&, (164, 164)-(203, 203) IF PCycle = 2 THEN _PUTIMAGE (px, py)-(px + 39, py + 39), Sprites&, Video&, (205, 164)-(244, 203) IF PCycle = 3 THEN _PUTIMAGE (px, py)-(px + 39, py + 39), Sprites&, Video&, (246, 164)-(285, 203) CASE 2 IF PCycle = 1 THEN _PUTIMAGE (px, py)-(px + 39, py + 39), Sprites&, Video&, (164, 164)-(203, 203) IF PCycle = 2 THEN _PUTIMAGE (px, py)-(px + 39, py + 39), Sprites&, Video&, (205, 164)-(244, 203) IF PCycle = 3 THEN _PUTIMAGE (px, py)-(px + 39, py + 39), Sprites&, Video&, (246, 164)-(285, 203) CASE 3 IF PCycle = 1 THEN _PUTIMAGE (px, py)-(px + 39, py + 39), Sprites&, Video&, (203, 164)-(164, 203) IF PCycle = 2 THEN _PUTIMAGE (px, py)-(px + 39, py + 39), Sprites&, Video&, (244, 164)-(205, 203) IF PCycle = 3 THEN _PUTIMAGE (px, py)-(px + 39, py + 39), Sprites&, Video&, (285, 164)-(246, 203) CASE 4 IF PCycle = 1 THEN _PUTIMAGE (px, py)-(px + 39, py + 39), Sprites&, Video&, (203, 164)-(164, 203) IF PCycle = 2 THEN _PUTIMAGE (px, py)-(px + 39, py + 39), Sprites&, Video&, (244, 164)-(205, 203) IF PCycle = 3 THEN _PUTIMAGE (px, py)-(px + 39, py + 39), Sprites&, Video&, (285, 164)-(246, 203) END SELECT _DISPLAY LOOP UNTIL _KEYDOWN(27) SLEEP SYSTEM GMove: SELECT CASE GPlace CASE 1 gx = gx + 4 IF gx >= 590 THEN gx = 590: GPlace = 2 CASE 2 gy = gy + 4 IF gy >= 430 THEN gy = 430: GPlace = 3 CASE 3 gx = gx - 4 IF gx <= 10 THEN gx = 10: GPlace = 4 CASE 4 gy = gy - 4 IF gy <= 10 THEN gy = 10: GPlace = 1 END SELECT RETURN PMove: SELECT CASE PPlace CASE 1 px = px + 4 IF px >= 540 THEN px = 540: PPlace = 2 CASE 2 py = py + 4 IF py >= 380 THEN py = 380: PPlace = 3 CASE 3 px = px - 4 IF px <= 100 THEN px = 100: PPlace = 4 CASE 4 py = py - 4 IF py <= 100 THEN py = 100: PPlace = 1 END SELECT RETURN Title: Re: PacMan2f This one moves with arrow keys Post by: Dustie Bear on March 19, 2011, 11:10:54 am Hi, This is realy neat what you two are doing with pacman May I make a suggestion. Could you place the code in the rar files with the pictures then we dont have to save the code then come back and DL the pics seperatly. Just a thought, its ok the way your doing, Im just lazy I guess. LOL Dustie Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on March 19, 2011, 11:05:16 pm Oldoslover, those look good, the pac man and the ghost,...since you already have these, no need to post them again, ....
Guess thats about it, looking forward to seeing how these are put into the maze,... from Garry Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on March 27, 2011, 05:26:54 pm I made a maze useing the program olddoslover , and have been trying to get
the PacMan, and the ghosts,inside the maze, but no luck, All I get is the maze loading as a bacground, The pac man moves around with the arrow keys, and the ghost, but they do not stay in the walls, they go right over or through them,..? I don't see any point in posting the code, because it dose not work right at all. Maybe I should,..sorry I have not been on much, I was out of town all of last week. from Garry Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on March 28, 2011, 08:59:31 am OK, I found a Demo, at petesqbasicsite, but for one it is for qb45, it is pretty neat,but it dose not include the entire source, the .bas can not be run by itself, but just looking at it, yes I can see it is going to take some time, it gets pretty complicated,...
thanks from Garry Title: Re: PacMan2f This one moves with arrow keys Post by: guest on April 03, 2011, 01:36:45 pm Here's an update showing PacMan responding to key movement and correct facing direction. Code: REM Demo of Pac Map and PacMan movement. DEFLNG A-Z Graphics& = _LOADIMAGE("GMPacMan1.bmp", 32) SCREEN _NEWIMAGE(800, 600, 32) 'what we see DIM SHARED mx, my, mbl, mbr DIM SHARED PacMap(19, 25) DIM SHARED Pacrow, Paccol, Pacsym, N, S, E, W, NN, SS, EE, WW Pacsym = 10: Pacrow = 1: Paccol = 7: Pacframe = 1: PacDir = 2 'east GOSUB Filldim GOSUB Placepac 'NOTE row and column start at 0 DO _LIMIT 15 CLS GOSUB Showmap GOSUB Movpac LOCATE 33, 1: PRINT Pacrow, Paccol, N, E, S, W LOCATE 34, 1: PRINT NN, EE, SS, WW Pacframe = Pacframe + 1 IF Pacframe >= 5 THEN Pacframe = 1 _DISPLAY LOOP UNTIL _KEYDOWN(27) SLEEP SCREEN 0 SYSTEM Movpac: 'make a backup of PAC row and column OlDPacrow = Pacrow: OldPaccol = Paccol 'we need to know what is above,below,to right and left for possible unblocked movement 'if any of NSEW is a limit on the map make it invalid as -1 N = Pacrow - 1 IF N < 0 THEN N = -1 S = Pacrow + 1 IF S > 18 THEN S = -1 E = Paccol + 1 IF E > 24 THEN E = -1 W = Paccol - 1 IF W < 0 THEN W = -1 'now if NSEW are valid see whats in those "cells" IF N <> -1 THEN NN = PacMap(N, Paccol) IF S <> -1 THEN SS = PacMap(S, Paccol) IF E <> -1 THEN EE = PacMap(Pacrow, E) IF W <> -1 THEN WW = PacMap(Pacrow, W) IF _KEYDOWN(20480) THEN 'down arrow key IF SS <> 176 THEN 'test for wall IF S <> -1 THEN 'test for map limit Pacrow = Pacrow + 1 PacDir = 3 'south END IF END IF END IF IF _KEYDOWN(18432) THEN 'up arrow key IF NN <> 176 THEN IF N <> -1 THEN Pacrow = Pacrow - 1 PacDir = 1 'north END IF END IF END IF IF _KEYDOWN(19200) THEN 'left arrow key IF WW <> 176 THEN IF W <> -1 THEN Paccol = Paccol - 1 PacDir = 4 'west END IF END IF END IF IF _KEYDOWN(19712) THEN 'right arrow key IF EE <> 176 THEN IF E <> -1 THEN Paccol = Paccol + 1 PacDir = 2 'east END IF END IF END IF IF Pacrow <> OlDPacrow OR Paccol <> OldPaccol THEN 'remove pac man from old position z = PacMap(OlDPacrow, OldPaccol) ''extract old pac man z = z - Pacsym ''suntract pacman symbol from it (42 - 10 = 32) PacMap(OlDPacrow, OldPaccol) = z ''place z back inside map 'add new pac to new position z = PacMap(Pacrow, Paccol) ''extract whats at this new row and column (should be 32) z = z + Pacsym ''add pacman symbol to it (32 +10 = 42) PacMap(Pacrow, Paccol) = z ''place in back inside map END IF RETURN Showmap: FOR c = 0 TO 18 FOR R = 0 TO 24 z = PacMap(c, R) SELECT CASE z CASE 32 CASE 42 SELECT CASE PacDir CASE 1 'N SELECT CASE Pacframe CASE 1 _PUTIMAGE (R * 30, c * 30)-((R * 30) + 29, (c * 30) + 29), Graphics&, 0, (164, 285)-(203, 246) CASE 2 _PUTIMAGE (R * 30, c * 30)-((R * 30) + 29, (c * 30) + 29), Graphics&, 0, (205, 285)-(244, 246) CASE 3 _PUTIMAGE (R * 30, c * 30)-((R * 30) + 29, (c * 30) + 29), Graphics&, 0, (246, 285)-(285, 246) CASE 4 _PUTIMAGE (R * 30, c * 30)-((R * 30) + 29, (c * 30) + 29), Graphics&, 0, (287, 285)-(326, 246) END SELECT CASE 2 'E SELECT CASE Pacframe CASE 1 _PUTIMAGE (R * 30, c * 30)-((R * 30) + 29, (c * 30) + 29), Graphics&, 0, (0, 246)-(39, 285) CASE 2 _PUTIMAGE (R * 30, c * 30)-((R * 30) + 29, (c * 30) + 29), Graphics&, 0, (41, 246)-(80, 285) CASE 3 _PUTIMAGE (R * 30, c * 30)-((R * 30) + 29, (c * 30) + 29), Graphics&, 0, (82, 246)-(121, 285) CASE 4 _PUTIMAGE (R * 30, c * 30)-((R * 30) + 29, (c * 30) + 29), Graphics&, 0, (123, 246)-(162, 285) END SELECT CASE 3 'S SELECT CASE Pacframe CASE 1 _PUTIMAGE (R * 30, c * 30)-((R * 30) + 29, (c * 30) + 29), Graphics&, 0, (164, 246)-(203, 285) CASE 2 _PUTIMAGE (R * 30, c * 30)-((R * 30) + 29, (c * 30) + 29), Graphics&, 0, (205, 246)-(244, 285) CASE 3 _PUTIMAGE (R * 30, c * 30)-((R * 30) + 29, (c * 30) + 29), Graphics&, 0, (246, 246)-(285, 285) CASE 4 _PUTIMAGE (R * 30, c * 30)-((R * 30) + 29, (c * 30) + 29), Graphics&, 0, (287, 246)-(326, 285) END SELECT CASE 4 'W SELECT CASE Pacframe CASE 1 _PUTIMAGE (R * 30, c * 30)-((R * 30) + 29, (c * 30) + 29), Graphics&, 0, (39, 246)-(0, 285) CASE 2 _PUTIMAGE (R * 30, c * 30)-((R * 30) + 29, (c * 30) + 29), Graphics&, 0, (80, 246)-(41, 285) CASE 3 _PUTIMAGE (R * 30, c * 30)-((R * 30) + 29, (c * 30) + 29), Graphics&, 0, (121, 246)-(82, 285) CASE 4 _PUTIMAGE (R * 30, c * 30)-((R * 30) + 29, (c * 30) + 29), Graphics&, 0, (162, 246)-(123, 285) END SELECT END SELECT CASE 176 LINE (R * 30, c * 30)-((R * 30) + 29, (c * 30) + 29), _RGB32(0, 0, 255), BF END SELECT NEXT R NEXT c RETURN Filldim: FOR c = 0 TO 18 FOR R = 0 TO 24 READ z PacMap(c, R) = z 'PacMap(r, c) = Z IF z = 176 THEN LINE (R * 30, c * 30)-((R * 30) + 29, (c * 30) + 29), _RGB32(0, 0, 255), BF END IF NEXT R NEXT c RETURN Placepac: 'extract whats at this row and column (should be 32) z = PacMap(Pacrow, Paccol) 'add pacman symbol to it (32 +10 = 42) z = z + Pacsym 'place in back inside map PacMap(Pacrow, Paccol) = z RETURN '-------------------------- MAP -------------------------------------- DATA 176,176,176,176,176,176,176,176,176,176,176,176,32,176,176,176,176,176,176,176,176,176,176,176,176 DATA 176,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,176 DATA 176,32,176,176,176,176,176,176,176,176,176,32,176,32,176,176,176,176,176,176,176,176,176,32,176 DATA 176,32,176,32,32,32,32,32,32,32,32,32,176,32,176,32,32,32,32,32,32,32,176,32,176 DATA 176,32,176,32,176,176,176,176,32,176,176,32,176,32,176,32,176,176,176,176,176,32,176,32,176 DATA 176,32,176,32,176,32,32,32,32,32,176,32,176,32,176,32,32,32,32,32,32,32,176,32,176 DATA 176,32,176,32,176,32,176,176,32,176,176,32,176,32,176,32,176,32,176,32,176,32,32,32,176 DATA 176,32,32,32,176,32,32,32,32,32,32,32,32,32,32,32,176,32,176,32,176,32,176,32,176 DATA 176,32,176,32,176,32,176,176,176,32,176,176,32,176,176,32,32,32,176,32,32,32,176,32,176 DATA 32,32,176,32,32,32,32,32,32,32,176,32,32,32,176,32,176,176,176,176,176,32,176,32,32 DATA 176,32,176,32,176,32,176,176,176,32,176,176,176,176,176,32,32,32,176,32,32,32,176,32,176 DATA 176,32,32,32,176,32,32,32,32,32,32,32,32,32,32,32,176,32,176,32,176,32,176,32,176 DATA 176,32,176,32,176,32,176,176,32,176,176,32,176,32,176,32,176,32,176,32,176,32,32,32,176 DATA 176,32,176,32,176,32,32,32,32,32,176,32,176,32,176,32,32,32,32,32,32,32,176,32,176 DATA 176,32,176,32,176,176,176,176,32,176,176,32,176,32,176,32,176,176,176,176,176,32,176,32,176 DATA 176,32,176,32,32,32,32,32,32,32,32,32,176,32,176,32,32,32,32,32,32,32,176,32,176 DATA 176,32,176,176,176,176,176,176,176,176,176,32,176,32,176,176,176,176,176,176,176,176,176,32,176 DATA 176,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,176 DATA 176,176,176,176,176,176,176,176,176,176,176,176,32,176,176,176,176,176,176,176,176,176,176,176,176 Heres the updated GRAPHIC:http://dl.dropbox.com/u/10291175/GMPacMan1.rar (http://dl.dropbox.com/u/10291175/GMPacMan1.rar) Title: Re: PacMan2f This one moves with arrow keys Post by: guest on April 03, 2011, 04:12:35 pm Here's some thoughts on some Artificial Intelligence for our PacMan game. Quote Ghost AI Ok we got four ghost's . How do we make some artificial intelligence? Ok we identify them as numbers. 1 = blue 2 = red 3 = yellow 4 = pink Now elsewhere we defined direction as compass points. We will use the same idea for the ghosts. N E S W As far as a ghost is concerned as it travels it needs to probe these places Ahead To the right To the left So if ghost is heading north the right is east and left is west. A ghost continues traveling until it comes to an intersection. An intersection may be A dead end A one new direction A two new direction A three new direction If we have only one choice we have to go that way. If we reach a dead end then we have to reverse If we reach a 2 way intersection then we roll a dice to decide new direction from the 2 choices. If we reach a 3 way intersection then we roll a dice to decide new direction from the 3 choices. Now this is totally random. Its possible that being random the ghosts will never be able to "track , corall, work in coordination , hunt". To do any of these behaviours we could make the ghost when possible move toward the shortest direction of our hero some of the time. In our maze will be dots that get eaten. If we had 100 dots and divided them by 10 we reach a result of 10. Alternatively if we calculate the number of eaten dots and divide it by 10 we'd get at present 0. So these two figures are inversely related. We use one of these derived figures to generate a "chance" that the ghost uses our hero location to base their choice of direction. If we used the eaten dots then its possible to make the ghosts hunt more as dots get eaten. Lastly rather than generating each dice rolls that we need to use on the fly we could create an array that holds a "weighted" amount of possible directions. In theory we have 3 directions to choose from at any moment. By arranging the numbers of direction as 1,2,3,1,2,3,1,2,3 and pre shuffle them then we simply read throught the array until we arrive at a valid direction. As long as we note what subscript houses our valid number then we can start at the next subscript the next time we need a new direction. Obviously we need to code wrap around to arrive back at the start when we reach the end of the array. Also we can start each ghost at different starting subscripts. When our hero eats a power pill then the ghosts must flee. We could use the same arrangement of tracking to calculate the greates distance AWAY from our hero. Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on April 03, 2011, 06:13:37 pm Hi all, This is pretty neat, , ...Glad to finaly see it,...On the Artificial inteligence, It sounds more complicatedHere's an update showing PacMan responding to key movement and correct facing direction. Heres the updated GRAPHIC:http://dl.dropbox.com/u/10291175/GMPacMan1.rar (http://dl.dropbox.com/u/10291175/GMPacMan1.rar) Quote this is totally random. Its possible that being random the ghosts will never be In the orginal,it is very noticable, that it seems like sometimes the ghosts seem to know where you are,...but I need to read your thoughts on the artificial intelligence , mor closely, to be able to say much.....I sure am glad to see some progress on this, sorry I have not been much help,...I am still looking for some sounds, like one for when the dots get eaten, another for if the ghost gets him and he dies, "doom", also a warning sound that goes off when the ghosts are about to go bcak to being able to attack,...able to "track , corall, work in coordination , hunt". To do any of these behaviours we could make the ghost when possible move toward the shortest direction of our hero some of the time. guess thats about it for now, thanks for posting this from Garry Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on April 06, 2011, 09:40:57 pm It dose work, I had seen some about Dice in Ted Felix's tutorial, and he had said it was a important, concept to understand, but I had not realized how it could be used,...thats interesting.....looking good,
thanks from Garry Title: Re: PacMan2f This one moves with arrow keys Post by: GarrisonRicketson on September 09, 2011, 01:08:32 am Well any way, good try, but ...never got finished, Now I am going to start over,.. on this,...Dong it right, but simple like I started out,.... |