GameDeveloper 1. Task: “9.Persistence pays” Language: C++.
At the start of task at line 5 i get error:
Expected “->”,".","<","[", [\t\r\n\x0C], [A-Z], [_$], or [a-z] but “=” found.
When i was search solution to this bug, i found this task for another language, but error message not appear here.
Hello, @Stas_Bahacheuski and welcome to the Forum!
Here is a topic, where you can post C++ (Cpp) bug reports:
Hello @Stas_Bahacheuski,
Welcome! Would you be willing to provide your code so I can take a look? If it seems to be a real bug I’ll send this to the team to take care of
My code.
[spoiler]// Ты можешь использовать базу данных для хранения постоянных данных.
// Постоянные данные остаются неизменными между запусками игры!
var generator = game.spawnXY(“generator”, 60, 40);
generator.spawnType = “munchkin”;
generator.spawnDelay = 1;
var player = game.spawnPlayerXY(“raider”, 36, 30);
player.maxHealth = 70;
player.attackDamage = 10;
game.addSurviveGoal(8);
// БД означает база данных
// db.add(key, value) увеличивает значение хранимое в базе данных
// Добавляет 1 к ключу “plays” в базе данных
db.add(“plays”, 1);
// Показывает значение ключа “plays” из БД
ui.track(db, “plays”);
ui.track(db, “wins”);
ui.track(db, “total defeated”);
ui.track(game, “time”);
// Показывает значение свойства “defeated” из объекта game.
ui.track(game, “defeated”);
// Код ниже запустится, когда игрок выиграет в игре.
auto onVictory(auto event) {
db.add(“wins”, 1);
// Используй db.add(key, value) для добавление значения из value
// game.defeated в базу данных с ключом “defeated”
db.add (“defeated”, game.defeated);
}
int main() {
game.on("victory", onVictory);
return 0;
}
[/spoiler]
Same bug i have at next task “Game Grove”, where game give to me fully complete code and i need change only Maze form.
I am having the same on this one and the next as well and it is a cascading error because if i delete that line the error goes down
correct default code for persistence pays :
auto onVictory(auto event) {
db.add("wins", 1);
// Use db.add(key, value) to add the value of
// game.defeated to the database with the key "total defeated"
}
int main() {
auto generator = game.spawnXY("generator", 60, 40);
generator.spawnType = "munchkin";
generator.spawnDelay = 1;
auto player = game.spawnPlayerXY("raider", 36, 30);
player.maxHealth = 70;
player.attackDamage = 10;
game.addSurviveGoal(8);
// db stands for database
// db.add(key, value) increments a value stored in the database.
// This adds 1 to the "plays" key in the database.
db.add("plays", 1);
// Show the value of the "plays" and other keys in the db
ui.track(db, "plays");
ui.track(db, "wins");
ui.track(db, "total defeated");
ui.track(game, "time");
// Show the value of the "defeated" property of the game object
// The code below will run when the player wins the game.
game.on("victory", onVictory);
return 0;
}
explanation here: Ошибка на уровне "Игровая Роща"