public void Activate() { magnet0.x = 0.2f; magnet0.y = -0.8f; magnet1.x = 0.4f; magnet1.y = -0.9f; particleSource0.Reset(); particleSource1.Reset(); complete0 = 0; complete1 = 0; }
public void Create() { particleSource0 = new ParticleSource(70, ParticleSource.TYPE_RED, 5, 0.5f, 0.25f); particleSource0.x = -0.0f; particleSource0.y = 0.9f; particleSource0.rot = -3.141f / 2.0f; particleSource0.on = true; particleSource1 = new ParticleSource(70, ParticleSource.TYPE_BLUE, 5, 0.5f, 0.25f); particleSource1.x = -0.8f; particleSource1.y = 0.9f; particleSource1.rot = -3.141f / 2.0f; particleSource1.on = true; magnet0 = new Magnet(Magnet.TYPE_RED, 0.2f, 0.2f, 0.2f); magnet0.x = 0.2f; magnet0.y = -0.8f; magnet1 = new Magnet(Magnet.TYPE_RED, 0.2f, 0.2f, 0.2f); magnet1.x = 0.4f; magnet1.y = -0.9f; detector = new Detector(0.8f, 40); detector.y = -0.8f; detector.x = 0.0f; grid = new Grid(0.2f, 0.2f); complete0 = 0; complete1 = 0; complete2 = 0; }
public void Activate() { magnet0.x = -0.2f; magnet0.y = -0.2f; magnet1.x = 0.2f; magnet1.y = -0.2f; magnet2.x = 0.0f; magnet2.y = 0.2f; particleSource0.Reset(); particleSource1.Reset(); particleSource2.Reset(); complete0 = 0; }
public void Render() { GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); particleSource0.AddField(magnet0); particleSource0.AddField(magnet1); particleSource1.AddField(magnet0); particleSource1.AddField(magnet1); boolean s0 = particleSource0.AddDetector(detector); boolean s1 = particleSource1.AddDetector(detector); int maxScore = 500; int incValue = 20; int decValue = 3; int winThreshold = maxScore - 20; if (s0) complete0 += incValue; else complete0 -= decValue; if (s1) complete1 += incValue; else complete1 -= decValue; if (complete0 < 0) complete0 = 0; if (complete1 < 0) complete1 = 0; if (complete0 > maxScore) complete0 = maxScore; if (complete1 > maxScore) complete1 = maxScore; if (complete0 >= winThreshold && complete1 >= winThreshold) { SharedPreferences userPref = context.getSharedPreferences("userPref", 0); int saveState = userPref.getInt("saveState", 20); if (saveState < windowId + 1) { SharedPreferences.Editor editorPref = userPref.edit(); editorPref.putInt("saveState", windowId + 1); editorPref.commit(); } manager.Activate(windowId + 1); } magnet0.AddSourceCollision(particleSource0); magnet0.AddSourceCollision(particleSource1); magnet1.AddSourceCollision(particleSource0); magnet1.AddSourceCollision(particleSource1); magnet0.AddMagnetCollision(magnet1); magnet1.AddMagnetCollision(magnet0); grid.Render(); particleSource0.RenderSourceSprite(); particleSource1.RenderSourceSprite(); magnet0.Render(); magnet1.Render(); particleSource0.Render(); particleSource1.Render(); detector.Render(); }