Jump to content
  • Advertisement

football94

Member
  • Content Count

    64
  • Joined

  • Last visited

Community Reputation

211 Neutral

About football94

  • Rank
    Member
  1. football94

    Double jump 3d

    Problem solved I had much help from the link below http://xboxforums.create.msdn.com/forums/t/113607.aspx         modified code bool doubleJump; //logs whether the player has done a double jump yet void DudeGravity2(GameTime gameTime) { float treshold = 0.0f; float terrainHeight = GetExactHeightAt(avatarPosition2.X, -avatarPosition2.Z); if (avatarPosition2.Y < terrainHeight + treshold) { newPos = avatarPosition2; newPos.Y = terrainHeight + treshold * (float)gameTime.ElapsedGameTime.TotalSeconds; avatarPosition2 = newPos; gravityVelocity = 0;// On ground so not falling. //jump if (keyState.IsKeyDown(Keys.L)) { doubleJump = false; gravityVelocity = 1f; // Adjust this value to control height of jump. } } else { // Not on ground so must be falling. //Add in effect of gravity on current velocity. // m/sec^2 float g = -1.10f; gravityVelocity += g * (float)gameTime.ElapsedGameTime.TotalSeconds; //Add effect of velocity to position. newPos = avatarPosition2; newPos.Y += gravityVelocity * (float)gameTime.ElapsedGameTime.TotalSeconds; avatarPosition2 = newPos; //jump if (!doubleJump && keyState.IsKeyDown(Keys.L)) { doubleJump = true; gravityVelocity = 1f; // Adjust this value to control height of jump. } } another way of doing the same thing separate from the dudegavity2 method KeyboardState oldState; KeyboardState newState = Keyboard.GetState(); // get the newest state if (newPos.Y <= 1f) { //jump if (oldState.IsKeyUp(Keys.R) && newState.IsKeyDown(Keys.R)) { doubleJump = false; gravityVelocity = 1f; // Adjust this value to control height of jump. } else { //jump if (!doubleJump && keyState.IsKeyDown(Keys.R)) { doubleJump = true; gravityVelocity = 1f; } } oldState = newState; }
  2. football94

    Double jump 3d

    Thanks for the response Norm but I have one more question, is there a way to apply this technique while in mid air like in such games as mario 64( I provided sample examples below)                                                                      Thanks again :)       (Mario does a mid air double jump at about 21 seconds into the video)       here's a 2d version of the midair double jump       here's a 2d jpeg illustration. The character does a mid air jump avoiding the water [attachment=31758:IMG_1356.jpg]
  3. football94

    Double jump 3d

    HI everyone Ive been experimenting with gravity in my project and with much input from others Ive managed to add a jumping element, and now I'm working on implementing a double jump to the method but so far Ive run into many brick walls trying to do so, and was hoping if anyone had any suggestions as to how to go about doing it.                                                                       Thankyou             The Methods I used are below             The jump method void DudeGravity2(GameTime gameTime) { float treshold = 0.0f; float terrainHeight = GetExactHeightAt(avatarPosition2.X, -avatarPosition2.Z); if (avatarPosition2.Y < terrainHeight + treshold) { newPos = avatarPosition2; newPos.Y = terrainHeight + treshold * (float)gameTime.ElapsedGameTime.TotalSeconds; avatarPosition2 = newPos; gravityVelocity = 0;// On ground so not falling. //jump if (keyState.IsKeyDown(Keys.L)) { gravityVelocity = 1f; // Adjust this value to control height of jump. } } else { // Not on ground so must be falling. //Add in effect of gravity on current velocity. // m/sec^2 float g = -1.10f; gravityVelocity += g * (float)gameTime.ElapsedGameTime.TotalSeconds; //Add effect of velocity to position. newPos = avatarPosition2; newPos.Y += gravityVelocity * (float)gameTime.ElapsedGameTime.TotalSeconds; avatarPosition2 = newPos; } The method I used to get the height of the terrain (GetExactHeightAt) public float GetExactHeightAt(float xCoord, float zCoord) { bool invalid = xCoord < 0; invalid |= zCoord < 0; invalid |= xCoord > floorPlan.GetLength(0) - 1; invalid |= zCoord > floorPlan.GetLength(1) - 1; if (invalid) return 10; int xLower = (int)xCoord; int xHigher = xLower + 1; float xRelative = (xCoord - xLower) / ((float)xHigher - (float)xLower); int zLower = (int)zCoord; int zHigher = zLower + 1; float zRelative = (zCoord - zLower) / ((float)zHigher - (float)zLower); float heightLxLz = floorPlan[xLower, zLower]; float heightLxHz = floorPlan[xLower, zHigher]; float heightHxLz = floorPlan[xHigher, zLower]; float heightHxHz = floorPlan[xHigher, zHigher]; bool cameraAboveLowerTriangle = (xRelative + zRelative < 1); float finalHeight; if (cameraAboveLowerTriangle) { finalHeight = heightLxLz; finalHeight += zRelative * (heightLxHz - heightLxLz); finalHeight += xRelative * (heightHxLz - heightLxLz); } else { finalHeight = heightHxHz; finalHeight += (1.0f - zRelative) * (heightHxLz - heightHxHz); finalHeight += (1.0f - xRelative) * (heightLxHz - heightHxHz); } return finalHeight; } The terrain I used is from riemers flightsim tutorial(link below)   http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series2/Loading_the_floorplan.php  
  4. football94

    Terrain scaling

    Hi guys    Ive been experimenting with a terrain from riemers xna tutorial website( link below) and came across a problem with scaling the terrain, in my draw method(code below) I added Matrix.CreateScale and the terrain looks to be scaled but when begin to move across the terrain I get an out of bounds exception and I think the problem is even though the terrain is scaled visually  it still seems to reading the boundary data from the original size of the terrain,so I was hoping if anyone had any tips on how to help me solve the problem.                         Thank you private void DrawCity(string technique) { effect1.CurrentTechnique = effect1.Techniques[technique]; effect1.Parameters["xTexture"].SetValue(sceneryTexture); effect1.Parameters["xWorld"].SetValue(Matrix.Identity ); effect1.Parameters["xLightPower"].SetValue(lightPower); effect1.Parameters["xWorldViewProjection"].SetValue(Matrix.Identity *Matrix.CreateScale(10) * view * proj * Matrix.CreateTranslation(0,0,0)); effect1.Parameters["xLightPosition"].SetValue(position ); effect1.Parameters["xAmbient"].SetValue(ambientPower); effect1.Parameters["xlightsWorld"].SetValue(Matrix.Identity * lightsViewProjectionMatrix); effect1.Parameters["xShadowMap"].SetValue(shadowMap); effect1.Begin(); foreach (EffectPass pass in effect1.CurrentTechnique.Passes) { pass.Begin(); device.VertexDeclaration = new VertexDeclaration(device, VertexPositionNormalTexture.VertexElements); device.Vertices[0].SetSource(cityVertexBuffer, 0, VertexPositionNormalTexture.SizeInBytes); device.DrawPrimitives(PrimitiveType.TriangleList, 0, cityVertexBuffer.SizeInBytes / 3); pass.End(); } effect1.End(); riemers link http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series2/Loading_the_floorplan.php
  5. football94

    uneven 3D tile map

    Thanks for the reply HappyCoder but Ive managed to come up with a solution which was to just change the int floorplan into a float floorplan which works perfectly for me since that I now have more options to play around with the number values     Thankyou   new code below public void LoadFloorPlan() { floorPlan = new float[,] { {0.1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f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f}, {0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f}, {0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f}, {0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f}, {0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f}, {0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f}, {0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f}, {0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f}, {0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f}, {0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f}, {0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f,0.002f}, }; }
  6. Hi guys Ive been researching riemers xna flightsim game(link below) and did some collision detection experiments using the terrain , but after modifying the numbers in the array I came across the problem of an uneven surface, for example for all the zero values the avatar stays even with the terrain, but when I changed the values to one, the avatar began to move up, and higher still with the two values, so I was hoping if anyone had any advice or suggestions on how the problem could be fixed, it would be much appreciated.                                Thank you         link to riemers flightsim http://www.riemers.net/eng/Tutorials/XNA/Csharp/series2.php   The array   public void LoadFloorPlan()         {             floorPlan = new int[,]              {                  {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},                    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},                  {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},                  {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},                  {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},                  {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},                  {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2},                  {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2},                  {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2},                  {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2},                  {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2},                  {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2},                  {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2},                  {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2},                  {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},                  {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},                  {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},                  {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},                  {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},                  {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},                  {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},                  {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},                  {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},                  {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},                  {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},                                                 };                    }  public void SetUpVertices()         {             cityWidth = floorPlan.GetLength(0) ;             cityLength = floorPlan.GetLength(1) ;                         List<VertexPositionNormalTexture> verticesList = new List<VertexPositionNormalTexture>();             for ( x = 0; x < cityWidth; x++)             {                 for ( z = 0; z < cityLength; z++)                 {                     int imagesInTexture = 11;                     int imagesInTexture1 = 1;                     int imagesInTexture2 = 5;                     if (floorPlan[x, z] == 0)                     {                         verticesList.Add(new VertexPositionNormalTexture(new Vector3(x, 0, -z), new Vector3(0, 1, 0), new Vector2(0, 1)));                         verticesList.Add(new VertexPositionNormalTexture(new Vector3(x, 0, -z - 1), new Vector3(0, 1, 0), new Vector2(0, 0)));                         verticesList.Add(new VertexPositionNormalTexture(new Vector3(x + 1, 0, -z), new Vector3(0, 1, 0), new Vector2(1.0f / imagesInTexture, 1)));                         verticesList.Add(new VertexPositionNormalTexture(new Vector3(x, 0, -z - 1), new Vector3(0, 1, 0), new Vector2(0, 0)));                         verticesList.Add(new VertexPositionNormalTexture(new Vector3(x + 1, 0, -z - 1), new Vector3(0, 1, 0), new Vector2(1.0f / imagesInTexture, 2)));                         verticesList.Add(new VertexPositionNormalTexture(new Vector3(x + 1, 0, -z), new Vector3(0, 1, 0), new Vector2(1.0f / imagesInTexture, 1)));                     }                                              if (floorPlan[x, z] == 1)                         {                                                                                    verticesList.Add(new VertexPositionNormalTexture(new Vector3(x, 0, -z), new Vector3(0, 1, 0), new Vector2(0, 1)));                             verticesList.Add(new VertexPositionNormalTexture(new Vector3(x, 0, -z - 1), new Vector3(0, 1, 0), new Vector2(0, 0)));                             verticesList.Add(new VertexPositionNormalTexture(new Vector3(x + 1, 0, -z), new Vector3(0, 1, 0), new Vector2(1.0f / imagesInTexture, 1)));                             verticesList.Add(new VertexPositionNormalTexture(new Vector3(x, 0, -z - 1), new Vector3(0, 1, 0), new Vector2(0, 0)));                             verticesList.Add(new VertexPositionNormalTexture(new Vector3(x + 1, 0, -z - 1), new Vector3(0, 1, 0), new Vector2(1.0f / imagesInTexture, 0)));                             verticesList.Add(new VertexPositionNormalTexture(new Vector3(x + 1, 0, -z), new Vector3(0, 1, 0), new Vector2(1.0f / imagesInTexture, 1)));                         }                         if (floorPlan[x, z] == 2)                     {                         verticesList.Add(new VertexPositionNormalTexture(new Vector3(x, 0, -z) , new Vector3(0, 1, 0), new Vector2(0, 1)));                         verticesList.Add(new VertexPositionNormalTexture(new Vector3(x, 0, -z - 1) , new Vector3(0, 1, 0), new Vector2(0, 0)));                         verticesList.Add(new VertexPositionNormalTexture(new Vector3(x + 1, 0, -z) , new Vector3(0, 1, 0), new Vector2(1.0f / imagesInTexture2, 1)));                         verticesList.Add(new VertexPositionNormalTexture(new Vector3(x, 0, -z - 1) , new Vector3(0, 1, 0) , new Vector2(0, 0)));                         verticesList.Add(new VertexPositionNormalTexture(new Vector3(x + 1, 0, -z - 1) , new Vector3(0, 1, 0) , new Vector2(1.0f / imagesInTexture2, 0)));                         verticesList.Add(new VertexPositionNormalTexture(new Vector3(x + 1, 0, -z)  , new Vector3(0, 1, 0) , new Vector2(1.0f / imagesInTexture2, 1)));                     }                 }             }             cityVertexBuffer = new VertexBuffer(device, verticesList.Count * VertexPositionNormalTexture.SizeInBytes, BufferUsage.WriteOnly);             cityVertexBuffer.SetData<VertexPositionNormalTexture>(verticesList.ToArray());         } pictures of avatar   blue for zero values red for one values green for two values
  7. football94

    Cloning a 3D Model

    Thankyou imoogiBG I never thought of that, thanks for teaching me something new.                                                       Thanks again
  8. Hi guys Ive been researching the sub zero ice clone technique(pic below) in the mortal kombat games and been trying to figure out how I can implement this techique in xna but Im not quite sure how its done and was hoping if anyone would be so kind as to give any pointers or comments on the subject.                                                                                Thankyou       Resources Ive researched so far but still not sure http://xbox.create.msdn.com/en-US/education/catalog/sample/mesh_instancing http://xboxforums.create.msdn.com/forums/p/26056/142855.aspx           Subzero clone pic   [attachment=28614:subzero clone.png]       Subzero clone video from youtube           I think a simpler example of what Im looking for is in the youtube video below when the ball starts to repeat about 35 seconds into the video    
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!