"A FPS Game" Online Game

Anything related in any way to game development as a whole is welcome here. Tell us about your game, grace us with your project, show us your new YouTube video, etc.

Moderator: PC Supremacists

User avatar
LeonBlade
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1314
Joined: Thu Jan 22, 2009 12:22 am
Current Project: Trying to make my first engine in C++ using OGL
Favorite Gaming Platforms: PS3
Programming Language of Choice: C++
Location: Blossvale, NY

Re: "A FPS Game" Online Game

Post by LeonBlade »

I'm trying to take the difference of the distances between the X and Z of the two objects.
Then seeing if the distance is less than the radius.

But this doesn't always work, because sometimes the values are negative...
There's no place like ~/
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: "A FPS Game" Online Game

Post by Ginto8 »

LeonBlade wrote:But this doesn't always work, because sometimes the values are negative...
Create an absolute value function, like this:

Code: Select all

int abs( int number )
{
    if( number < 0 )
       return -number;
    return number;
}
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
User avatar
LeonBlade
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1314
Joined: Thu Jan 22, 2009 12:22 am
Current Project: Trying to make my first engine in C++ using OGL
Favorite Gaming Platforms: PS3
Programming Language of Choice: C++
Location: Blossvale, NY

Re: "A FPS Game" Online Game

Post by LeonBlade »

Wow... I can't believe I never thought of that haha.
It works too!!!

Thanks so much dude, your the best!
There's no place like ~/
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: "A FPS Game" Online Game

Post by Ginto8 »

LeonBlade wrote:Wow... I can't believe I never thought of that haha.
It works too!!!

Thanks so much dude, your the best!
No problem, glad I could help. :)
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
User avatar
LeonBlade
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1314
Joined: Thu Jan 22, 2009 12:22 am
Current Project: Trying to make my first engine in C++ using OGL
Favorite Gaming Platforms: PS3
Programming Language of Choice: C++
Location: Blossvale, NY

Re: "A FPS Game" Online Game

Post by LeonBlade »

I'm almost there...
So, what I'm doing is setting my Velocity to 0 when I encounter a collision.

Code: Select all

private void CheckCollisions()
        {
            for (int i = 0; i < objects.Length; i++)
            {
                float delta_x = abs(player.Center.X) - abs(objects[i].Center.X);
                float delta_z = abs(player.Center.Z) - abs(objects[i].Center.Z);

                float sum = (player.Sphere.Radius * objects[i].Sphere.Radius) * 2;

                if (delta_x <= sum && delta_z <= sum)
                {
                    if (player.Velocity.X != -player.Velocity.X)
                    {
                        hit_x = true;
                    }
                    else
                    {
                        hit_x = false;
                    }
                    if (player.Velocity.Z != -player.Velocity.Z)
                    {
                        hit_z = true;
                    }
                    else
                    {
                        hit_z = false;
                    }
                }
            }
        }
Now what I'm doing is making it so you can only move in the set velocity if it's negative of it's current...
But that isn't working right... it was earlier...
There's no place like ~/
User avatar
M_D_K
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1087
Joined: Tue Oct 28, 2008 10:33 am
Favorite Gaming Platforms: PC
Programming Language of Choice: C/++
Location: UK

Re: "A FPS Game" Online Game

Post by M_D_K »

You should really include Y axis checking in that.
Gyro Sheen wrote:you pour their inventory onto my life
IRC wrote: <sparda> The routine had a stack overflow, sorry.
<sparda> Apparently the stack was full of shit.
User avatar
LeonBlade
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1314
Joined: Thu Jan 22, 2009 12:22 am
Current Project: Trying to make my first engine in C++ using OGL
Favorite Gaming Platforms: PS3
Programming Language of Choice: C++
Location: Blossvale, NY

Re: "A FPS Game" Online Game

Post by LeonBlade »

Yeah I know, but I'm not doing Y collision just yet.
But that shouldn't effect it in the way that it does.

When you encounter an object, you stop on both X and Z axis, and then if you try to move away, it does nothing...

I'm stopping the update of the player's position, not the velocity, so you still should be able to adjust velocity and get (unstuck) but it's not working right...
There's no place like ~/
User avatar
M_D_K
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1087
Joined: Tue Oct 28, 2008 10:33 am
Favorite Gaming Platforms: PC
Programming Language of Choice: C/++
Location: UK

Re: "A FPS Game" Online Game

Post by M_D_K »

But doesn't velocity update position?

And why did you have a variable called bleed in your update loop shouldn't you be multiplying by delta time(currentTime - lastTime).
Gyro Sheen wrote:you pour their inventory onto my life
IRC wrote: <sparda> The routine had a stack overflow, sorry.
<sparda> Apparently the stack was full of shit.
User avatar
LeonBlade
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1314
Joined: Thu Jan 22, 2009 12:22 am
Current Project: Trying to make my first engine in C++ using OGL
Favorite Gaming Platforms: PS3
Programming Language of Choice: C++
Location: Blossvale, NY

Re: "A FPS Game" Online Game

Post by LeonBlade »

Yes Velocity Updates Position... but you can still modify Velocity even when I lock the Position.

And I don't know how to get currentTime - lastTime so I just bleed off the velocity like that.
There's no place like ~/
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: "A FPS Game" Online Game

Post by MarauderIIC »

<cmath> has abs() by the way, which is an absolute value fn.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
LeonBlade
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1314
Joined: Thu Jan 22, 2009 12:22 am
Current Project: Trying to make my first engine in C++ using OGL
Favorite Gaming Platforms: PS3
Programming Language of Choice: C++
Location: Blossvale, NY

Re: "A FPS Game" Online Game

Post by LeonBlade »

M_D_K helped me out big time with some stuff!
So I'm getting there, thanks again M_D_K!
There's no place like ~/
User avatar
Aeolus
Chaos Rift Regular
Chaos Rift Regular
Posts: 179
Joined: Fri Jan 16, 2009 2:28 am

Re: "A FPS Game" Online Game

Post by Aeolus »

Are you going to implement guns?
Hyde from That 70's Show wrote:Woman are like muffins... Once you have a muffin you will do anything to have another muffin... And they know that.
User avatar
LeonBlade
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1314
Joined: Thu Jan 22, 2009 12:22 am
Current Project: Trying to make my first engine in C++ using OGL
Favorite Gaming Platforms: PS3
Programming Language of Choice: C++
Location: Blossvale, NY

Re: "A FPS Game" Online Game

Post by LeonBlade »

Aeolus wrote:Are you going to implement guns?
Lol yes... it would be pretty shitty FPS without guns don't you think? Haha :lol:
Right now still working on basic game mechanics...
There's no place like ~/
User avatar
Aeolus
Chaos Rift Regular
Chaos Rift Regular
Posts: 179
Joined: Fri Jan 16, 2009 2:28 am

Re: "A FPS Game" Online Game

Post by Aeolus »

No i mean multi-guns.

Deagle, M-16, m-4, etc...
Hyde from That 70's Show wrote:Woman are like muffins... Once you have a muffin you will do anything to have another muffin... And they know that.
User avatar
LeonBlade
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1314
Joined: Thu Jan 22, 2009 12:22 am
Current Project: Trying to make my first engine in C++ using OGL
Favorite Gaming Platforms: PS3
Programming Language of Choice: C++
Location: Blossvale, NY

Re: "A FPS Game" Online Game

Post by LeonBlade »

Oh... yeah probably, for now it will just be one gun though.
There's no place like ~/
Post Reply