Jump to content
IGNORED

Finding Playfield Coordinates for Multisprite SuperChip


KevKelley

Recommended Posts

I was messing around with the Multisprite Kernel and SuperChip and set the pfres at 32 and pfheight at 1.

 

Now my brain doesn't want to work and I am having a hard time trying to convert the player coordinates into playfield coordinates so that I may use pfread.

 

Does anyone have a quick look up to convert these?

 

PLATFORM_2023_11_25_23_MSK.bas

Link to comment
Share on other sites

KevKelly,

 

Hope you or someone can get this working. I tried and made some success, but didn't work out correctly. So I went with fixed coordinates and it's a pain. Attached is what I started to use, but it ate up a lot memory. Then I switch over to data and less lines etc. Hope this helps.

20180605_Multisprite_Pac_Man_Pfread_Example.bas

  • Like 1
Link to comment
Share on other sites

4 hours ago, Lewis2907 said:

KevKelly,

 

Hope you or someone can get this working. I tried and made some success, but didn't work out correctly. So I went with fixed coordinates and it's a pain. Attached is what I started to use, but it ate up a lot memory. Then I switch over to data and less lines etc. Hope this helps.

20180605_Multisprite_Pac_Man_Pfread_Example.bas 18.97 kB · 1 download

I’ll have to check it out later. I have it work for my regular SuperChip platformer code so at first I thought it would be a quick change for this. Invert the y coordinates, etc. but what got me was the higher res for the playfield. Also pfread for the x coordinates. I had read somewhere that with the playfield being mirrored I may have to check on the left half of the screen. 
 

what I thought would be simple took too much time during my lunch break for me to figure out. Nothing like a good puzzle. 

Link to comment
Share on other sites

On 11/25/2023 at 12:59 PM, KevKelley said:

I was messing around with the Multisprite Kernel and SuperChip and set the pfres at 32 and pfheight at 1.

 

Now my brain doesn't want to work and I am having a hard time trying to convert the player coordinates into playfield coordinates so that I may use pfread.

 

Does anyone have a quick look up to convert these?

 

PLATFORM_2023_11_25_23_MSK.bas 3.45 kB · 5 downloads

Okay; I haven't messed with your code, but let me make sure I understand. If you are using the Multisprite Kernel and pfheight=1, then you have 44 rows to work with. SuperChip is irrelevant since the Multisprite kernel stores the playfield in ROM, so it's not needed to get extra playfield rows, and as far as I know, the Multisprite kernel doesn't use pfres at all.

 

So anyway, with a 44 rows, the Y conversion should be pretty easy, with 88 pixels for the player and 44 rows, in theory you should just be able to divide the player Y coordinate by 2, and maybe subtract from 43 to invert the result for the backwards coordinates of the Multisprite kernel.

 

For the player X coordinate, you should be able to use the same formula as for the standard kernel, except for the fact that it is mirrored like you say. So, for player X < 80, use the same formula. For player X >= 80, subtract the player X coordinate from 159, and then apply the same formula.

 

These numbers might need to be tweaked by one if the player coordinates and playfield coordinates don't line up perfectly, but this should hopefully give a starting point. 

  • Like 1
Link to comment
Share on other sites

36 minutes ago, Karl G said:

So anyway, with a 44 rows, the Y conversion should be pretty easy, with 88 pixels for the player and 44 rows, in theory you should just be able to divide the player Y coordinate by 2, and maybe subtract from 43 to invert the result for the backwards coordinates of the Multisprite kernel.


For some reason I was looking at everything as being 30-something rows, which threw me off… but I was also playing around and had tried dividing by 2 and it was closer to working. 

 

36 minutes ago, Karl G said:

For the player X coordinate, you should be able to use the same formula as for the standard kernel, except for the fact that it is mirrored like you say. So, for player X < 80, use the same formula. For player X >= 80, subtract the player X coordinate from 159, and then apply the same formula.


Thanks for pretty much confirming my thoughts. 
 

I guess I over complicated in my head and to make matters worse, I took my regular code and just changed all the parts from addition to subtraction and vice versa but I probably needed to make more adjustments for things like different playfield thickness

 

My goal was to kind of create a generic code for platforming that I could use. I started with just SuperChip but wanted to make one for MultiSprite and that is when I got mixed up.  I had basically used pfread to see if the player is falling or not (hence converting the coordinates) and I use collision statements to see if you hit a floor or clip it so that you either fall back down or don’t get stuck.
 

 

Link to comment
Share on other sites

So I got it kind of working.  When I adjusted temp value for the y-coordinate it seems to do a good job but I must be missing something in getting the player to fall.

 

This is what I was working with for the MultiSprite SuperChip kernel.

 

 if !collision(player0,playfield) then goto SKIP_COLLISION_CHECK
 if  e{0} then f=28 
 
  p0y=p0y+0.25 ; if in playfield then pushes player out 
 if  f<19 && f>0 then p0y=p0y-0.50:f=20 ; hits head when jumping 
SKIP_COLLISION_CHECK 

  if joy0fire  && !e{0} && e{1} && f<1 then  e{0}=1:f=1 ; jump 
SKIP_UP
  if !joy0fire && f=0  then  e{0}=0
SKIP_UP2

JUMP
 if f<>0  then f=f+1
 if f>0 && f<19 then p0y=p0y+1.0:AUDV0=3:AUDC0=6:AUDF0=player0y ; jump up
 if f>25 && f<30 then p0y=p0y-1.0:AUDV0=3:AUDC0=6:AUDF0=player0y ; jump down  
 if f>=30 then f=0:AUDV0=0

 if !e{0} && !e{1} && f=0 then p0y=p0y-1.25:AUDV0=0 ; fall if no ground 
 
 if player0x<80 then temp1 = (player0x-14)/4
 if player0x>=80 then temp1 = (159-player0x-14)/4
 temp2 = ((43-player0y-9)/2)

 if pfread(temp1,temp2) then e{1}=1:AUDV0=0 :goto NO_FALL
 e{1}=0
 e{0}=0
 
NO_FALL

 

This is what I had working for non-MultiSprite and the basis for the above code:

 

SKIP_LR_CHECK 
 if !collision(player0,playfield) then goto SKIP_COLLISION_CHECK
 if  e{0} then f=28
 ;if joy0fire && f>0 then p0y=p0y:goto SKIP_COLLISION_CHECK ; allows for jumping through floor 


   p0y=p0y-0.50 
 if  f<19 && f>0 then p0y=p0y+0.50:f=20
SKIP_COLLISION_CHECK 

  if joy0fire  && !e{0} && e{1} && f<1 then  e{0}=1:f=1:k=41
SKIP_UP
  if !joy0fire && f=0  then  e{0}=0
SKIP_UP2

 if f<>0  then f=f+1
 

 if f>0 && f<19 then p0y=p0y-1.0:AUDV0=3:AUDC0=6:AUDF0=player0y:gosub JUMP
 if f>25 && f<30 then p0y=p0y+1.0:AUDV0=3:AUDC0=6:AUDF0=player0y:gosub JUMP 
 if f>=30 then f=0:AUDV0=0:k=0:gosub RUN1
 
 if !e{0} && !e{1} && f=0 then p0y=p0y+1.25:AUDV0=0


 temp1 = (player0x-14)/4: temp2 = ((player0y)/4) 
 

 if pfread(temp1,temp2) then e{1}=1:AUDV0=0 :goto NO_FALL
 e{1}=0
 e{0}=0
 
NO_FALL

 

I assume I am overlooking something stupid.

 

Apologize in advance for my sloppy code.  I intended on cleaning it up after I got it working...

 

PLATFORM_2023_11_25_23_SC.bas PLATFORM_2023_11_28_23_MSK.bas

Link to comment
Share on other sites

I was working on a pfread-less method as well. Once I get all working I’ll post them together. I think my biggest challenge for this version is getting pfread to work as I did in the standard kernel version, as that is the core of detecting whether the player drops or not. 
 

 

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