Jump to content
pacgreg

Finding if playfield between sprites?

Recommended Posts

I'm trying to figure out a way to detect if there is a playfield part between two sprites, and use that to switch a bit on or off to be used elsewhere, something like the enemies in marauder switching invisible/visible when on the opposite side of a playfield part. Does anyone know how I would accomplish this?

Share this post


Link to post
Share on other sites

So you are wanting to do something similar to what is in the post below?

 

atariage.com/forums/topic/152123-bloober-and-the-gnarl/?p=1864981

 

One way is to convert the positions of the two sprites to playfield coordinates, then use pfread to look between them.

Share this post


Link to post
Share on other sites

I was thinking about something like this, I guess I'll have to break out some algebra to find out points between them. Thank you!

Share this post


Link to post
Share on other sites

My game doesn't move on a grid, where do I look for playfield so that it isn't too or too little sensitive. I tried fourths and it wasnt sensitive enough, and fifths or more slow down my game. How did you get it working?

Share this post


Link to post
Share on other sites

My game doesn't move on a grid, where do I look for playfield so that it isn't too or too little sensitive. I tried fourths and it wasnt sensitive enough, and fifths or more slow down my game. How did you get it working?

 

In a game like Marauder, your position determines what is seen. I don't know how to do that yet. The only thing I have done is have an enemy check the playfield in the direction that he is looking/moving. If he sees a playfield pixel, he continues his normal activities. If he sees the player, the enemy speeds up.

Share this post


Link to post
Share on other sites

The first thing that comes to mind is to do it in such a way that is similar to software collisions. Simply check if there is a playfield pixel at a y coordinate that is +- the sprites' y positions. Of course, this is easier said and done, and will likely include many if statements, especially if it needs to be true for both players. You'll probably need to use pfread, which can take variables and arrays as arguements. So, you'll probably need to set a counter that goes from 0 to 31 to check each position to see if there's a pixel, then plug that into an array which gives you the actual x positions of those pixels, the y position in the pf read argument can be the playery's y position rounded to the pixel rows as you see fit. Then, you check the second player, and see if they match up.
In practice however, it would seem that this code would take up way too many cycles to ever actually be useful. If you know the places where the pfpixels are, you can cut down on the redundant checking and go straight to the comparison.

In the case of a game like maurader though, this whole thing is way more complex and out of my jurisdiction. Pretty much what you're asking for is line of sight. and in that case, you'll need to check if there is a pixel within the player's line of site, and if not, show the sprites in the direction of the player's line of site. You will definitely need to do some calculations for something like that.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...