game-physics

Access variable from a different class in a different package?

为君一笑 提交于 2019-12-08 12:07:01
问题 I want to set it so igAS for each igCharacter will be limited by a variable in igMech. Here is what I have first : package igCharacters; import igMech.*; protected class igBrand { public double igAS = .77; } second: package igMech; class igLimits { double aSLimit = 2.5 } 回答1: I think you might want to use the public modifier (although it's quite hard to tell what you mean from your question). You are using default, which is package-private (i.e. not accessible from any class outside the

Simulating two circles bouncing off each other

↘锁芯ラ 提交于 2019-12-08 10:17:58
问题 I have many particles moving around and hit detection to see when they touch. If two particles touch they should bounce off in the opposite direction. particle.moveSelf = function() { var radians = this.angle * Math.PI / 180; var moveX = this.velocity * Math.sin(radians); var moveY = this.velocity * Math.cos(radians); for (var i = 0; i < particles.length; i++) { var distance = this.position.getDistance(new Point(particles[i].position.x, particles[i].position.y)); //if distance < radius 1 +

DirectX Math function confusion

狂风中的少年 提交于 2019-12-08 08:24:24
问题 While I was going over some older DirectX code, I came by the functions D3DXVec3Transform and D3DXVec3TransformCoord. Upon looking up the descriptions for them, they seemed rather similar but I don't see what the difference between the two are. Can someone please explain what is the difference between D3DXVec3Transform and D3DXVec3TransformCoord are, along with the math behind them? 回答1: When you transform a 3D vector by matrix it results in a 4D vector where w!=1 a 3D vector can be described

Multiplayer game - synchronizing ball

折月煮酒 提交于 2019-12-08 07:07:06
问题 I'm developing a very simple game in HTML5 with the amazing phaser.io. The game is very simple: a 1vs1 volley game in 2D... Actually it is 'copy' of the great "pikachu volley"(http://imagenes.es.sftcdn.net/es/scrn/12000/12531/pikachu-volleyball-2.jpg). As I said, the game is very easy, I have: Player1 Player2 Static elements Ball And I have just to control: - Players movements - Ball movements(actually controlled by Arcade Physics) - Players-Ball collisions I made it just for fun, adding the

Water effect “on android” for a 2D game. Where to start?

你离开我真会死。 提交于 2019-12-08 06:28:08
问题 I wanna to add some water effects in my android 2D game to give the impression that objects are under water and the water becomes higher and higher. Is there a way to do this programmatically. May be someone can give me please some code suggestions or can say where can I find something to get started. I like to do things programmatically. One time I saw a fire effect artificial done with code. Is the same possible in the water case ? 回答1: You're going to have write a gl shader for the water

How to fix circles overlap in collision response?

南笙酒味 提交于 2019-12-08 05:48:31
问题 Since in the digital world a real collision almost never happens, we will always have a situation where the "colliding" balls overlap. How to put back balls in situation where they collide perfectly without overlap? I would solve this problem with a posteriori approach (in two dimensions). In short I have to solve this equation for t: Where: is a number that answers to the question: how many frames ago did the collision happen perfectly? is the center of the first ball is the center of the

Bouncing ball in Bullet

大城市里の小女人 提交于 2019-12-08 03:05:48
问题 I have two questions with regards to Bullet, but they are related. In the HelloWorldApp, the objective is to get a ball bouncing on a box right? If I wanted to test a plane, could I just add in a btCollisionObject with a btStaticPlaneShape instead of the box? How can I set custom restitution, static and kinetic friction per object? 回答1: Yes, I believe that should be correct Restitution and friction can be set per object by supplying them to the btRigidBodyConstructionInfo object passed into

How do I make bouncing ball move quicker? dynamic velocity?

喜欢而已 提交于 2019-12-08 01:32:25
问题 So I had a program to move a bouncing ball across the screen using JavaFX now, Now I've tried reformatting certain values under Duration.millis() in my Timeline Animation and the lower I put it the faster the ball goes but, someone has told me that is not the best way to go instead I should ask about dynamic velocity to add to my program here's my code for movement of my ball: public class BallPane extends Pane { public final double radius = 5; public double x = radius, y = radius; public

Unity3D, “knocked away” type light object?

自古美人都是妖i 提交于 2019-12-07 22:19:30
问题 In a Unity scene, imagine a large sliding object (perhaps a "shipping container" or a "sofa" sliding along for some reason) in the way there are a number of 2m tall light wooden sticks lightly stuck in the ground. in real life, the sticks would stand there (to begin with, this is annoyingly hard to achieve in PhysX actually), and when the large object hit them, the large object would be totally unaffected the sticks would be knocked away briskly, probably bounce off the ground once or twice

Make objects inside a group collide with themselves in Phaser.io?

时光总嘲笑我的痴心妄想 提交于 2019-12-07 20:17:55
问题 This question is regarding phaser.io. Can someone show me how to make objects inside a group collide with each other. Right now when i do, //board is the group and it has many elements //Floor is where all the elements fall to game.physics.arcade.collide(this.board, this.floor); All the elements inside the group stack on top of each other when they hit the floor at the same position. In other words the stack builds at one position, the latest one hiding the previous element and not upwards in