Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Raycasting
Index -> Programming, Java -> Java Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
jamonathin




PostPosted: Tue Dec 13, 2005 2:25 pm   Post subject: 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).
Java:

public class game extends Applet implements Runnable

Which is the initial class, i just dont understand everything after 'game'
Java:

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?
Java:

// CERATE A SIMPLE MAP
        byte [] map =
        {
                W, W, W, W, W, W, W, W, W, W, W, W,
                W, O, O, O, O, O, O, O, O, O, O, W,
                W, O, O, O, O, O, O, O, O, O, O, W,
                W, O, O, O, O, O, O, O, O, O, O, W,
                W, O, O, O, O, O, O, O, O, O, O, W,
                W, O, O, W, O, O, O, O, O, O, O, W,
                W, O, O, O, O, O, O, O, O, O, O, W,
                W, O, O, O, O, O, W, O, O, O, O, W,
                W, O, O, O, O, O, O, O, O, O, O, W,
                W, O, O, O, O, O, O, O, O, O, O, W,
                W, O, O, O, O, O, O, O, O, O, O, W,
                W, W, W, W, W, W, W, W, W, W, W, W,
        }
        ;
        fMap = map;

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 Smile



game.java
 Description:

Download
 Filename:  game.java
 Filesize:  19.7 KB
 Downloaded:  118 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Andy




PostPosted: Tue Dec 13, 2005 3:48 pm   Post subject: (No subject)

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




PostPosted: Tue Dec 13, 2005 3:54 pm   Post subject: (No subject)

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




PostPosted: Wed Dec 14, 2005 1:06 pm   Post subject: (No subject)

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




PostPosted: Wed Dec 14, 2005 1:41 pm   Post subject: (No subject)

And do you think this approach will actually lead to you learning anything?
jamonathin




PostPosted: Wed Dec 14, 2005 2:05 pm   Post subject: (No subject)

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




PostPosted: Wed Dec 14, 2005 2:21 pm   Post subject: (No subject)

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




PostPosted: Wed Dec 14, 2005 4:30 pm   Post subject: (No subject)

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.
Sponsor
Sponsor
Sponsor
sponsor
jamonathin




PostPosted: Wed Dec 14, 2005 6:21 pm   Post subject: (No subject)

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. Smile
Andy




PostPosted: Sun Dec 25, 2005 11:47 pm   Post subject: (No subject)

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




PostPosted: Mon Dec 26, 2005 12:19 am   Post subject: (No subject)

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




PostPosted: Mon Dec 26, 2005 2:21 am   Post subject: (No subject)

Martin wrote:
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




PostPosted: Mon Dec 26, 2005 2:33 am   Post subject: (No subject)

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




PostPosted: Mon Dec 26, 2005 2:35 am   Post subject: (No subject)

A sure sign that you're not quite getting OOP: excessive use of "static".
Martin




PostPosted: Mon Dec 26, 2005 10:27 pm   Post subject: (No subject)

wtd wrote:
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.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 26 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: