
-----------------------------------
jamonathin
Tue Dec 13, 2005 2:25 pm

Raycasting
-----------------------------------
I started getting bored at school, and so i decided to take up 3D programming.  I got Martin's "tutorial" on it where it led to a site and explained what you should do, but not really how to do it.  At the end of the tutorial he gave source code for java.

There's quite a few things i dont get (as always).

public class game extends Applet implements Runnable
Which is the initial class, i just dont understand everything after 'game'

fThread = new Thread (this);
I know that's changing that array, but to 'this'?  What the hell is; this?

and one last thing for now. . . how does this make a map? or at least the structure of one?

// CERATE A SIMPLE MAP
        byte 
The w's are for wall and o's are for open. . .drrrr . . . but how does all that information get transfered into an array of type "byte"?

Here's all of the code .  Any help is appreciated :)

-----------------------------------
Andy
Tue Dec 13, 2005 3:48 pm


-----------------------------------
how much java have you done? if you dont understand those lines, then you'll have a hell of a time trying to learn 3d programming.. extends means it inherits from, and impliments means its defining the class runnable. i'd go back to learning more java before starting 3d

-----------------------------------
Hikaru79
Tue Dec 13, 2005 3:54 pm


-----------------------------------
Ooooh boy. Jamonathin, you don't seem to understand what objects and classes are. You really really should go back and learn that first. The answers to your questions should come as naturally as breathing to you before you start writing raycasters in Java =P Honestly.

However, just to answer your questions:

1) "extends" means it subclasses Applet.
2) "implements" means it is implementing Runnable (i.e, it is a Thread)
3) "this" is an object's reference to itself.
4) The line "fThread = new Thread (this);" has NOTHING at ALL to do with Arrays in any way, shape, or form. It is creating a new thread object, passing a reference to itself as a parameter (since this class Implements Runnable, this allows the Thread to execute concurrently).

You still don't seem to understand the difference between Java and Turing yet =/

-----------------------------------
jamonathin
Wed Dec 14, 2005 1:06 pm


-----------------------------------
I know I should slow down a bit with my learning of this, and probabily start dealing with something simpler, but I really dont have time to sit down and do a million basic programs and work my way up.  Im too far behind in the programming world.  Look at it this way, tony is like 2? years older than I am, and he probabily knows 10x more than I do.  And the same thing goes with other people such as martin, who made a 3D maze in Turing like 2 years ago?  That's probabily my age now, maybe even 1 less.   I need to pick it up, thats why im pushin things.

-----------------------------------
wtd
Wed Dec 14, 2005 1:41 pm


-----------------------------------
And do you think this approach will actually lead to you learning anything?

-----------------------------------
jamonathin
Wed Dec 14, 2005 2:05 pm


-----------------------------------
Possibly.  Im just using this as something to refer to.  If i'm gonna be doing anything myself 3D is gonna be rotating a 3D cube, but I hope to learn all this at a fairly quick pace, considering I can only really learn to do this stuff at school, or if i buy a book/print one.

-----------------------------------
wtd
Wed Dec 14, 2005 2:21 pm


-----------------------------------
Keep in mind, there's a very important reason educators like to teach through simple examples, and it's not to tick students off.

The reason is that you can teach concepts without losing sight of them in the course of building a complex program.  If I try to teach someone how to open and read from a file, but require that it be done within a large, complex Swing GUI app, I'll spend a lot of time on the GUI, and that will be the subject of all of the questions.  By the time I'm done answering Swing questions, I'll have no desire to talk about how to actually open and read from files.

-----------------------------------
Hikaru79
Wed Dec 14, 2005 4:30 pm


-----------------------------------
And anyway, to be honest, inheritance, interfaces, and class structure are far more useful things to learn (it will put you closer to Martin and Tony) than making a 3d rotating cube. They're immensely important concepts.

-----------------------------------
jamonathin
Wed Dec 14, 2005 6:21 pm


-----------------------------------
I'll still gonna learn the basics, hopefully quickly. And i do understand where your coming from wtd.
I'll be keepin in mind what you guys said.  Thanks for your inputs.  :)

-----------------------------------
Andy
Sun Dec 25, 2005 11:47 pm


-----------------------------------
and there is nothing wrong with being behind, u have the rest of your life ahead of you, u probably wont need to find a job for another 7 years, or 3 if you do co op, just start slow, and keep going at it

-----------------------------------
Martin
Mon Dec 26, 2005 12:19 am


-----------------------------------
Try it in Turing first, it'll be a lot easier.

As for what to learn, it depends on what you like about programming. I really like graphics.

Don't worry too much about object orientation right now. I didn't really learn how to use it until university.

And finally, it's not a race. And even if it is, you're doing fine.

When I started writing my raycasting engine, the first thing that I did was made a 2d guy navigate through a 2d map - because, after all raycasting is just a 3d projection of a 2d world - not true 2d. And that's the hardest part. Once you're done that, the rest is just hacking with trig.

-----------------------------------
wtd
Mon Dec 26, 2005 2:21 am


-----------------------------------
Don't worry too much about object orientation right now.

If you don't want to deal with object-orientation, don't use a heavily object-oriented environment.  Doing so is just denial.

-----------------------------------
rizzix
Mon Dec 26, 2005 2:33 am


-----------------------------------
Yea, try something else other than Java.. if OO is not your thing. Most people write poor Java code because they don't know OOD.

-----------------------------------
wtd
Mon Dec 26, 2005 2:35 am


-----------------------------------
A sure sign that you're not quite getting OOP: excessive use of "static".

-----------------------------------
Martin
Mon Dec 26, 2005 10:27 pm


-----------------------------------
A sure sign that you're not quite getting OOP: excessive use of "static".

Or, you know, a million seg faults.


But anyway back on topic:
I am a big fan of Turing for learning how to program. Turing has a very clean  syntax and an IDE that is at a really nice place between notepad and an actual IDE, which I think is exactly what the aspiring programmer needs. Platform dependance and price aside, I think it was an excellent first programming language to learn. The other thing I like about it is its speed. The fact that it's not fast forces the programmer in some ways to optimize their code better than the necissarily would otherwise. So don't feel bad about using Turing. And as for graphics, I haven't found anything that meets the ease of use for 2d graphics for Turing. And for raycasting, Turing is more than fast enough to get a working engine up.

-----------------------------------
jamonathin
Thu Dec 29, 2005 12:34 pm


-----------------------------------
Thanks for your inputs guys :). It would make a lot of sense to practice this stuff in Turing, cuz I know all the commands and crap, and as Martin said, it's fast and clean.  Thanks again guys.

-----------------------------------
wtd
Thu Dec 29, 2005 1:48 pm


-----------------------------------
Now... when I say that if you don't want to deal with OOP you shouldn't use a heavily OO language...

I didn't mean you shouldn't.  I think you should instead try learning.

Learning how to work with OOP and use it to your advantage is likely far more important than any knowledge you'll gain raycasting in Turing.

-----------------------------------
Martin
Thu Dec 29, 2005 2:15 pm


-----------------------------------
Nah, he can learn OOP later. Fun is more important right now. And it's not like you won't learn anything writing a raycasting engine.

-----------------------------------
wtd
Thu Dec 29, 2005 2:18 pm


-----------------------------------
Didn't want my input to seem like:

"You suck at Java, nOOb!  Go back to Turing you moron!!!111!!onehundredandeleven!"

-----------------------------------
[Gandalf]
Thu Dec 29, 2005 4:15 pm


-----------------------------------
"j00 sux0r5 @ j4v4, n00bz0r5!1!  g0 b4ck t0 tur1ng j00 m0r0n!11!!11!!"
I felt like killing some time on something that wouldn't benefit anyone.  These things are actually pretty challenging to write.  lol

You know, as impossible it is to comprehend, you can still learn the basics (and a bit further) of OOP using the object-oriented part of Turing.

-----------------------------------
wtd
Thu Dec 29, 2005 5:13 pm


-----------------------------------
"]You know, as impossible it is to comprehend, you can still learn the basics (and a bit further) of OOP using the object-oriented part of Turing.

It isn't impossible to comprehend.  Turing just makes you work too hard for what you learn.  Last I checked, Turing didn't support a lot of OO concepts present in many other languages.

-----------------------------------
[Gandalf]
Thu Dec 29, 2005 9:26 pm


-----------------------------------
Ok, but it still serves as a decent introduction, right?  Does it make you work too hard to learn just because it lacks some OOP features?

-----------------------------------
wtd
Thu Dec 29, 2005 9:43 pm


-----------------------------------
From what I've seen, the syntax is unwieldy due to declaration, allocation of memory, and initialization having to occur on separate lines.  Additionally, there's the requirement that one specify separately members names which one wishes to make public.  This opens up lots of opportunity for typos to cause bugs that would occur elsewhere.

Then there's the semantic overhead.  One must understand pointers to make use of objects in Turing.

-----------------------------------
wtd
Thu Dec 29, 2005 9:45 pm


-----------------------------------
Oh, and from what I've seen, there are either very few or no classes provided with Turing.  This means there's little to experiment without writing one's own classes.

-----------------------------------
[Gandalf]
Fri Dec 30, 2005 2:18 am


-----------------------------------
I see, and I agree. :)  I meant that an introduction to OOP in Turing is better than no introduction at all, and I was also looking for a better explanation of the shortcomings of OOT rather than it missing some concepts.

-----------------------------------
wtd
Fri Dec 30, 2005 3:03 am


-----------------------------------
Why does it have to be Turing or nothing?

I would honestly say that learning another language that better supports OOP will lead to understanding OOP concepts more quickly than trying to gan the same understanding in Turing, despite one already knowing the other aspects of Turing.
