Uzebox Mode 3 with Scrolling Guide
Re: Uzebox Mode 3 with Scrolling Guide
I used your guide to add scrolling to my UzeJump game, and it works great! However, I can't figure out how to properly use the Level_getTileAt function. Before, I was able to use some simple code to detect if the player is touching a platform:
But that doesn't work when the screen is scrolled, it still detects the tiles that were originally there even after they have been scrolled away. How do I use Level_getTileAt to return what tile the player is on?
Code: Select all
touchingTile = GetTile((playerx/8)+1, (playery/8)+2);
if (touchingTile == 24) {
player[0].jump = true;
TriggerFx(1, 0xff, true);
} else {
...
- nicksen782
- Posts: 714
- Joined: Wed Feb 01, 2012 8:23 pm
- Location: Detroit, United States
- Contact:
Re: Uzebox Mode 3 with Scrolling Guide
You likely need to also consider the Screen.scrollX and Screen.scrollY values in your collision detection code.
The Super Mario Demo does not have collision detection but it does work with the scroll value. It may help to look at it.
https://github.com/Uzebox/uzebox/blob/m ... arioDemo.c
I just compiled your latest on Github. Glad to see the update!
The Super Mario Demo does not have collision detection but it does work with the scroll value. It may help to look at it.
https://github.com/Uzebox/uzebox/blob/m ... arioDemo.c
I just compiled your latest on Github. Glad to see the update!
Re: Uzebox Mode 3 with Scrolling Guide
Thanks for the suggestion! I'm only using vertical scrolling so I only need Screen.scrollY.nicksen782 wrote: ↑Tue Jun 19, 2018 2:17 pm You likely need to also consider the Screen.scrollX and Screen.scrollY values in your collision detection code.
The Super Mario Demo does not have collision detection but it does work with the scroll value. It may help to look at it.
https://github.com/Uzebox/uzebox/blob/m ... arioDemo.c
I just compiled your latest on Github. Glad to see the update!
I've tired both
Code: Select all
touchingTile = GetTile((player[0].x/8)+1, (player[0].y/8)+2+Screen.scrollY);
Code: Select all
if (touchingTile == 24+Screen.scrollY) {
...
}
What am I doing wrong?
Re: Uzebox Mode 3 with Scrolling Guide
I don't understand the intent behind that line and it is hard to guess without seeing more code. Keep in mind that changing scrollY does not change any data in vram, only loading new rows in at the top and bottom can do that. So you basically need to figure out how your sprite coordinates relate to the scroll values to pull the correct tile.
With scroll value of 0, and assuming you are using a screen that is 28 tiles tall, and assuming your character is at the top left hitting the tile at 0,0...if you scroll down by 8 pixels(1 tile height), keeping your character at the top left, you would now need to check against (0,1) to get the right tile. If you scrolled down 16(2 tile height), you would need to check against (0,2). I would try getting that part to work first, since you also have to handle roll over. Also I haven't thought about it in a while, so my thinking feels a bit fuzzy on the subject
That is to be expected, since you are passing Screen.scrollY as the x position to draw at, and passing the integer 1 as a pointer for the text. If you are printing a byte and not a string, try:
Code: Select all
PrintByte(3, 1, Screen.scrollY, 1);
Re: Uzebox Mode 3 with Scrolling Guide
Oops, both of those are mess-ups, probably because I wrote that code late at night. Once I got some rest I realized what I was doing wrong.
Here's how i got it working:
Code: Select all
touchingTile = GetTile((player[0].x/8)+1, (player[0].y/8)+2+(Screen.scrollY/8));
if (touchingTile == 24) {
...
}
Re: Uzebox Mode 3 with Scrolling Guide
Nice job getting it working, looking forward to seeing more of that game in action