Spider Mastermind
Register | User Profile | Member List | F.A.Q | Privacy Policy | New Blog | Search Forums | Forums Home
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Classic Doom > Source Ports > 360 Turning
 
Author
All times are GMT. The time now is 05:51. Post New Thread    Post A Reply
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.

Old Post 06-11-03 02:33 #
JavaGuy4230 is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit/Delete || Quote
Julian


Posts: 2677
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.

Old Post 06-11-03 02:47 #
Julian is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit/Delete || 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.

Old Post 06-11-03 03:27 #
JavaGuy4230 is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit/Delete || 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

Old Post 06-11-03 11:44 #
DarkWolf is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || 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.

Old Post 06-12-03 13:33 #
JavaGuy4230 is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit/Delete || Quote
Julian


Posts: 2677
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).

Old Post 06-12-03 13:50 #
Julian is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit/Delete || Quote
timmie
2 legit 2 quit!


Posts: 714
Registered: 03-02


movex = distanceToMove * sin(viewangleInRadians);
movey = distanceToMove * cos(viewangleInRadians);
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!

Old Post 06-13-03 22:48 #
timmie is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Fredrik


Posts: 11685
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 ;)

Old Post 06-13-03 22:55 #
Fredrik is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || 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

Old Post 06-14-03 01:48 #
DarkWolf is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Fredrik


Posts: 11685
Registered: 05-00


Or better yet:

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

Old Post 06-14-03 02:44 #
Fredrik is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || 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.

Old Post 06-16-03 02:41 #
JavaGuy4230 is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit/Delete || Quote
Lord FlatHead
man overboard


Posts: 2925
Registered: 06-00


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

Old Post 06-17-03 17:05 #
Lord FlatHead is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || 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?

Old Post 06-26-03 01:26 #
JavaGuy4230 is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit/Delete || Quote
All times are GMT. The time now is 05:51. Post New Thread    Post A Reply
 
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Classic Doom > Source Ports > 360 Turning

Show Printable Version | Email this Page | Subscribe to this Thread

 

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
 

< Contact Us - Doomworld >

Powered by: vBulletin Version 2.2.5
Copyright ©2000, 2001, Jelsoft Enterprises Limited.