Uzebox Mode 3 with Scrolling Guide

Topics on software tools like TileStudio, comments on documentation and tutorials (or the lack of) should go here.
User avatar
Artcfox
Posts: 1382
Joined: Thu Jun 04, 2015 5:35 pm
Contact:

Re: Uzebox Mode 3 with Scrolling Guide

Post by Artcfox »

Gotcha.
User avatar
ry755
Posts: 225
Joined: Mon May 22, 2017 6:01 am

Re: Uzebox Mode 3 with Scrolling Guide

Post by ry755 »

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:

Code: Select all

touchingTile = GetTile((playerx/8)+1, (playery/8)+2);
if (touchingTile == 24) {
	player[0].jump = true;
	TriggerFx(1, 0xff, true);
} else {
...
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?
User avatar
nicksen782
Posts: 714
Joined: Wed Feb 01, 2012 8:23 pm
Location: Detroit, United States
Contact:

Re: Uzebox Mode 3 with Scrolling Guide

Post by nicksen782 »

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!
User avatar
ry755
Posts: 225
Joined: Mon May 22, 2017 6:01 am

Re: Uzebox Mode 3 with Scrolling Guide

Post by ry755 »

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!
Thanks for the suggestion! I'm only using vertical scrolling so I only need Screen.scrollY.
I've tired both

Code: Select all

touchingTile = GetTile((player[0].x/8)+1, (player[0].y/8)+2+Screen.scrollY);
and

Code: Select all

if (touchingTile == 24+Screen.scrollY) {
	...
}
but it still doesn't detect the correct tiles when the screen is scrolled. If I do Print(Screen.scrollY, 1, 1); I get a garbled mess of text:
Image

What am I doing wrong?
User avatar
D3thAdd3r
Posts: 3175
Joined: Wed Apr 29, 2009 10:00 am
Location: Minneapolis, United States

Re: Uzebox Mode 3 with Scrolling Guide

Post by D3thAdd3r »

ry755 wrote: Tue Jun 19, 2018 10:08 pm touchingTile == 24+Screen.scrollY
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 :?
ry755 wrote: Tue Jun 19, 2018 10:08 pm If I do Print(Screen.scrollY, 1, 1); I get a garbled mess of text
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);
User avatar
ry755
Posts: 225
Joined: Mon May 22, 2017 6:01 am

Re: Uzebox Mode 3 with Scrolling Guide

Post by ry755 »

D3thAdd3r wrote: Wed Jun 20, 2018 3:29 am
ry755 wrote: Tue Jun 19, 2018 10:08 pm touchingTile == 24+Screen.scrollY
I don't understand the intent behind that line and it is hard to guess without seeing more code. (...)
ry755 wrote: Tue Jun 19, 2018 10:08 pm If I do Print(Screen.scrollY, 1, 1); I get a garbled mess of text
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.
Oops, both of those are mess-ups, probably because I wrote that code late at night. :oops: 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) {
	...
}
By dividing Screen.scrollY by 8 I get the number of tiles down the screen has scrolled. Then I add that to GetTile so if it's scrolled down by 1 tile it checks (x,y + 1), if it's scrolled down 2 tiles it checks (x,y + 2), etc.
User avatar
D3thAdd3r
Posts: 3175
Joined: Wed Apr 29, 2009 10:00 am
Location: Minneapolis, United States

Re: Uzebox Mode 3 with Scrolling Guide

Post by D3thAdd3r »

Nice job getting it working, looking forward to seeing more of that game in action :)
Post Reply