private void MouseManage() { sideMenuEtMouseFollowUp = sideMenu && mouseFollowUp; structureHover = selectedStructure != null && newState.X >= 0 && newState.X < windowSizeX && newState.Y >= 0 && newState.Y < windowSizeY; statePressed = newState.LeftButton == ButtonState.Pressed && oldState.LeftButton == ButtonState.Released && this.IsActive; if (statePressed) { if (structureHover) { if (newState.X < windowSizeX && newState.Y < windowSizeY) { for (int y = 0; y < selectedStructure.getHeight(arrowDirection); y++) { for (int x = 0; x < selectedStructure.getWidth(arrowDirection); x++) { if (selectedStructure.getValue(arrowDirection, x, y, structureFlipped) > 0) { JeuDeLaVieTable.setLife(x + newState.X - selectedStructure.getWidth(arrowDirection) / 2, y + newState.Y - selectedStructure.getHeight(arrowDirection) / 2, (byte)selectedStructure.getValue(arrowDirection, x, y, structureFlipped)); } } } } } if (sideMenuEtMouseFollowUp) { bool foundSomething = false; if (newState.X >= windowSizeXPlus12 && newState.Y >= menuHeightMinus30 && newState.X < windowSizeXPlus37 && newState.Y < menuHeightMinus5) { foundSomething = true; arrowDirection += 1; if (arrowDirection >= 4) { arrowDirection = 0; } generateStructureTexture(); generateArrowTexture(); } for (int y = 0, yCord = 0; !foundSomething && y < structureMgr.StructureTemplates.Count; y++, yCord += 22) { if (newState.X >= windowSizeXPlus6 && newState.Y >= menuHeight + yCord && newState.X < windowSizeXPlus46 && newState.Y < menuHeight + yCord + 22) { foundSomething = true; selectedStructure = structureMgr.StructureTemplates[y]; indexSelectedStructure = y; generateStructureTexture(); generateMenuTexture(); } } } } }
static void Main(string[] args) { JeuDeLaVieTable leJeu = new JeuDeLaVieTable(); Console.WriteLine(); Console.SetWindowSize(200, 50); while (true) { string affichageBuffer = leJeu.ToString(); Console.SetCursorPosition(0, 0); Console.Write(affichageBuffer); leJeu.cycleSuivant(); Thread.Sleep(50); } }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); tableTexture = new Texture2D(GraphicsDevice, windowSizeX, windowSizeY); plusButtonTexture = Content.Load <Texture2D>("Textures/plus"); minusButtonTexture = Content.Load <Texture2D>("Textures/minus"); blackRectangle = new Texture2D(GraphicsDevice, 1, 1); blackRectangle.SetData(new[] { Color.Black }); font = Content.Load <SpriteFont>("daFont"); JeuDeLaVieTable.GenerateNew(tailleX: windowSizeX, tailleY: windowSizeY); generateMenuTexture(); generateArrowTexture(); }
protected override void Update(GameTime gameTime) { base.Update(gameTime); if (JeuDeLaVieTable.Stale) { JeuDeLaVieTable.GenerateNew(tailleX: windowSizeX, tailleY: windowSizeY); } //discard over the physical cap frames if (!FpsCounter.availableFrameT) { this.SuppressDraw(); } else { tableTexture.SetData(JeuDeLaVieTable.DonneeTables); } thread1 = new Thread(JeuDeLaVieTable.CalculerCycle) { Priority = ThreadPriority.Highest }; oldState = newState; newState = Mouse.GetState(); KeyManage(); DrawThread(); thread1.Start(); FpsCounter.Add((float)gameTime.ElapsedGameTime.TotalSeconds); thread1.Join(); MouseManage(); }