Jump to content

Photo

Sprite X coordinates


3 replies to this topic

#1 flux OFFLINE  

flux

    Space Invader

  • 37 posts

Posted Mon Sep 24, 2018 1:57 PM

I was having an issue with getting the value for the x coordinate located between two sprites. I took the x value for one of them, plus the x value for the other plus its width and divided it by two. Somehow this still seemed to never be quite right and would always look a little off. I plotted a couple of points in a vertical line and set them to the same x value I was positioning one of the sprites at, and it seems to be off.

 

Then to make sure it wasn't something weird with my own code, I tweaked nyandodge a bit and tried the same thing. I added a PX variable to go along with the PY, and set it to some arbitrary value (in this case 40) at the top where I declared it. Then lower in the code, where it positioned the y value, I added this bit.

    rlist[1].y_=PY
    rlist[1].x_=PX
    COLOUR(1)
    PLOT(PX, 136)
    PLOT(PX, 135)
    PLOT(PX, 134)
    PLOT(PX, 133)
    PLOT(PX, 132)

You can see the results in a screenshot here. My understanding was the the x coordinate of a sprite refers to the left side of it. If that's the case, this line clearly isn't matching up with the left side of that nyan cat. It might be that I don't know enough about how the plot command works or how sprite positions work. If that's the case, could someone talk me through why those things shouldn't line up in that case because I'm scratching my head over here.



#2 Sporadic OFFLINE  

Sporadic

    Dragonstomper

  • 505 posts
  • Probably RB+ing
  • Location:UK

Posted Mon Sep 24, 2018 2:11 PM

Quick thought from me, plot will draw on to the particle layer object. That object is positioned on the screen like all others. Therefore if you plot at 10,10 then that will appear on the screen at particlelayer.x+10, particlelayer.y+10



#3 flux OFFLINE  

flux

    Space Invader

  • Topic Starter
  • 37 posts

Posted Mon Sep 24, 2018 2:17 PM

That actually looks like it's it. I guess I haven't really looked into the particle layer too much so it's still a bit of a mystery to me. I didn't realize everything on it was relative to the layer's position. I thought they were straight up screen coordinates. That helps a lot, thanks!



#4 sh3-rg OFFLINE  

sh3-rg

    River Patroller

  • 3,395 posts
  • doge + tie = dothemath
  • Location:BOLTON, England

Posted Tue Oct 2, 2018 6:02 AM

That actually looks like it's it. I guess I haven't really looked into the particle layer too much so it's still a bit of a mystery to me. I didn't realize everything on it was relative to the layer's position. I thought they were straight up screen coordinates. That helps a lot, thanks!

 

Once you realise this, and that the particle layer can be shifted around, and that you can have multiple copies of it with multiple CLUT allocations set to them, and you can resize it by editing the .S file and you can scale it just like any other object, ... and... and... well that thing becomes super useful ;-) But as a single backdrop that's on a weird offset and confuses you the first time you start plotting things to it and the co-ords are wacky... yeah, that's not so much fun ;-)





Reply to this topic



  


0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users