private void WorldGenForm_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 'w') { selectionY -= 1; } else if (e.KeyChar == 's') { selectionY += 1; } else if (e.KeyChar == 'a') { selectionX -= 1; } else if (e.KeyChar == 'd') { selectionX += 1; } selectionBox.Width = mapScale; selectionBox.Height = mapScale; selectionBox.X = selectionX * mapScale; selectionBox.Y = selectionY * mapScale; PlanetDrawPanel.Invalidate(); //this.drawPlanet(); PlanetDrawPanel.Focus(); }
private void randomizeBtnClick(object sender, EventArgs e) { CreateWorld newPlanet = new CreateWorld(); myPlanet.setTerrain(newPlanet.createMap(myPlanet.getSize())); //this.drawPlanet(); PlanetDrawPanel.Invalidate(); PlanetDrawPanel.Focus(); }
private void nextBtn_Click(object sender, EventArgs e) { if (myPlanet.getName() != "") { textBox1.Hide(); label1.Hide(); PlanetSizeCmbBox.Hide(); label2.Hide(); NextBtn.Enabled = false; CreateWorld newPlanet = new CreateWorld(); this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.WorldGenForm_KeyPress); this.PlanetDrawPanel.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.PlanetDrawPanel_Scroll); this.PlanetDrawPanel.MouseDown += new System.Windows.Forms.MouseEventHandler(this.OnMouseDown); this.PlanetDrawPanel.MouseMove += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove); this.PlanetDrawPanel.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OnMouseUp); PlanetDrawPanel.Paint += new System.Windows.Forms.PaintEventHandler(this.drawPlanet); myPlanet.setTerrain(newPlanet.createMap(myPlanet.getSize())); myPlanet.setMap(newPlanet.getMap()); showingPlanet = true; PlanetDrawPanel.Height = this.Height - 100; PlanetDrawPanel.Width = this.Width - 100; int sizeMod; if (PlanetDrawPanel.Height < PlanetDrawPanel.Width) { sizeMod = PlanetDrawPanel.Height; } else { sizeMod = PlanetDrawPanel.Width; } mapScale = sizeMod / myPlanet.getTerrain().Length; PlanetDrawPanel.Show(); PlanetDrawPanel.Focus(); PlanetDrawPanel.Invalidate(); //drawPlanet(); } }