It is currently Sun Dec 10, 2017 7:23 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Sun May 22, 2016 2:40 am 
Offline
User avatar

Joined: Mon Jul 14, 2014 6:05 am
Posts: 89
Location: Lausanne, Switzerland
Right now, I'm thinking about making a racing game. So far, I managed to implement a routine that can easily calculate the next frame of the road's parallax, like so

Image to Image

The only problem is that it takes a long time in CPU time to calculate the next frame, as you can see on the pic below (This is for 2 road frames at once)

Image

This could potentially be a problem when the player encounters a sharp turn or gets sent to the other side of the road quickly, as it could be the source of slowdown (Not to mention road rendering takes a ton of CPU time too)

So I would like to know if there is a better way to calculate the road's parallax, making it possible to go from the pic on the left to the pic of the right directly.

Image to Image


Top
 Profile  
 
PostPosted: Sun May 22, 2016 4:59 am 
Offline
Site Admin
User avatar

Joined: Mon Sep 20, 2004 6:04 am
Posts: 3486
Location: Indianapolis
My first thought would be a look-up table, assuming you're not limited on ROM. If your scrolling covers 128 scanlines, then you'd have 128 entries in the table with the H value for each line. Then for the left-to-right position, duplicate the table for each step. In that case, 256 steps would make a 32kB table.


Top
 Profile  
 
PostPosted: Sun May 22, 2016 5:50 am 
Offline
User avatar

Joined: Mon Jul 14, 2014 6:05 am
Posts: 89
Location: Lausanne, Switzerland
I thought about this actually, but I don't want to waste too much ROM space even though I'll probably end up doing it on an MMC3 because IRQs


Top
 Profile  
 
PostPosted: Sun May 22, 2016 5:52 am 
Offline
User avatar

Joined: Thu Mar 31, 2016 11:15 am
Posts: 218
I was thinking use a lookup table but only for slope values. That way it would be only 256 128 bytes and not 32k.

Quote:
So I would like to know if there is a better way to calculate the road's parallax

It would really help if you were to describe your current attempt and how you want the parallax to actually behave.


Top
 Profile  
 
PostPosted: Sun May 22, 2016 7:40 am 
Offline
User avatar

Joined: Mon Jul 14, 2014 6:05 am
Posts: 89
Location: Lausanne, Switzerland
So I decided to transcribe the scroll values onto a massive file and do as Memblers suggested. It seems to work fine :D - I ended up saying "*%$@ it" and going MMC3!


Top
 Profile  
 
PostPosted: Sun May 22, 2016 9:06 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10164
Location: Rio de Janeiro - Brazil
pubby wrote:
I was thinking use a lookup table but only for slope values. That way it would be only 256 128 bytes and not 32k.

Slope values would work, since the road is straight, not curved like in many teaching games. These values would have to be fixed-point numbers, but they can probably still fit in 8 bits. But you'd also need the initial scroll value for the topmost scanline, doubling the amount of space necessary for this approach, but that's still waaaay less than full lookup tables with values for every scanline.


Top
 Profile  
 
PostPosted: Sun May 22, 2016 9:44 am 
Offline
User avatar

Joined: Mon Sep 15, 2014 4:35 pm
Posts: 3152
Location: Nacogdoches, Texas
I can't help but feel that the road should get even smaller toward the top. It looks like it's as wide as the buildings.


Top
 Profile  
 
PostPosted: Sun May 22, 2016 1:02 pm 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7312
Location: Chexbres, VD, Switzerland
What I did in the only demo I did who does that is use an exponential curve. The top scroll value is multiplied by a fixed-point constant and goes closer to zero each line. It works pretty well, although it's probably not the only way to do that.

Rad Racer does it all with lookup tables.


Top
 Profile  
 
PostPosted: Sun May 22, 2016 5:13 pm 
Offline
User avatar

Joined: Sun May 27, 2012 8:43 pm
Posts: 1311
Espozo wrote:
I can't help but feel that the road should get even smaller toward the top. It looks like it's as wide as the buildings.

Certainly. The only other justification is the player is going around a small sphere or up a hill, forever.


Top
 Profile  
 
PostPosted: Sun May 22, 2016 5:20 pm 
Offline
User avatar

Joined: Mon Sep 15, 2014 4:35 pm
Posts: 3152
Location: Nacogdoches, Texas
It's going around the entire planet, those buildings are actually moving backward. :lol:


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group