Pacman Game

BlitzPlus Forums/BlitzPlus Beginners Area/Pacman Game

SuperSonic7(Posted 2008) [#1]
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.


Sauer(Posted 2008) [#2]
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.


SuperSonic7(Posted 2008) [#3]
hmm, thanks. I'll look into this.


SuperSonic7(Posted 2008) [#4]
This didn't seem to work, B+ is asking that dot be a NewType.
But I can probably fix this.


SuperSonic7(Posted 2008) [#5]
No, it's still saying it's a non-Newtype...




Rob Farley(Posted 2008) [#6]
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..


Sauer(Posted 2008) [#7]
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.


SuperSonic7(Posted 2008) [#8]
Yeah, but now it says "Next without For." ????????


Rob Farley(Posted 2008) [#9]
OK... Just knocked this together to demonstrate my point:

You'll need:





Ginger Tea(Posted 2008) [#10]
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 ;)


SuperSonic7(Posted 2008) [#11]
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.


Sauer(Posted 2008) [#12]
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.


SuperSonic7(Posted 2008) [#13]
All right, it's not even drawing the bit now...


Rob Farley(Posted 2008) [#14]
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.


Nate the Great(Posted 2008) [#15]
try this

Delete SMbit.TypSmallBit


I program in b3d but I would assume this would still work.


SuperSonic7(Posted 2008) [#16]
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. :) :) :)