added upgrades
This commit is contained in:
@@ -14,6 +14,9 @@ let buttonAddRows = null;
|
||||
let buttonUpgradeAI = null;
|
||||
let buttonAddMoreApples = null;
|
||||
let AddMoreApplesPrice = 1;
|
||||
let AddColoumsPrice = 1;
|
||||
let AddRowsPrice = 1;
|
||||
let UpgradeAIPrice = 1;
|
||||
|
||||
function setup() {
|
||||
buttonAddColoums = createButton("Add coloums");
|
||||
@@ -28,11 +31,42 @@ function setup() {
|
||||
grid[i][j] = 0;
|
||||
}
|
||||
}
|
||||
buttonAddColoums.mousePressed(buttonAddColoumsPressed);
|
||||
buttonAddRows.mousePressed(buttonAddRowsPressed);
|
||||
buttonUpgradeAI.mousePressed(buttonUpgradeAIPressed);
|
||||
buttonAddMoreApples.mousePressed(buttonAddMoreApplesPressed);
|
||||
summonSnake();
|
||||
summonApple();
|
||||
drawGrid();
|
||||
}
|
||||
function buttonAddColoumsPressed(){
|
||||
if (eatenApples < AddColoumsPrice) {
|
||||
return;
|
||||
}
|
||||
eatenApples -= AddColoumsPrice;
|
||||
gridColumns++;
|
||||
grid.push([]);
|
||||
for (let i = 0; i < gridRows; i++) {
|
||||
grid[grid.length - 1][i] = 0;
|
||||
}
|
||||
}
|
||||
function buttonAddRowsPressed(){
|
||||
if (eatenApples < AddRowsPrice) {
|
||||
return;
|
||||
}
|
||||
eatenApples -= AddRowsPrice;
|
||||
gridRows++;
|
||||
for (let i = 0; i < gridColumns; i++) {
|
||||
grid[i].push(0);
|
||||
}
|
||||
}
|
||||
function buttonUpgradeAIPressed(){
|
||||
if (eatenApples < UpgradeAIPrice) {
|
||||
return;
|
||||
}
|
||||
eatenApples -= UpgradeAIPrice;
|
||||
AItype = "smart";
|
||||
}
|
||||
|
||||
function buttonAddMoreApplesPressed(){
|
||||
if (eatenApples < AddMoreApplesPrice) {
|
||||
@@ -158,10 +192,13 @@ function draw() {
|
||||
buttonAddMoreApples.html("Add more apples ₴ " + AddMoreApplesPrice);
|
||||
buttonAddMoreApples.position(gridColumns * gridSize + gridSize + _textSize*6, _textSize * 1.5);
|
||||
text("AI: " + AItype, gridColumns * gridSize + gridSize, _textSize * 3);
|
||||
buttonUpgradeAI.html("Upgrade AI ₴ " + UpgradeAIPrice);
|
||||
buttonUpgradeAI.position(gridColumns * gridSize + gridSize + _textSize*6, _textSize * 2.5);
|
||||
text("Coloums: " + gridColumns, gridColumns * gridSize + gridSize, _textSize * 4);
|
||||
buttonAddColoums.html("Add coloums ₴ " + AddColoumsPrice);
|
||||
buttonAddColoums.position(gridColumns * gridSize + gridSize + _textSize*6, _textSize * 3.5);
|
||||
text("Rows: " + gridRows, gridColumns * gridSize + gridSize, _textSize * 5);
|
||||
buttonAddRows.html("Add rows ₴ " + AddRowsPrice);
|
||||
buttonAddRows.position(gridColumns * gridSize + gridSize + _textSize*6, _textSize * 4.5);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user