Hi,
I'm trying out a few things on the Falling Sand Game @ the below link & cannot figure out how to change the Gravity. @Erel had updated the code with a switch to change the gravity, but I would like to change the gravity according to the output from the TYPE_ACCELEROMETER phone sensor so it will move the objects. Is there a way of changing the gravity incrementally?
I've already got the readings from the accelerometer to get the right direction details, I just need the gravity to change accordingly & it is baffling me.
Any help at all will be well received. Cheers.
I'm trying out a few things on the Falling Sand Game @ the below link & cannot figure out how to change the Gravity. @Erel had updated the code with a switch to change the gravity, but I would like to change the gravity according to the output from the TYPE_ACCELEROMETER phone sensor so it will move the objects. Is there a way of changing the gravity incrementally?
I've already got the readings from the accelerometer to get the right direction details, I just need the gravity to change accordingly & it is baffling me.
Any help at all will be well received. Cheers.
[B4X] [BitmapCreator] Cross platform Falling Sand game
The main challenge here is the performance. All particles are updated if needed and redrawn every cycle. The Particles array stores the state of all "game pixels". A value of 0 means that the pixel is empty. Other values mean that there is a particle on that pixel. Sand particles move down or...
www.b4x.com
Gravity:
Sub btnGravity_Click
Dim btn As B4XView = Sender
GravityDown = Not(GravityDown)
If GravityDown Then
btn.SetRotationAnimated(500, 0)
Else
btn.SetRotationAnimated(500, 180)
End If
ToastMessageShow("RSL: " & RowsState.Length,False)
AllDirty
End Sub
AllDirty:
Private Sub AllDirty
For i = 0 To RowsState.Length - 1
RowsState(i) = 1
Next
End Sub