public InfoBody AddVert(float x, float y, Vec2[] vert, float angle, float density, float friction, float restetution, Bitmap image, Object userDate = null) { float max_w = vert[0].X; float max_h = vert[0].Y; for (int i = 0; i < vert.Length; i++) { if (vert[i].X > max_w) { max_w = vert[i].X; } if (vert[i].Y > max_h) { max_h = vert[i].Y; } vert[i].X /= 2; vert[i].Y /= 2; vert[i].X /= metric; vert[i].Y /= metric; } GImage g_image = new GImage(game); g_image.SetImage(image); g_image.SetWidth(max_w); g_image.SetHeight(max_h); BodyDef bDef = new BodyDef(); bDef.Position.Set(x / metric, y / metric); bDef.Angle = angle; PolygonDef pDef = new PolygonDef(); pDef.Restitution = restetution; pDef.Friction = friction; pDef.Density = density; pDef.SetAsBox(max_w / metric / 2, max_h / metric / 2); pDef.Vertices = vert; Body body = world.CreateBody(bDef); body.CreateShape(pDef); body.SetMassFromShapes(); InfoBody info = new InfoBody(); info.image = g_image; info.body = body; info.userDate = userDate; body.SetUserData(info); return(info); }
public ScreenLoading(IGame game) : base(game) { image = new GImage(game); image.SetWidth(100); image.SetHeight(100); image.SetX(200); image.SetY(100); image.SetImage(GameResource.text_lmd); AddElement(image); }
private GImage CreateImage(float x, float y, float width, float height, Bitmap b_img) { GImage img = new GImage(Game); img.SetWidth(width); img.SetHeight(height); img.SetImage(b_img); img.SetX(x); img.SetY(y); AddElement(img); return(img); }
public override void Resume() { imgLMD = new GImage(Game); imgLMD.SetImage(GameResource.text_lmd); imgLMD.SetWidth(50); imgLMD.SetHeight(1); imgLMD.SetX(Game.GetWindowWidth() / 2 + 90); imgLMD.SetY(200); ScaleImg_x = imgLMD.GetWidth(); ScaleImg_y = imgLMD.GetHeight(); AddElement(imgLMD); intent_to_menu = new Intent(Game); intent_to_menu.SetScreenLoading(null); }
public InfoBody AddRect(float x, float y, float w, float h, float angle, float density, float friction, float restetution, Bitmap image, Object userDate = null) { GImage g_image = new GImage(game); g_image.SetImage(image); g_image.SetWidth(w); g_image.SetHeight(h); BodyDef bDef = new BodyDef(); bDef.Position.Set(x / metric, y / metric); bDef.Angle = angle; PolygonDef pDef = new PolygonDef(); pDef.Restitution = restetution; pDef.Friction = friction; pDef.Density = density; pDef.SetAsBox(w / metric / 2, h / metric / 2); Body body = world.CreateBody(bDef); body.CreateShape(pDef); body.SetMassFromShapes(); InfoBody info = new InfoBody(); info.image = g_image; info.body = body; info.userDate = userDate; body.SetUserData(info); return(info); }
public InfoBody AddCircle(float x, float y, float radius, float angle, float density, float friction, float restetution, Bitmap image, Object userDate = null) { GImage g_image = new GImage(game); g_image.SetImage(image); g_image.SetWidth(radius * 2); g_image.SetHeight(radius * 2); BodyDef bDef = new BodyDef(); bDef.Position.Set(x / metric, y / metric); bDef.Angle = angle; CircleDef pDef = new CircleDef(); pDef.Restitution = restetution; pDef.Friction = friction; pDef.Density = density; pDef.Radius = radius / metric; Body body = world.CreateBody(bDef); body.CreateShape(pDef); body.SetMassFromShapes(); InfoBody info = new InfoBody(); info.image = g_image; info.body = body; info.userDate = userDate; body.SetUserData(info); return(info); }
public override void Resume() { // Initialize particle parameters partParams = new GSystemParticles.ParticleParameters[1]; partParams[0] = new GSystemParticles.ParticleParameters() { Type = GSystemParticles.TypeParticle.Circle, Color = Color.DarkTurquoise, TTL = 100, radius = 10 }; // Initialize Physics Game.GetPhysics().Initialize(-1000, -1000, 1000, 1000, 0, 0, false); Game.GetPhysics().GetSolver().onAdd += ScreenGame_onAdd; // Create circles InfoBody foeBody = Game.GetPhysics().AddCircle(Game.GetWindowWidth() / 2, 100, 50, 0, 1f, 1f, 1f, GameResource.circle_3, "I"); myBody = Game.GetPhysics().AddCircle(Game.GetWindowWidth() / 2, Game.GetWindowHeight() - 100, 50, 0, 1f, 1f, 1f, GameResource.circle_1, "FOE"); ballBody = Game.GetPhysics().AddCircle(Game.GetWindowWidth() / 2, Game.GetWindowHeight() / 2 + 40, 30, 0, 1f, 1f, 1f, GameResource.circle_2, "BALL"); LFoe = new LogicFoe(Game, foeBody, ballBody); // Create borders Game.GetPhysics().AddRect(0, Game.GetWindowHeight() / 2, 20, Game.GetWindowHeight(), 0, 0f, 0f, 0f, GameResource.rect_3, "BORDER"); Game.GetPhysics().AddRect(Game.GetWindowWidth() - 15, Game.GetWindowHeight() / 2, 20, Game.GetWindowHeight(), 0, 0f, 0f, 0f, GameResource.rect_3, "BORDER"); // Decor image_line = new GImage(Game); image_line.SetImage(GameResource.rect_1); image_line.SetX(Game.GetWindowWidth() / 2); image_line.SetY(Game.GetWindowHeight() / 2); image_line.SetWidth(Game.GetWindowWidth()); image_line.SetHeight(10); // Create intent to menu Intent intent_to_menu = new Intent(Game); intent_to_menu.SetScreenLoading(null); // Create top panel topPanel = new GTopPanel(Game); topPanel.ClearBalls(); topPanel.onCommand += (cmd) => { switch (cmd) { case GTopPanel.CommandTopPanel.menu: intent_to_menu.screenFrom = this; intent_to_menu.screenTo = new ScreenMenu(Game); intent_to_menu.Start(); break; case GTopPanel.CommandTopPanel.play: IsPause = false; break; case GTopPanel.CommandTopPanel.pause: IsPause = true; break; } }; AddElement(topPanel); }