Jump to content

Playfield collision query


Recommended Posts

Hi everyone.
I'm starting to learn the basics with Batari Basic.

I used collision detection betweeen player shots and playfield, but I don't know how to implement this case:
- Turn off part of the playfield when a player shot was impacted.

Looking at commands, there is pfhline, so I think pfhline xpos ypos flip could work.
But while value ranges are 0-31 for xpos and 0-11 for ypos, I can't determine it refering player shot position (with has a range up to about 136 for x-basis in my sample).

So, is there a way to flip off part of playfield depending of player shot position?

I attach the .bas file, sorry for very dirty code (copy-pastes from here and there, wasting space with too many variables, using for-next for timing etc etc, I'm still experimenting). My objetive later will be make my own sample (with cleaner code) with the basic elements only (that's playfield, player and missiles, without clone sprites etc).





Link to comment
Share on other sites

You might want to post future batari Basic questions in the batari Basic forum:




If I understand your post correctly, you want to convert your missile coordinates to playfield coordinates. When using a sprite, something similar to the following is used:


You'd replace the sprite in that example with the missile and play with the numbers until you get it right (for example, -15 will probably need to be changed). For testing, it helps to draw pixels under the missile using pfpixel to see if you have things lined up properly.

Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

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.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...