K
Kleber_Ferreira
Guest
When the game ends, an object will be instantiated to show a congratulations message and the winner's name with his score.
The code shows no error messages but when this object is instatiated, the variables 'winner' (to hold the player's name after checking who won) and 'winnerPontos' (to hold the winner's score) don't get updated, thus displaying this text: "Congratulations null, you won with 0.
//Create event
//Draw event
draw_self();
draw_set_color(c_white);
draw_set_halign(fa_middle);
draw_set_font(coordinates);
draw_text(x, y, "CONGRATULATIONS!");
draw_set_font(segoeUI);
draw_text(x, y+40, winner + " you won with " + string(winnerPontos));
The code shows no error messages but when this object is instatiated, the variables 'winner' (to hold the player's name after checking who won) and 'winnerPontos' (to hold the winner's score) don't get updated, thus displaying this text: "Congratulations null, you won with 0.
//Create event
GML:
winner = "null";
winnerPontos = 0;
if (obj_student1.pontos > obj_student2.pontos && obj_student3.pontos && obj_student4.pontos && obj_student5.pontos && obj_student6.pontos && obj_student7.pontos && obj_student8.pontos && obj_student9.pontos && obj_student10.pontos) {
winner = global.student1;
winnerPontos = obj_student1.pontos;
} else if (obj_student2.pontos > obj_student1.pontos && obj_student3.pontos && obj_student4.pontos && obj_student5.pontos && obj_student6.pontos && obj_student7.pontos && obj_student8.pontos && obj_student9.pontos && obj_student10.pontos) {
winner = global.student2;
winnerPontos = obj_student2.pontos;
} else if (obj_student3.pontos > obj_student1.pontos && obj_student2.pontos && obj_student4.pontos && obj_student5.pontos && obj_student6.pontos && obj_student7.pontos && obj_student8.pontos && obj_student9.pontos && obj_student10.pontos) {
winner = global.student3;
winnerPontos = obj_student3.pontos;
} else if (obj_student4.pontos > obj_student2.pontos && obj_student3.pontos && obj_student1.pontos && obj_student5.pontos && obj_student6.pontos && obj_student7.pontos && obj_student8.pontos && obj_student9.pontos && obj_student10.pontos) {
winner = global.student4;
winnerPontos = obj_student4.pontos;
} else if (obj_student5.pontos > obj_student2.pontos && obj_student3.pontos && obj_student4.pontos && obj_student1.pontos && obj_student6.pontos && obj_student7.pontos && obj_student8.pontos && obj_student9.pontos && obj_student10.pontos) {
winner = global.student5;
winnerPontos = obj_student5.pontos;
} else if (obj_student6.pontos > obj_student2.pontos && obj_student3.pontos && obj_student4.pontos && obj_student5.pontos && obj_student1.pontos && obj_student7.pontos && obj_student8.pontos && obj_student9.pontos && obj_student10.pontos) {
winner = global.student6;
winnerPontos = obj_student6.pontos;
} else if (obj_student7.pontos > obj_student2.pontos && obj_student3.pontos && obj_student4.pontos && obj_student5.pontos && obj_student6.pontos && obj_student1.pontos && obj_student8.pontos && obj_student9.pontos && obj_student10.pontos) {
winner = global.student7;
winnerPontos = obj_student7.pontos;
} else if (obj_student8.pontos > obj_student2.pontos && obj_student3.pontos && obj_student4.pontos && obj_student5.pontos && obj_student6.pontos && obj_student7.pontos && obj_student1.pontos && obj_student9.pontos && obj_student10.pontos) {
winner = global.student8;
winnerPontos = obj_student8.pontos;
} else if (obj_student9.pontos > obj_student2.pontos && obj_student3.pontos && obj_student4.pontos && obj_student5.pontos && obj_student6.pontos && obj_student7.pontos && obj_student8.pontos && obj_student1.pontos && obj_student10.pontos) {
winner = global.student9;
winnerPontos = obj_student9.pontos;
} else if (obj_student10.pontos > obj_student2.pontos && obj_student3.pontos && obj_student4.pontos && obj_student5.pontos && obj_student6.pontos && obj_student7.pontos && obj_student8.pontos && obj_student9.pontos && obj_student1.pontos) {
winner = global.student10;
winnerPontos = obj_student10.pontos;
}
draw_self();
draw_set_color(c_white);
draw_set_halign(fa_middle);
draw_set_font(coordinates);
draw_text(x, y, "CONGRATULATIONS!");
draw_set_font(segoeUI);
draw_text(x, y+40, winner + " you won with " + string(winnerPontos));