• Advertisement

Lars-Kristian

Member
  • Content count

    15
  • Joined

  • Last visited

Community Reputation

158 Neutral

About Lars-Kristian

  • Rank
    Member
  1. Xna GameTime problem?

    [quote name='AmzBee' timestamp='1350903299' post='4992722'] Try updating your logic less frequent, let's say 30fps: [CODE] TimeSpan.FromMilliseconds(1000.0d / 30.0d); [/CODE] [/quote] Thanks for a reply, but this did not work for me and the problem is still there. I used Stopwatch to time my update- and draw method. Update uses under 1ms and draw under 2ms, so I don't think its because my game is to complex.
  2. Xna GameTime problem?

    The code is not displayed the proper way. Does anyone know how to fix it?
  3. Xna GameTime problem?

    Hi, everyone! I am making a game for wp7 using silverlight/xna. In the pre made code the game loop is setup like this: [source lang="csharp"]GameTimer timer; public MyGame() { timer = new GameTimer(); timer.UpdateInterval = TimeSpan.FromTicks(166666); timer.Update += OnUpdate; timer.Draw += OnDraw; } private void OnUpdate(object sender, GameTimerEventArgs e) { } private void OnDraw(object sender, GameTimerEventArgs e) { }[/source] When the game runs, it lags precisely one time a second; From my understanding the GameTimer suspends a frame if the frame is using more time than it should. My game is pretty simple and the game runs fine on all the other frames, so why is this happening only one time per second? I have Googled around and this seem to be a common problem. But I can't find a solution to it. If someone have had this problem or know a solution I would be very happy if you can share it with me. [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img]
  4. If you have a basic understanding about vectors this link will help you a lot: [url="http://www.metanetsoftware.com/technique/tutorialA.html"]http://www.metanetso.../tutorialA.html[/url] Under the "calculating the projection vector" section. You can: 1. Find the the smallest projection vector. 2. Move the ball on the outside of the paddle.(The length of the projection vector) 3. Reverse the acceleration of the ball in the direction of the collision. Note: It can also be useful too not allow movement of the paddle if the ball hits the top or bottom side of the paddle, so that the ball and paddle does not collide 2 time in a row. This is not the simplest method too find the collision, but it is very useful when it comes too collision handling. If this does not make sense, please let me know. xD
  5. Hi I read your post and I think I can help. But first I need to know: How do you want your game to look like? Are you aiming for the absolute simplest version(the ball updates 1-5 times a second), or the more modern version(the ball have a fluid motion)? Is the ball round or square? What happens if it hits a corner of the paddle?
  6. Bug in Verlet integrated physics engine.

    Thanks for the help, I will try those things tomorrow.
  7. Bug in Verlet integrated physics engine.

    I understand that not everything makes sense. The fraction thing is a variable between 0.5-1.0, it helps making everything more stable. If something collides, instead of moving both object all the away from each other, they are only moved by a fraction. like a dampening effect. m is a vertex, v1 and v2 is an edge. If a vertex is active it can move, but not if its not active. I agree with that mass thing. Are you saying that if 2 objects collide, the object with the least mass moves the most?
  8. Bug in Verlet integrated physics engine.

    Thanks for a good reply The game is a typical bridge builder game. And the problem is with the train. I have managed to get the jumping down to 2-3px, but it still looks horrible. [attachment=11605:test.png] [size=3]The train has not yet been given a texture[/size][size=3]. [img]http://public.gamedev.net//public/style_emoticons/default/tongue.png[/img] [size=4]I think the problem is here[/size][/size] v1 and v2 is the edge, and m is the colliding vertex. [CODE] private void CollidingE(Vertex m, Vertex v1, Vertex v2, Vector2 cv) //cv = Collision Vector { if (v1.active == false && v2.active == false) { m.pos += cv * fraction; return; } float t; if (Math.Abs(v1.pos.X - v2.pos.X) > Math.Abs(v1.pos.Y - v2.pos.Y)) { t = (m.pos.X - cv.X - v1.pos.X) / (v2.pos.X - v1.pos.X); } else { t = (m.pos.Y - cv.Y - v1.pos.Y) / (v2.pos.Y - v1.pos.Y); } float lambda = 1.0f / (t * t + (1 - t) * (1 - t)); Vector2 v1pos = v1.pos; Vector2 v2pos = v2.pos; Vector2 mpos = m.pos; if (m.active == true) { if (v1.active == true && v2.active == true) { v1pos -= cv * ((1 - t) * lambda / 2.0f) * fraction; v2pos -= cv * (t * lambda / 2.0f) * fraction; } else if (v1.active == false && v2.active == true) { v2pos -= cv * (t * lambda) * fraction; } else if (v1.active == true && v2.active == false) { v1pos -= cv * ((1 - t) * lambda) * fraction; } mpos += cv * fraction; } else { if (v1.active == true && v2.active == true) { v1pos -= cv * ((1 - t) * lambda) * fraction; v2pos -= cv * (t * lambda) * fraction; } else if (v1.active == false && v2.active == true) { v2pos -= cv * (t * lambda * 2) * fraction; } else if (v1.active == true && v2.active == false) { v1pos -= cv * ((1 - t) * lambda * 2) * fraction; } } v1.pos = v1pos; v2.pos = v2pos; m.pos = mpos; } [/CODE] Or here [CODE] private void UpdateVertices(List<Vertex> list) { Vector2 tmp; foreach (Vertex v in list) { Vector2 pos = v.pos; Vector2 oldpos = v.oldpos; Vector2 deltapos = v.deltapos; if (v.type == Vertex.NORMAL) { deltapos.X = 0; deltapos.Y = v.mass; deltapos -= (pos - oldpos) * 0.0001f;//0.0001f * (pos - oldpos); tmp = pos; pos += pos - oldpos + deltapos; oldpos = tmp; } else if (v.type == Vertex.TRAIN) { deltapos.X = 0; deltapos.Y = v.mass; deltapos -= 0.05f * (pos - oldpos); tmp = pos; pos += pos - oldpos + deltapos; oldpos = tmp; } else { pos = oldpos; } v.pos = pos; v.oldpos = oldpos; v.deltapos = deltapos; } } [/CODE]
  9. Hi everyone. I am working on a game that uses Verlet integrated physics, and it works pretty well. I got 2 types of objects vertices and edges. The problem is when 2 horizontal edges collide and one of them is static, the other one jumps pretty high. [attachment=11585:path3961-6.png] Is this a common problem? does anyone know how to fix it?
  10. Incremental freedrag

    Does anyone know how to make a incremental freedrag from only using gesture samples in xna? What I mean is if the user makes a drag gesture that is 40px long, the object will move to the left or right. I can't seem to figure it out. xD
  11. Rotational motion to linear motion

    Thanks for all the help everyone, but i did it my way, and it ended up working the way I wanted to.
  12. Easy programming language

    I think Python is really fun to start with, and PyGame is easy to learn. The best about pygame.org is that you can download games that others have made, and take a look at there source code.
  13. Rotational motion to linear motion

    Thanks for the reply, but im still not sure how to achieve this effect. This is my ideas: [attachment=10203:test2.jpg]
  14. Take a look at [url="http://en.wikipedia.org/wiki/Coulomb_law"]http://en.wikipedia.org/wiki/Coulomb_law[/url] (coulomb's law). It is used in [url="http://en.wikipedia.org/wiki/Force-based_layout"]http://en.wikipedia....ce-based_layout[/url] (Force-based graph drawing). You can use coulomb's law between all the particles, and then they will repel each other. More particles will give more tension or pressure.
  15. Hi, like my title says I want to transform rotational motion in to linear motion. In my game I have a circle that spins, and when it collides with something, it shall transform some of that spin in to a linear motion. [attachment=10173:test.jpg] I have tried alot of different things, and I'm out of ideas. Does someone have a solution? And I'm using a verlet integration for physic's if it helps.
  • Advertisement