If touch.IsInitialized = False Then
ShipMotor.MaxMotorForce = 0 'disable the motor
Else
'the touch panel is wider than the game screen so we need to fix the offsets and clip the value to the game screen (ivForeground)
Dim x As Float = Min(ivForeground.Width, Max(0, touch.X - (ivForeground.Left - PanelForTouch.Left)))
Dim v As B2Vec2 = X2.ScreenPointToWorld(X, touch.Y)
ShipMotor.LinearOffset = X2.CreateVec2(v.X, ShipMotor.LinearOffset.Y)
ShipMotor.MaxMotorForce = 50
End If
- It is a bit challenging to model the non-physics game in box2d physics engine. After trying all kinds of things, I've used brute force, literally. The main problem was that the ball started moving up and down or sideways. The solution is to check the horizontal and vertical velocity and apply force if they are too slow.
There is also a check for the total speed and the ball is pushed if it is too slow.
Ball.Body.AngularDamping = 0 '<<<<
Ball.Body.LinearDamping = 0 '<<<<
world.Initialize("world", world.CreateVec2(0, 0))
Weld - holds the bodies at the same orientation
Distance - a point on each body will be kept at a fixed distance apart
Dim distanceDef As B2DistanceJointDef'<<<<
distanceDef.Initialize(Ship.Body, Ball.Body, Ball.Body.WorldCenter, Ball.Body.WorldCenter)'<<<<
distanceDef.DampingRatio = 1'<<<<
distanceDef.FrequencyHz = 0'<<<<
This is all "scary" ? : it seems that everything in that world is questionable ?
I suppose it takes... years to become an expert in this field.
'Ball.Body.ApplyLinearImpulse(X2.CreateVec2(0.25, 0.25), Ball.Body.WorldCenter)
Ball.Body.LinearVelocity = X2.CreateVec2(4, 4)
I've tried it during development and it didn't work better. The ball will still lose some energy.the reason the ball is losing energy is that in such a game where we don't really use any physic it would make more sense to give all bodies friction of 0 and restitution of 1.
when a ball with restitution 0 will fall on the ground it won't bounce back (like a bowling ball) but with restitution of 1, it will bounce back with the same velocity it hits the other body. Friction 0 will help us also to not lose any energy when the ball hits any other body. so I changed all bodies' restitution value to 1 and friction to 0 (in tiled).
I've tried it during development and it didn't work better. The ball will still lose some energy.
= X2.CreateVec2(0, 4)
= X2.CreateVec2(-4, 4)
= X2.CreateVec2(4, 4)
.... can i ask a question... may be will be needed to make it at a different thread (a new one)... but i ll give a try here...
View attachment 114775
This nice backround ... is it possible to be moving like walking-running to the lines ?
actually create an illusion with lines moving or something ?
ps: This is a baby dream had from old days...
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?