Jump to content
IGNORED

any way to convert between...


InsaneSonikkuFan

Recommended Posts

the x and y co-ordinates of something like missles and the co-ordinates of the playfield?

i figured something like dividing by 8 would work, but it's only working for half of the block, as in if the missle hits the bottom half it will work, but if the missle hits the top half, it will consider it the block above... i would use collision(), but then i'd still need to know what block is being hit accurately. i am using playfield scrolling, would that cause this not to work how i want it to? is there some way i can remedy this?

thanks.

Edited by InsaneSonikkuFan
Link to comment
Share on other sites

the x and y co-ordinates of something like missles and the co-ordinates of the playfield?

i figured something like dividing by 8 would work, but it's only working for half of the block, as in if the missle hits the bottom half it will work, but if the missle hits the top half, it will consider it the block above... i would use collision(), but then i'd still need to know what block is being hit accurately. i am using playfield scrolling, would that cause this not to work how i want it to? is there some way i can remedy this?

thanks.

Yes - dividing by 8 is correct, but you may also need to add a fixed amount first. And since you are scrolling, you also need to also subtract (I think) the system variable playfieldpos before dividing. playfieldpos contains 1-8, and it actually represents the height of the top row.

 

Sorry, I don't know the correct formula offhand, though if you post your source, someone (maybe me if I have time) might be willing to help you work it out.

Link to comment
Share on other sites

The conversion is a little more complex than that, because the player or missile's height will affect its vertical positioning, and it's impossible to get a perfect vertical alignment in some cases.

 

Ignoring the playfield for a moment, a player's vertical position value (e.g., player0y) determines the location of its bottommost row of pixels. And you have to keep in mind that each row of player pixels is actually two scan lines, or one "double line." If player0 is only 1 (double) line tall, then the topmost vertical position will be player0y = 2; anything below 2 (i.e., 1 or 0) will move player0 off the top of the screen. If player0 is only 2 (double) lines tall, then player0y = 2 will position the bottommost row of pixels at the top of the screen, and the topmost row of pixels will be off screen, so player0y = 3 will put the topmost row of pixels on the first visible line. So the general formula for determining the player0y value is 1 + h, where h is the height of player0 in (double) lines. For example, if player0 is 8 (double) lines tall, the highest position that keeps all of player0 on screen will be player0y = 9. In all cases, the lowest position that keeps all of player0 on screen will be player0y = 89; anything over 89 will start to move player0 behind the score lines.

 

On the other hand, in the standard bB kernel, the playfield pixels are 15 lines tall, with 1 blank line between them, so you could say that they're 16 lines tall, or 8 double lines tall, except that 1 of the lines (or half of a double line) is blank. Thus, if player0 is 8 (double) lines tall, then you can position player0 so that it covers up an entire playfield pixel from top to bottom, except that the topmost row of the player0 pixels will extend slightly above the playfield pixel (or over the blank line).

 

Furthermore, assuming that the playfield isn't being scrolled, the topmost portion of the playfield is just a tiny bit off of the screen in Stella-- that is, the first (double) line of the playfield pixel is the blank scan line, followed by a non-blank line, but you can't see that first double line in Stella (but you can see it in z26). So if player0 is 1 (double) line tall, and you use player0y = 2 to position player0 as high as it can go without moving off screen, then the topmost edge of player0 won't reach the topmost edge of the playfield pixel. In Stella it will look like they're lined up, but in z26 you can see that there's actually a single scan line of the playfield pixel that extends above player0. On the other hand, if player0 is 8 (double) lines tall, and you use player0y = 8, then the bottommost edge of player0 will line up exactly with the bottommost edge of the first playfield pixel row, but you won't be able to see the topmost pixels of player0.

 

The following program draws a full playfield in yellow, and draws player0 as a red checkerboard pattern. The player0y value is shown in the score. You can use the joystick (or cursor keys) to move player0 up and down, and see the different player0y values as it moves up and down. You can increase or decrease player0's height by moving the stick left (decrease) or right (increase). This lets you see how player0y determines the position of player0's bottommost edge, rather than the position of player0's topmost edge. In this program, player0 cannot be decreased to less than 1 (double) line tall, or to more than 8 (double) lines tall. You can also see that the blank lines between each row of playfield pixels are just a single line, or half of a player pixel.

 

The missiles and ball are a little quirky, as I'll demonstrate with another program in another post.

 

Michael Rideout

 

player0y.bas

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