From ac53887cbcb39bb771af40cebd7c8bb7278046b3 Mon Sep 17 00:00:00 2001 From: shark Date: Fri, 8 Feb 2019 19:08:55 +0000 Subject: [PATCH] add cell death in wbc mode --- src/cancergrowth/CellPanel.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/cancergrowth/CellPanel.java b/src/cancergrowth/CellPanel.java index c868c08..1a38697 100644 --- a/src/cancergrowth/CellPanel.java +++ b/src/cancergrowth/CellPanel.java @@ -32,6 +32,7 @@ public class CellPanel extends javax.swing.JPanel implements ActionListener, Cha private int cycle; private boolean cycledir = true; Player player; + private boolean age = true; ArrayList cells = new ArrayList(100000000); // Limit us at 100,000,000 cells (if we ever get there) @@ -87,8 +88,16 @@ public class CellPanel extends javax.swing.JPanel implements ActionListener, Cha k--; } } + if (age && (cells.size() > 1000 || kill)) { + int y = (int) (Math.random() * (Math.abs(cells.size() - 10)) + 10); + int z = 0; + while (cells.size() > 100 && z < 10) { + cells.remove(y - z); + z ++; + } + } //growing = true; - if(!kill) count ++; // Count how many hours have passed + if(!kill || dontkill) count ++; // Count how many hours have passed super.repaint(); // Redraw the screen so we can see the progress } @@ -107,6 +116,8 @@ public class CellPanel extends javax.swing.JPanel implements ActionListener, Cha int s = 0; int g2 = 0; int m = 0; + int z = 0; + int x = cells.size() - 1; for (int k = x; k >= 0; k--) // Use a loop to draw each cell { @@ -185,6 +196,8 @@ public class CellPanel extends javax.swing.JPanel implements ActionListener, Cha jButton3 = new javax.swing.JButton(); jLabel2 = new javax.swing.JLabel(); + setToolTipText(""); + speed.setMaximum(1000); speed.setMinimum(1); speed.setPaintLabels(true); @@ -248,7 +261,7 @@ public class CellPanel extends javax.swing.JPanel implements ActionListener, Cha .add(speed, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .add(18, 18, 18) + .add(95, 95, 95) .add(jButton3) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 63, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)