User Profile | Member List | F.A.Q | Privacy Policy | New Blog | Search Forums | Forums Home
 Doomworld Forums > Classic Doom > Source Ports > 360 Turning
Author
 All times are GMT. The time now is 22:14.
JavaGuy4230
Mini-Member

Posts: 58
Registered: 06-03

I'm trying to learn how to program games (seriously now, since I have some partners). Right now I'm trying to figure out how a character who turns 360 degrees moves. It'll be 2D, but it's the same concept as the turning in a first person shooter. In any case, make a character on the screen turn is easy enough. However, once you hit that foward button, the character has to move in the direction of face. So how does this work? I've had a couple ideas of my own, but I haven't implemented them. Anyway, what I'm hoping is that someone can give me the file/s containing the source code for movement in Doom. By looking at it I can compare it to my ideas. And also although thing. Does the movement involve conditionals or is it just a pure algorithm thing? I don't know if they have it going though if then statements everytime some movement thread comes about. Help is appreciated, thanks.

Jun 11 2003 02:33 #
 || Blog || PM || Post History || Add Buddy IP || Edit || Quote
Julian

Posts: 2678
Registered: 04-75

JavaGuy4230 said:
I'm trying to learn how to program games (seriously now, since I have some partners). Right now I'm trying to figure out how a character who turns 360 degrees moves. It'll be 2D, but it's the same concept as the turning in a first person shooter.
Exactly like DOOM heh.

JavaGuy4230 said:
In any case, make a character on the screen turn is easy enough. However, once you hit that foward button, the character has to move in the direction of face. So how does this work?
Keep an angle or a line direction as an info attached to the player structure

JavaGuy4230 said:
I've had a couple ideas of my own, but I haven't implemented them. Anyway, what I'm hoping is that someone can give me the file/s containing the source code for movement in Doom. By looking at it I can compare it to my ideas.
It's pretty easy to get the DOOM source (or any other port), but I wouldn't recommand it. DOOM's code is a mess actually.

JavaGuy4230 said:
And also although thing. Does the movement involve conditionals or is it just a pure algorithm thing? I don't know if they have it going though if then statements everytime some movement thread comes about. Help is appreciated, thanks.
The way you handle movements and collision detection is higly dependant on the underlying structures. I'd recommand to check some serious tutorial on the web before starting a game engine. And even if you have a straight-forward algorithm, I doubt it'll ever be conditional free.

Jun 11 2003 02:47 #
 || Blog || PM || Post History || Add Buddy IP || Edit || Quote
JavaGuy4230
Mini-Member

Posts: 58
Registered: 06-03

Yeah. I wasn't sure if it would be conditional free. Thing is, with my ideas, it might take one or two if then statements in the midst of the movement code. The thing is I was wondering if there was a better way to do it for efficiency.

Jun 11 2003 03:27 #
 || Blog || PM || Post History || Add Buddy IP || Edit || Quote
DarkWolf
Member

Posts: 360
Registered: 08-02

Moving the player in the angle direction he's facing can be done with some simple trig. There are probably other ways to do it too.

__________________
-DarkWolf
DarkWolf's Doom Page (down)
Scientia et Mors

Jun 11 2003 11:44 #
 || Blog || PM || Post History || Add Buddy IP || Edit || Quote
JavaGuy4230
Mini-Member

Posts: 58
Registered: 06-03

Yeah. Like I said, I've got an idea, but I still have to implement it. I get the center of character, and two points on the radius (four all together for both x and y axis) and using the three points I can calculate the angle (through trig, since the angle always makes an isosceles triangle, which can be split into two right) and make him move proportional distances. But like I said, since I haven't gotten around to that yet I just wanted to see Doom's source code to see how they did it.

Actually, before I figured out my own way of doing it, I tried going Sun's forums (they developed Java). It turns out nobody there is any help at all.

Jun 12 2003 13:33 #
 || Blog || PM || Post History || Add Buddy IP || Edit || Quote
Julian

Posts: 2678
Registered: 04-75

JavaGuy4230 said:
It turns out nobody there is any help at all.
Well, you problem has nothing to do with java. It is purely algorithmic (if you can use such a word for something that simple).

Jun 12 2003 13:50 #
 || Blog || PM || Post History || Add Buddy IP || Edit || Quote
timmie
2 legit 2 quit!

Posts: 714
Registered: 03-02

posx += movex;
posy += movey;

How's that? I might have the sin/cos mixed up, though...

Oh, the Doom engine uses binary angles for everything, so it's probably not the best resource for this.

__________________
That's grade 4.9 like a fox!

Jun 13 2003 22:48 #
 || Blog || PM || Post History || Add Buddy IP || Edit || Quote
Fredrik

Posts: 11773
Registered: 05-00

How's that? I might have the sin/cos mixed up, though...
Yeah, I think you do. I've memorized that cos always goes for x and sin always goes for y ;)

Jun 13 2003 22:55 #
 || Blog || PM || Post History || Add Buddy IP || Edit || Quote
DarkWolf
Member

Posts: 360
Registered: 08-02

posx = distanceToMove * cos(viewangleInRadians) + posx;
posy = distanceToMove * sin(viewangleInRadians) + posy;

Save yourself some variables.

__________________
-DarkWolf
DarkWolf's Doom Page (down)
Scientia et Mors

Jun 14 2003 01:48 #
 || Blog || PM || Post History || Add Buddy IP || Edit || Quote
Fredrik

Posts: 11773
Registered: 05-00

Or better yet:

Jun 14 2003 02:44 #
 || Blog || PM || Post History || Add Buddy IP || Edit || Quote
JavaGuy4230
Mini-Member

Posts: 58
Registered: 06-03

Well, thanks for posting, but it doesn't matter because my idea worked. Actually I was suprised to come back here and find more replies. Well, whatever, done and over.

On another note, the problem is not Java related, but since people there program games similar to those I wish to program, I thought that perhaps someone would have a good answer.

Jun 16 2003 02:41 #
 || Blog || PM || Post History || Add Buddy IP || Edit || Quote
man overboard

Posts: 2925
Registered: 06-00

Hey, I needed this too for a stupid little racing game I'm writing. Thanks.

Jun 17 2003 17:05 #
 || Blog || PM || Post History || Add Buddy IP || Edit || Quote
JavaGuy4230
Mini-Member

Posts: 58
Registered: 06-03

Sorry for bumping this older thread, but I didn't see a reason to start a new one, since this is along the same lines.

Anyway, I was hoping someone might be able to point me towards some comprehensive Trig lessons on the net. The thing is, I figure it'd be good to know a bit on how it works (I mean, I know about sin, cos, tan, and their inverses, but it get's rather complicated when I want to do various things for games). The thing of it is, my school doesn't teach trig, so my only method other than an internet lesson (or if I can find a decent book) is to pay \$1200 for summer school at a local college. Any links?

Jun 26 2003 01:26 #
 || Blog || PM || Post History || Add Buddy IP || Edit || Quote
 All times are GMT. The time now is 22:14.
 Doomworld Forums > Classic Doom > Source Ports > 360 Turning

Forum Rules:
 You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is OFF vB code is ON Smilies are OFF [IMG] code is ON