Jump to content
IGNORED

how do I?


Recommended Posts

This is how I would do it:

 

ballx=(rand&127)+16

bally=(rand&63)+8

 

This gives a decent range while being roughly centered. You can adjust it a little to suit your needs (change the 8 or 16, not the 127 or 63.)

 

If the range isn't quite right, there is a function available that can do this. It's slower and takes up more space, however.

Link to comment
Share on other sites

This is how I would do it:

 

ballx=(rand&127)+16

bally=(rand&63)+8

 

This gives a decent range while being roughly centered. You can adjust it a little to suit your needs (change the 8 or 16, not the 127 or 63.)

 

If the range isn't quite right, there is a function available that can do this. It's slower and takes up more space, however.

 

I'll give that a try. thanks a lot

Link to comment
Share on other sites

This is how I would do it:

 

ballx=(rand&127)+16

bally=(rand&63)+8

 

This gives a decent range while being roughly centered. You can adjust it a little to suit your needs (change the 8 or 16, not the 127 or 63.)

 

If the range isn't quite right, there is a function available that can do this. It's slower and takes up more space, however.

 

that worked like I wanted. thanks. One more question. I am probably asking a lot but how can I make sure it does not appear on top of something else in the playfield? any help appreciated.

Link to comment
Share on other sites

that worked like I wanted. thanks. One more question. I am probably asking a lot but how can I make sure it does not appear on top of something else in the playfield? any help appreciated.

I wonder if pfread might be helpful:

 

http://www.randomterrain.com/atari-2600-me...nds.html#pfread

Link to comment
Share on other sites

This is how I would do it:

 

ballx=(rand&127)+16

bally=(rand&63)+8

 

This gives a decent range while being roughly centered. You can adjust it a little to suit your needs (change the 8 or 16, not the 127 or 63.)

 

If the range isn't quite right, there is a function available that can do this. It's slower and takes up more space, however.

 

that worked like I wanted. thanks. One more question. I am probably asking a lot but how can I make sure it does not appear on top of something else in the playfield? any help appreciated.

Probably the easiest way would be to check for a playfield/ball collision during the next frame, and if so, get a different random number. This method isn't preemptive, so you may see the ball appear in a few different places for a few frames before it finds a valid place. In practice it will probably work just fine, however.

 

A preemptive method using pfread might work as well, but it will require some additional calculations.

Link to comment
Share on other sites

This is how I would do it:

 

ballx=(rand&127)+16

bally=(rand&63)+8

 

This gives a decent range while being roughly centered. You can adjust it a little to suit your needs (change the 8 or 16, not the 127 or 63.)

 

If the range isn't quite right, there is a function available that can do this. It's slower and takes up more space, however.

 

that worked like I wanted. thanks. One more question. I am probably asking a lot but how can I make sure it does not appear on top of something else in the playfield? any help appreciated.

Probably the easiest way would be to check for a playfield/ball collision during the next frame, and if so, get a different random number. This method isn't preemptive, so you may see the ball appear in a few different places for a few frames before it finds a valid place. In practice it will probably work just fine, however.

 

funny you came back and said that. I do not really understand the pfread. I feel really stupid trying to do this stuff hopefully I will get better. I did use the collision detection and so far it seems to be working well for me. I'm kinda proud tho cause I figured it out before you posted it. thanks for you guys help. I appreciate it.

 

A preemptive method using pfread might work as well, but it will require some additional calculations.

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.

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...