Joel D. Park Posted June 7, 2009 Share Posted June 7, 2009 Guys, I'm trying to do the basic math that will figure out where how a certain pixel on the screen would line up with a block on the playfield. For example, the playfield is like 32 blocks wide and the screen is 150 pixels (or something like that) wide. So a playfield block is every 4.68 pixels. I'm not exacly going to be able to do remainders/decimal math I don't think. Have any of you guys allready come up with this calculation. I'm close with something like this: temp1 = ballx/5 : temp2 = (bally - 39 ) / 8 + 5: pfpixel temp1 temp2 off But for division reasons there are certain playfield blocks I can't hit. Thanks, Joel Quote Link to comment Share on other sites More sharing options...
SeaGtGruff Posted June 7, 2009 Share Posted June 7, 2009 I'm trying to do the basic math that will figure out where how a certain pixel on the screen would line up with a block on the playfield. For example, the playfield is like 32 blocks wide and the screen is 150 pixels (or something like that) wide. So a playfield block is every 4.68 pixels. I'm not exacly going to be able to do remainders/decimal math I don't think. Have any of you guys allready come up with this calculation. I'm close with something like this: temp1 = ballx/5 : temp2 = (bally - 39 ) / 8 + 5: pfpixel temp1 temp2 off But for division reasons there are certain playfield blocks I can't hit. There are *160* pixel positions on a line, and *40* playfield blocks, so there's a playfield block every *4* pixel positions. So that means your first calculation is off a little (but this still isn't right, because there's more): temp1 = ballx / 4 : rem not / 5 batari Basic normally uses only 32 of the 40 playfield blocks-- the leftmost 4 blocks and the rightmost 4 blocks are typically all blank-- so that means the usable portion of the playfield is 128 (32 * 4) pixel positions wide, with 16 (4 * 4) unused pixel positions on the left side of the screen, and another 16 (4 * 4) unused pixel positions on the right side of the screen. So that means if we number the first *usable* playfield block as 0 (as batari Basic does), then we need to subtract 16 from the pixel position before we divide by 4 (but this still isn't quite right, because there's more): temp1 = (ballx - 16) / 4 Normally we number the pixel positions from 0 to 159. But because of the way batari Basic v1.0 calculates the ball's horizontal (x) position, the ball's pixel positions end up being numbered from 2 to 161. So that means we really need to subtract 18 (16 + 2) instead of 16: temp1 = (ballx - 18) / 4 Try that and see if it works better for you. Michael Quote Link to comment Share on other sites More sharing options...
Joel D. Park Posted June 8, 2009 Author Share Posted June 8, 2009 This worked perfectly!! Thank you! Joel Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.