Pacman Game
BlitzPlus Forums/BlitzPlus Beginners Area/Pacman Game
| ||
I've been trying to program a Pacman game but can't figure out how to get the small yellow dot to delete once pacman eats it (collides). I know I obiously need the "Delete" Command but I need a NewType for that. I know what types are and what a newtype is but don't know how to incorperate it into the situation. Any help would be most appriciated. |
| ||
Well, you should make your dots into a type. For instance,type food field x,y end type for f=1 to 100 ;make 100 foods dot.food=new food next Then, when it collides, just use DELETE dot. |
| ||
hmm, thanks. I'll look into this. |
| ||
This didn't seem to work, B+ is asking that dot be a NewType. But I can probably fix this. |
| ||
No, it's still saying it's a non-Newtype... |
| ||
Why is you maze not just in an array? surely that's the simpler solution, and forget about using images collide, simply go by the snapped location of the pacman? ie Dim Maze(9) Maze(0) = "XXXXXXXXX" Maze(1) = "X.......X" Maze(2) = "X.X.XXXXX" etc etc Then if your pacman is say 32x32 then just take the x,y pos take away the offset of where the maze is onscreen and divide by 32. Anyway... That's how I'd do it.. |
| ||
Ok, well in your code, your next needs to be after all of the collision checking, not before. That way the program knows to handle ALL SMbit's, and then delete the one when there is a collision. |
| ||
Yeah, but now it says "Next without For." ???????? |
| ||
OK... Just knocked this together to demonstrate my point: You'll need: ![]() ![]() |
| ||
this method is also handy in gauntlet clones i myself would use 0-255 (well the hex equivelant) to define objects 00 in hex = floor FF wall that then gives you 254 other values for bits inbetween (optional) player start point (which is also a floor tile when not the start) exit monster a start points (also a floor tile when it moves) monster b " " " " monster c " " " " monster d " " " " monster a generator (and perhaps levels of degredation) monster b generator etc food potions heal packs afaik in the olden days levels were kinda layed out like this, simple random looking chunks of ascii that the game understood as destructable wall i doubt youd ever need to fill all 256 options, without counting i dont think gauntlet needed more than 32 edit: im defining monster and hero starting squares in the maze data but you could have level layer object layer monster layer but i find it easier not to worry about a monster being one grid out and finding itself on a wall ;) |
| ||
OK, neither of your posts really answered my questions... maybe I'm not reading carfully enough, but all I want to know is what's wrong with the code I provided and a straight out answer what I can do to delete the dot instead of all of this elaborate stuff you're giving me. |
| ||
When I put NEXT just before END FUNCTION I don't get any error... but another issue is that you want to address is that you want to use "DELETE SMbit" because you're deleting that specific item of the type, not the type itself. Hopefully that helps a bit. |
| ||
All right, it's not even drawing the bit now... |
| ||
OK, neither of your posts really answered my questions. I've not answered your question because the way you're going about doing a pac man game in my opinion is seriously flawed and massively ineffeciant. I have given you an example of how to create a pac man game which is far from elaborate.If you want to know about types and handling them then don't mention pac man, just ask a specific types question. |
| ||
try thisDelete SMbit.TypSmallBit I program in b3d but I would assume this would still work. |
| ||
Well then someone coulda said something about how flawed my method is... however I'm not angry at you Rob. Thanks for showing me this code, I just didn't bother to look at it since I was too fustrated at the time. Thanks for providing me with the engine. :) :) :) |