It is currently Sat Nov 18, 2017 8:59 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 28 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Wed Apr 26, 2017 1:08 pm 
Offline

Joined: Mon Jan 30, 2017 5:20 pm
Posts: 300
Location: Colorado USA
I want to make a demake of Wolfenstien 3d on the NES using CHR RAM. But I don't quite understand how the Ray Casting system works. How does it know what pattern of pixels to make? You probably have no idea what I'm talking about. What I'm trying to say is when you are looking at a cube from an angle, you have to have their be a slant in the edges to make it look 3-dimensional. How does it know what pattern to make? It doesn't have a physical camera, so I'm confused. I've never done anything related to rendering 3D.


Top
 Profile  
 
PostPosted: Wed Apr 26, 2017 1:40 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19225
Location: NE Indiana, USA (NTSC)
I strongly urge you to make 3D on a PC before you attempt to make it on the NES.


Top
 Profile  
 
PostPosted: Wed Apr 26, 2017 2:44 pm 
Offline

Joined: Mon Jan 30, 2017 5:20 pm
Posts: 300
Location: Colorado USA
Okay, could you give an example of how I would do it on a PC?


Top
 Profile  
 
PostPosted: Wed Apr 26, 2017 2:48 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10112
Location: Rio de Janeiro - Brazil
I can give you a quick rundown on how raycasting works, but implementing it on the NES (at playable speeds) will require a lot of cleverness and optimization of the basic technique. How good are you with trigonometry? Raycasting basically involves a lot of triangles whose sides and hypotenuses you have to find.


Top
 Profile  
 
PostPosted: Wed Apr 26, 2017 3:07 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1823
Location: DIGDUG
Article on setting goals...

https://www.psychologytoday.com/blog/co ... al-setting

Quote:
Goals should not be so be so difficult that the [person] will fail to take them seriously or will experience failure and frustration.


People are happiest when they set small, achievable (yet challenging) goals.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Wed Apr 26, 2017 3:10 pm 
Offline

Joined: Mon Jan 30, 2017 5:20 pm
Posts: 300
Location: Colorado USA
tokumaru wrote:
I can give you a quick rundown on how raycasting works, but implementing it on the NES (at playable speeds) will require a lot of cleverness and optimization of the basic technique. How good are you with trigonometry? Raycasting basically involves a lot of triangles whose sides and hypotenuses you have to find.

I don't know anything about Trigonometry, I'm only in middle school. I'll try learning it on my own, though.


Top
 Profile  
 
PostPosted: Wed Apr 26, 2017 3:47 pm 
Offline
User avatar

Joined: Sat Jul 04, 2015 9:58 am
Posts: 563
Location: -29.794229 -55.795374
Bisqwit has made some nice videos about programming.
This one is about creating a Doom-style 3D engine in C.
I hope it helps.


Top
 Profile  
 
PostPosted: Wed Apr 26, 2017 3:49 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10112
Location: Rio de Janeiro - Brazil
DementedPurple wrote:
I don't know anything about Trigonometry

Then I simply can't explain how raycasting works in detail, since I'd have to teach you trigonometry as well. You need to at least understand what sines, cosines and tangents are, how they relate to the unit circle and their basic formulas.

I can still give you a basic overview of how things work, though. Like I said, raycasting is all about triangles:
Code:
+----------------+----------------+----------------+----------------+
|                |                |                |WWWWWWWWWWWWWWWW|
|                |                |                |WWWWWWWWWWWWWWWW|
|                |                |                |WWWWWWWWWWWWWWWW|
|                |                |                X WWWWWWWWWWWWWWW|
|                |                |              / |WWWWWWWWWWWWWWWW|
|                |                |            /   |WWWWWWWWWWWWWWWW|
|                |                |          /     |WWWWWWWWWWWWWWWW|
|                |                |        /       |WWWWWWWWWWWWWWWW|
+----------------+----------------+------/---------+----------------+
|                |                |    /           |WWWWWWWWWWWWWWWW|
|                |                |  /             |WWWWWWWWWWWWWWWW|
|                |                |/               |WWWWWWWWWWWWWWWW|
|                |           HYP /|                |WWWWWWWWWWWWWWWW|
|                |             /  |                |WWWWWWWWWWWWWWWW|
|                |           /    |            OPP |WWWWWWWWWWWWWWWW|
|                |         /      |                |WWWWWWWWWWWWWWWW|
|                |       /        |                |WWWWWWWWWWWWWWWW|
+----------------+-----/----------+----------------+----------------+
|                |   /            |                |WWWWWWWWWWWWWWWW|
|                | /              |                |WWWWWWWWWWWWWWWW|
|                /                |                |WWWWWWWWWWWWWWWW|
|         +---+/ | A              |                |WWWWWWWWWWWWWWWW|
|         | P |--+----------------+----------------+WWWWWWWWWWWWWWWW|
|         +---+  |                |  ADJ           |WWWWWWWWWWWWWWWW|
|                |                |                |WWWWWWWWWWWWWWWW|
|                |                |                |WWWWWWWWWWWWWWWW|
+----------------+----------------+----------------+----------------+

To draw a scene, you have to cast several rays away from the player at successive angles. When you cast a ray from player P at angle A, it hits a wall W at point X, forming a triangle. You need to apply trigonometric formulas to find the distance from the player to the wall (HYP), and use that information to calculate how tall that wall slice will appear on screen (greater distances result in smaller walls). Then you also need to find the opposite side (OPP), so you know the exact coordinate that was hit by the ray, in order to know what texture slice to use. Then you just need to do the actual scaling of the texture.

This is a very basic overview of the process, since each of these processes has to be broken down into smaller tasks. Casting the ray for example involves the use of smaller triangles, aligned to the grid:
Code:
+----------------+----------------+----------------+----------------+
|                |                |                |WWWWWWWWWWWWWWWW|
|                |                |                |WWWWWWWWWWWWWWWW|
|                |                |                |WWWWWWWWWWWWWWWW|
|                |                |                X WWWWWWWWWWWWWWW|
|                |                |              / |WWWWWWWWWWWWWWWW|
|                |                |            /   |WWWWWWWWWWWWWWWW|
|                |                |          /     |WWWWWWWWWWWWWWWW|
|                |                |        /       |WWWWWWWWWWWWWWWW|
+----------------+----------------+------/---------+----------------+
|                |                |    /           |WWWWWWWWWWWWWWWW|
|                |                |  /             |WWWWWWWWWWWWWWWW|
|                |                |/---------------+WWWWWWWWWWWWWWWW|
|                |               /|                |WWWWWWWWWWWWWWWW|
|                |             /  |                |WWWWWWWWWWWWWWWW|
|                |           /    |                |WWWWWWWWWWWWWWWW|
|                |         /      |                |WWWWWWWWWWWWWWWW|
|                |       /        |                |WWWWWWWWWWWWWWWW|
+----------------+-----/----------+----------------+----------------+
|                |   /            |                |WWWWWWWWWWWWWWWW|
|                | /              |                |WWWWWWWWWWWWWWWW|
|                /----------------+                |WWWWWWWWWWWWWWWW|
|         +---+/ |                |                |WWWWWWWWWWWWWWWW|
|         | P |--+                |                |WWWWWWWWWWWWWWWW|
|         +---+  |                |                |WWWWWWWWWWWWWWWW|
|                |                |                |WWWWWWWWWWWWWWWW|
|                |                |                |WWWWWWWWWWWWWWWW|
+----------------+----------------+----------------+----------------+

The formulas necessary to do this have a lot of divisions and multiplications, things the 6502 is just not good at, so you'll need to be clever and find ways to optimize those as much as possible. In my engine I was able to turn all divisions into multiplications or table look-ups, and I significantly reduced the number of multiplications by combining multiple operations into a single step.


Top
 Profile  
 
PostPosted: Wed Apr 26, 2017 3:56 pm 
Offline
User avatar

Joined: Thu Mar 31, 2016 11:15 am
Posts: 211
Christ dude, just make a pong game or something. You'll learn a lot more by actually doing things than posting questions on forums.

I'm cheering for you. :beer:


Top
 Profile  
 
PostPosted: Wed Apr 26, 2017 4:17 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10112
Location: Rio de Janeiro - Brazil
It's true, you do seem a little ambitious for someone who's so young and is just starting out with NES development. I'm an example of someone who has learned a lot of stuff over the years without releasing anything, but I wouldn't recommend that to anyone... I'd rather have released some simpler games! Try to set a simpler goal (not pong though, please, we have enough of those!) and go through with it.


Top
 Profile  
 
PostPosted: Wed Apr 26, 2017 4:37 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1823
Location: DIGDUG
Quote:
I don't know anything about Trigonometry, I'm only in middle school. I'll try learning it on my own, though.


In that case, you should learn C# and try to make a game in Unity. Or use GameMaker, which I think, has it's own language, similar to Java (?).

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Wed Apr 26, 2017 10:08 pm 
Offline
User avatar

Joined: Mon Sep 15, 2014 4:35 pm
Posts: 3108
Location: Nacogdoches, Texas
tokumaru wrote:
It's true, you do seem a little ambitious for someone who's so young and is just starting out with NES development.

12?!? I thought me being 15 when I signed up here was bad!

Yeah though, I hate to be the bearer of bad news, but starting out programming by building a raycasting engine (which I have no clue how to do!) will only lead to frustration. I don't think this is something you can really cut into steps where you can see your progress, unlike with a traditional 2D engine.

Just because you probably shouldn't do this doesn't mean you shouldn't avoid the NES. My first programming experience was actually with the SNES, although I didn't understand memory modes for more than my whole first year... I can't say for sure, but I heard learning higher level programming languages will not help you very much for learning assembly, because they are completely different. I know anything other than assembly or machine code still looks like gibberish to me.


Top
 Profile  
 
PostPosted: Thu Apr 27, 2017 1:54 am 
Offline

Joined: Tue May 28, 2013 5:49 am
Posts: 860
Location: Sweden
I think being young and ambitious is a good thing though. I wish I started real programming when I was 12 or even 15, but computers weren't as common back then as they are now so it can't be helped.

Failed projects also makes you stronger, haha! But yeah I'd also say do something simpler first, but still something that interests you.


Top
 Profile  
 
PostPosted: Thu Apr 27, 2017 11:35 am 
Offline

Joined: Mon Jan 30, 2017 5:20 pm
Posts: 300
Location: Colorado USA
I mean yeah, That does seem kind of complicated and hard to do, but I don't mean to brag, but I've learned Java when I was 7. I could probably learn a lot doing this, But to keep it simple, I'll start with a ray-casting engine in C++. I don't see any harm in at least trying.


Top
 Profile  
 
PostPosted: Thu Apr 27, 2017 6:15 pm 
Offline

Joined: Thu Aug 20, 2015 3:09 am
Posts: 288
DementedPurple wrote:
I mean yeah, That does seem kind of complicated and hard to do, but I don't mean to brag, but I've learned Java when I was 7. I could probably learn a lot doing this, But to keep it simple, I'll start with a ray-casting engine in C++. I don't see any harm in at least trying.

I wrote my first game when I was 7. It was a silly little text-mode BASIC thing - no Java in those days! - but it had two players, an AI and win/loss conditions.

I wrote my second game when I was 23 and a half. I spent the intervening time doing exactly what you're doing - aiming for the stars and falling short of the clouds. I'm trying not to sound judgemental, and if that's what you want to do then by all means go for it - but if you want to make games now, you're on the wrong trajectory. Trust me, I've been there.

My advice: whip up something easy, say a roguelike. Doesn't matter if it's awful, doesn't matter if nobody else ever sees it, doesn't matter if you throw the whole thing out and start over. You can learn much, much faster by doing than by reading, and nothing I've tried quite lives up to playing your own game, thinking "wouldn't it be cool if...", and two hours of furious coding and testing later, having found and implemented something even better.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 28 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 5 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:  
Powered by phpBB® Forum Software © phpBB Group