Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Katya's Game Of Death</title>
- <meta charset="UTF-8">
- <meta name ="author" content="TheWonderKat">
- </head>
- <script="text/javascript">
- <!--someone show me how to draw a grid!!!!!!!!!!!!!!-->
- function create2DArray (colms,rows) {
- let arr = new Array(colms);
- for (let i=0;i<arr.length>;i++); {
- arr[i]=new Array(rows);
- }
- return create2DArray;
- }
- let grid;
- let colms =;
- let rows =;
- let resolution =;
- function setup() {
- createCanvas(400,400);
- grid = create2DArray (10,10);
- for(let i=0; i< coms; i++) {
- for(let j= 0;j<rows; j++) {
- grid[i][j] = math.random(2);
- }
- }
- }
- }
- <!--looking through all columns and rows for drawing-->
- function draw() {
- //background(0);
- //not counting the outer edges
- if(i== 0|| i==colms -1|| j==0\\j==)
- next[i][j] = grid[i][j];
- let state grid=grid[i][j];
- //stae and grid are the same color so something is not working
- //rule time
- if(state ==0 && neighbors ==3) {
- next[i][j] = 1;
- } else if(state ==0 && neighbors <23) {
- next[i][j] = 0;
- }else {
- for(let i=0; i< coms; i++) {
- for(let j= 0;j<rows; j++) {
- let x =i *resolution;
- let y =j *resolution;
- if(grid[i][j] ==1) {
- fill(300);
- stroke(0);
- rect(x,y, resolution -1,
- }
- //let nexGeneration = create2DArray (colms,rows);
- //count live neighbors
- //how to make internal loop
- let sum = 0;
- sum += grid[i-1][j]
- sum += grid[i-1][j]
- sum += grid[i-1][j]
- sum += grid[i-1][j]
- sum += grid[i-1][j]
- sum += grid[i-1][j]
- sum += grid[i-1][j]
- sum += grid[i-1][j]
- //change the rules for neighbors
- }
- function countNeighbors(grid,x,y) {
- for(let i= -1;1<2;i++) {
- for(let j=-1; j<2; i++) {
- sum += grid[i][j];
- }
- }
- if(i=x,j=x);
- return(sum);
- else//idk what to do here
- return sum;
- grid = next;
- </script>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement