IGNORED

How do I accomplish checking whether certain parts of a playfield are gone (aka Pac-Man eating all the dots) to then load level 2?

Recommended Posts

I've got some blocks on the playfield. Let's assume level 1 has 16 blocks. I can fly my ship over them and they disappear.. aka Pac-Man eating dots.

I can't figure out how to make the game know you got all the blocks and it should load level 2.

I can set variable=16 and do variable=variable-1 until it reaches 0, but I've no way to actually tell whether you ran over a block or just dead space. Right now I'm checking x and y coordinates of the ship and doing a pfhline to get rid of the block. If the block was already gone, it's just wasted cycles because my game doesn't know whether it was gone or not to begin with.

What do I do?

(if you're curious why I used pfhline is because I was using two pfpixel commands.. pfhline takes up a little more cycles (294 vs 160), but it lessens the length of my code, so I could fit this whole crap in bank 2)

Edited by Words Fail
Share on other sites

I had done something similar in my project Lawn Boy. Once certain amount of blocks are cleared the level is over.

If I remember correctly I used a pfread to check if there was a block or not and if there was I would use a pfpixel to turn it off. I then had a variable to would add up until the number of cleared pixels equal the number of set playfield pixels I started with.

You can check out my .bas file here.

Share on other sites

So probably something like:

`if pfread(x,y) then pfpixel x y off: v=v-1`

Edited by KevKelley
Share on other sites

Thanks. I didn't see pfread because I was only searching the website for stuff I knew. I think this will perfect and might even save me some cycles.

Share on other sites

6 hours ago, KevKelley said:

So probably something like:

`if pfread(x,y) then pfpixel x y off: v=v-1`

Can I map player0x and player0y to a variable?

I need to pfread player0x and player0y and pfpixel player0x player0y off.

So far I can't get my code to work.

Share on other sites

I think I use the temp variables to define what the coordinate is since the playfield pixels don’t match up to the player coordinates.

so temp1 would equal the X conversion and temp2 the Y - something like temp1=(player0x/8)-3 … or whatever.

pfpixel temp1 temp2

It all depends on your playfield settings for how the coordinates will work so the conversion for the game I posted would be different then in my other games, like Cone Ball, which has just a standard bB kernel, or Crossdock, which has a standard kernel with variable playfield heights.

I can’t say what the right equation would be for your game because I don’t know your code and because I usually just do a look up on Random Terrain’s website or my other games and cut and paste.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.