public void rot(int amount) { addnewrow(); translatebackrow(); rotatecounter = 0; rowmovement += amount; rowmovementcheckspike += amount; bow.Play(); Movingcube.cam = cam; Movingcube.LoadFromFile("Cube2.txt"); Transformation_API.Scale(ref Movingcube.L_3D_Pts, 0.2f, 0.2f, 0.2f); _3D_Model tempground2 = (_3D_Model)Ground[rowmovement]; for (int i = 0; i < Movingcube.L_3D_Pts.Count; i++) { CPoint3D_Node temp = (CPoint3D_Node)Movingcube.L_3D_Pts[i]; CPoint3D_Node tempground3 = (CPoint3D_Node)tempground2.L_3D_Pts[i]; temp.X = tempground3.X; temp.Z = tempground3.Z; } Transformation_API.TranslateY(ref Movingcube.L_3D_Pts, -70); Movingcube.clr = Color.Blue; whichground = false; }
private void T_Tick(object sender, EventArgs e) { for (int i = 0; i < Spikes.Count; i++) { _3D_Model tempspike = (_3D_Model)Spikes[i]; CPoint3D_Node tempspikepoint = (CPoint3D_Node)tempspike.L_3D_Pts[3]; if (tempspikepoint.Z < -350) { Spikes.RemoveAt(i); } } CPoint3D_Node checkcube = (CPoint3D_Node)Movingcube.L_3D_Pts[3]; _3D_Model checkcube2 = (_3D_Model)Ground[1]; CPoint3D_Node checkcube22 = (CPoint3D_Node)checkcube2.L_3D_Pts[3]; if (checkcube.Z < checkcube22.Z) { falling = true; } if (spikemove == 15 || spikemove == 30) { for (int i = 0; i < Spikes.Count; i++) { _3D_Model tempspike = (_3D_Model)Spikes[i]; if (tempspike.upordown == false) { Transformation_API.TranslateY(ref tempspike.L_3D_Pts, 30); tempspike.upordown = true; } else if (tempspike.upordown == true) { Transformation_API.TranslateY(ref tempspike.L_3D_Pts, -30); tempspike.upordown = false; } } for (int i = 0; i < Ground.Count; i++) { _3D_Model tempspike = (_3D_Model)Ground[i]; if (tempspike.typeofcube == 2) { if (tempspike.upordown == false) { tempspike.upordown = true; _3D_Model checkhole = (_3D_Model)Ground[rowmovement]; if (checkhole.typeofcube == 2 && checkhole.upordown == true) { crushed = true; } } else if (tempspike.upordown == true) { tempspike.upordown = false; } } } } if (firstclick == true) { if (falling == false && crushed == false) { removeoldrow(); if (clickedrotate == true) { if (rotsided == true) { if (rotatecounter < 5) { Movingcube.Rotat_Aroun_Edge(10, 1, 15); } else { rot(6); rotsided = false; rotsidea = false; clickedrotate = false; rotatecounter = 0; _3D_Model checkhole = (_3D_Model)Ground[rowmovement]; if (checkhole.typeofcube == 1) { falling = true; } else if (checkhole.typeofcube == 2 && checkhole.upordown == true) { crushed = true; } } rotatecounter++; } else if (rotsidea == true) { if (rotatecounter < 5) { Movingcube.Rotat_Aroun_Edge(6, 1, 15); } else { rot(5); rotsided = false; rotsidea = false; clickedrotate = false; rotatecounter = 0; _3D_Model checkhole = (_3D_Model)Ground[rowmovement]; if (checkhole.typeofcube == 1) { falling = true; } else if (checkhole.typeofcube == 2 && checkhole.upordown == true) { crushed = true; } } rotatecounter++; } } } else if (falling == true) { if (fallingcubecounter < 20) { if (fallsound == false) { fall.Play(); fallsound = true; } Transformation_API.TranslateZ(ref Movingcube.L_3D_Pts, -20); } else { fall.Stop(); breaking.Play(); buildandreset(); } fallingcubecounter++; } else if (crushed == true) { if (fallingcubecounter < 20) { if (fallsound == false) { breaking.Play(); fallsound = true; } Transformation_API.Scale(ref Movingcube.L_3D_Pts, (float)0.7, (float)0.7, (float)0.7); } else { breaking.Stop(); buildandreset(); } fallingcubecounter++; } } spikemove++; if (spikemove == 31) { spikemove = 0; } cam.BuildNewSystem(); DrawScene(this.CreateGraphics()); }
public void addnewrow() { if (whichtoadd == false) { int startfgroundx = -75; float startgroundz; _3D_Model tempgr1 = (_3D_Model)Ground[Ground.Count - 3]; CPoint3D_Node tempgr2 = (CPoint3D_Node)tempgr1.L_3D_Pts[1]; startgroundz = tempgr2.Z; startgroundz += 45; _3D_Model cube3 = new _3D_Model(); cube3.cam = cam; cube3.LoadFromFile("Cubewall.txt"); cube3.typeofcube = 3; cube3.upordown = false; Transformation_API.Scale(ref cube3.L_3D_Pts, 0.2f, 0.2f, 0.2f); Transformation_API.TranslateZ(ref cube3.L_3D_Pts, (startgroundz - 10) - 50); Transformation_API.TranslateY(ref cube3.L_3D_Pts, -108); Transformation_API.TranslateX(ref cube3.L_3D_Pts, -163); cube3.Rotat_Aroun_Edge(3, 0, 90); cube3.Rotat_Aroun_Edge(8, 1, 146); cube3.Rotat_Aroun_Edge(7, 0, 12); cube3.clr = Color.DarkRed; Ground.Add(cube3); Random rnd1 = new Random(); chanceornot = rnd1.Next(3); Random rnd2 = new Random(); hole = rnd2.Next(4); for (int i = 0; i < 4; i++) { _3D_Model cube2 = new _3D_Model(); cube2.cam = cam; cube2.LoadFromFile("Cube2.txt"); cube2.upordown = false; Transformation_API.Scale(ref cube2.L_3D_Pts, 0.2f, 0.005f, 0.2f); Transformation_API.TranslateZ(ref cube2.L_3D_Pts, startgroundz); Transformation_API.TranslateY(ref cube2.L_3D_Pts, -100); Transformation_API.TranslateX(ref cube2.L_3D_Pts, startfgroundx); cube2.Rotat_Aroun_Edge(1, 0, 45); bool whichcolor = false; if (chanceornot == 0) { cube2.typeofcube = 0; } else if (chanceornot == 1) { if (hole == i) { cube2.typeofcube = 1; } } else if (chanceornot == 2) { if (hole == i) { cube2.typeofcube = 2; whichcolor = true; CPoint3D_Node forspikess = (CPoint3D_Node)cube2.L_3D_Pts[0]; addspikes(forspikess); } } if (whichcolor == false) { cube2.clr = Color.DarkGray; } else if (whichcolor == true) { cube2.clr = Color.Purple; } startfgroundx += 50; Ground.Add(cube2); } cube3 = new _3D_Model(); cube3.cam = cam; cube3.LoadFromFile("Cubewall.txt"); cube3.typeofcube = 3; cube3.upordown = false; Transformation_API.Scale(ref cube3.L_3D_Pts, 0.2f, 0.2f, 0.2f); Transformation_API.TranslateZ(ref cube3.L_3D_Pts, startgroundz - 10); Transformation_API.TranslateY(ref cube3.L_3D_Pts, -108); Transformation_API.TranslateX(ref cube3.L_3D_Pts, 102); cube3.Rotat_Aroun_Edge(3, 0, 90); cube3.Rotat_Aroun_Edge(8, 0, 45); cube3.clr = Color.DarkRed; Ground.Add(cube3); whichtoadd = true; } else if (whichtoadd == true) { int startfgroundx = -100; float startgroundz; _3D_Model tempgr1 = (_3D_Model)Ground[Ground.Count - 2]; CPoint3D_Node tempgr2 = (CPoint3D_Node)tempgr1.L_3D_Pts[1]; startgroundz = tempgr2.Z; startgroundz += 50; Random rnd1 = new Random(); chanceornot = rnd1.Next(3); Random rnd2 = new Random(); hole = rnd2.Next(5); for (int i = 0; i < 5; i++) { _3D_Model cube2 = new _3D_Model(); cube2.cam = cam; cube2.upordown = false; cube2.LoadFromFile("Cube2.txt"); Transformation_API.Scale(ref cube2.L_3D_Pts, 0.2f, 0.005f, 0.2f); Transformation_API.TranslateZ(ref cube2.L_3D_Pts, startgroundz); Transformation_API.TranslateY(ref cube2.L_3D_Pts, -100); Transformation_API.TranslateX(ref cube2.L_3D_Pts, startfgroundx); cube2.Rotat_Aroun_Edge(1, 0, 45); bool whichcolor = false; if (chanceornot == 0) { cube2.typeofcube = 0; } else if (chanceornot == 1) { if (hole == i) { cube2.typeofcube = 1; } } else if (chanceornot == 2) { if (hole == i) { cube2.typeofcube = 2; whichcolor = true; CPoint3D_Node forspikess = (CPoint3D_Node)cube2.L_3D_Pts[0]; addspikes(forspikess); } } if (whichcolor == false) { cube2.clr = Color.DarkRed; } else if (whichcolor == true) { cube2.clr = Color.Purple; } startfgroundx += 50; Ground.Add(cube2); } whichtoadd = false; } }
public void buildandreset() { XB = 100; YB = 50; cx = 0; cy = 0; Ground.Clear(); Spikes.Clear(); Movingcube = new _3D_Model(); cam = new Camera(); Cube = new _3D_Model(); x.X = 0; x.Y = 0; y.X = 0; y.Y = 0; chanceornot = 0; hole = 0; firstclick = false; whichground = false; whichtoadd = false; dropground = 0; rowmovement = 41; rowmovementcheckspike = 41; clickedrotate = false; rotsided = false; rotsidea = false; falling = false; crushed = false; checkdeath = false; rotatecounter = 0; fallingcubecounter = 0; fallsound = false; spikemove = 0; cx = (this.Width - 185); cy = (this.Height - 150); cam.ceneterX = XB + (cx / 2); cam.ceneterY = YB + (cy / 2); cam.cxScreen = cx; cam.cyScreen = cy; cam.cop.Y += 715; cam.cop.Z -= 360; Cube.cam = cam; Cube.LoadFromFile("Cube.txt"); Cube.clr = Color.White; Transformation_API.Scale(ref Cube.L_3D_Pts, 1.31f, 1f, 4f); float startgroundz = -350; for (int j = 0; j < 30; j++) { float startfgroundx = -75; _3D_Model cube3 = new _3D_Model(); cube3.cam = cam; cube3.LoadFromFile("Cubewall.txt"); cube3.upordown = false; Transformation_API.Scale(ref cube3.L_3D_Pts, 0.2f, 0.2f, 0.2f); cube3.typeofcube = 3; Transformation_API.TranslateZ(ref cube3.L_3D_Pts, startgroundz - (10 + 50)); Transformation_API.TranslateY(ref cube3.L_3D_Pts, -108); Transformation_API.TranslateX(ref cube3.L_3D_Pts, -163); cube3.Rotat_Aroun_Edge(3, 0, 90); cube3.Rotat_Aroun_Edge(8, 1, 146); cube3.Rotat_Aroun_Edge(7, 0, 12); cube3.clr = Color.DarkRed; Ground.Add(cube3); if (j > 10) { Random rnd1 = new Random(); chanceornot = rnd1.Next(3); Random rnd2 = new Random(); hole = rnd2.Next(4); } for (int i = 0; i < 4; i++) { _3D_Model cube2 = new _3D_Model(); cube2.cam = cam; cube2.upordown = false; cube2.LoadFromFile("Cube2.txt"); Transformation_API.Scale(ref cube2.L_3D_Pts, 0.2f, 0.005f, 0.2f); Transformation_API.TranslateZ(ref cube2.L_3D_Pts, startgroundz); Transformation_API.TranslateY(ref cube2.L_3D_Pts, -100); Transformation_API.TranslateX(ref cube2.L_3D_Pts, startfgroundx); cube2.Rotat_Aroun_Edge(1, 0, 45); bool changecolor = false; if (j <= 10) { cube2.typeofcube = 0; } else if (j > 10 && chanceornot == 0) { cube2.typeofcube = 0; } else if (j > 10 && hole == i && chanceornot == 1) { cube2.typeofcube = 1; } else if (j > 10 && hole == i && chanceornot == 2) { cube2.typeofcube = 2; changecolor = true; CPoint3D_Node forspikess = (CPoint3D_Node)cube2.L_3D_Pts[0]; addspikes(forspikess); } if (changecolor == false) { cube2.clr = Color.DarkGray; } else { cube2.clr = Color.Purple; } startfgroundx += 50; Ground.Add(cube2); } cube3 = new _3D_Model(); cube3.cam = cam; cube3.LoadFromFile("Cubewall.txt"); Transformation_API.Scale(ref cube3.L_3D_Pts, 0.2f, 0.2f, 0.2f); cube3.upordown = false; cube3.typeofcube = 3; Transformation_API.TranslateZ(ref cube3.L_3D_Pts, startgroundz - 10); Transformation_API.TranslateY(ref cube3.L_3D_Pts, -108); Transformation_API.TranslateX(ref cube3.L_3D_Pts, 102); cube3.Rotat_Aroun_Edge(3, 0, 90); cube3.Rotat_Aroun_Edge(8, 0, 45); cube3.clr = Color.DarkRed; Ground.Add(cube3); startgroundz += 27; startfgroundx = -100; if (j > 10) { Random rnd1 = new Random(); chanceornot = rnd1.Next(3); Random rnd2 = new Random(); hole = rnd2.Next(5); } for (int i = 0; i < 5; i++) { _3D_Model cube2 = new _3D_Model(); cube2.cam = cam; cube2.LoadFromFile("Cube2.txt"); cube2.upordown = false; Transformation_API.Scale(ref cube2.L_3D_Pts, 0.2f, 0.005f, 0.2f); Transformation_API.TranslateZ(ref cube2.L_3D_Pts, startgroundz); Transformation_API.TranslateY(ref cube2.L_3D_Pts, -100); Transformation_API.TranslateX(ref cube2.L_3D_Pts, startfgroundx); cube2.Rotat_Aroun_Edge(1, 0, 45); bool changecolor = false; if (j <= 10) { cube2.typeofcube = 0; } else if (j > 10 && chanceornot == 0) { cube2.typeofcube = 0; } else if (j > 10 && hole == i && chanceornot == 1) { cube2.typeofcube = 1; } else if (j > 10 && hole == i && chanceornot == 2) { cube2.typeofcube = 2; changecolor = true; CPoint3D_Node forspikess = (CPoint3D_Node)cube2.L_3D_Pts[0]; addspikes(forspikess); } if (changecolor == false) { cube2.clr = cube2.clr = Color.DarkRed; } else { cube2.clr = Color.Purple; } startfgroundx += 50; Ground.Add(cube2); } startgroundz += 30; } Movingcube.cam = cam; Movingcube.LoadFromFile("Cube2.txt"); Movingcube.upordown = false; Transformation_API.Scale(ref Movingcube.L_3D_Pts, 0.2f, 0.2f, 0.2f); _3D_Model tempground = (_3D_Model)Ground[41]; for (int i = 0; i < Movingcube.L_3D_Pts.Count; i++) { CPoint3D_Node temp = (CPoint3D_Node)Movingcube.L_3D_Pts[i]; CPoint3D_Node tempground2 = (CPoint3D_Node)tempground.L_3D_Pts[i]; temp.X = tempground2.X; temp.Z = tempground2.Z; } Transformation_API.TranslateY(ref Movingcube.L_3D_Pts, -70); Movingcube.clr = Color.Blue; cam.BuildNewSystem(); off = new Bitmap(this.ClientSize.Width, this.ClientSize.Height); }