Monday, October 17, 2016

game maker - Why are the randomly generated numbers not random?


I'm trying to make a game where the damage you deal is rolled by a dice. It all works. However, it keeps on giving the same values in a row so it isn't entirely random


ini_open("Health.ini");

attack = ini_read_real( "Attacks", "Felix", 0);
ini_close();
global.damage=0
repeat(attack){
global.damage=irandom(6)
}


if (global.damage ==0){instance_create_depth(300, 400, 0, obj_numbers0)}
if (global.damage ==1){instance_create_depth(400, 400, 0, obj_numbers1)}

if (global.damage ==2){instance_create_depth(500, 400, 0, obj_numbers2)}
if (global.damage ==3){instance_create_depth(600, 400, 0, obj_numbers3)}
if (global.damage ==4){instance_create_depth(700, 400, 0, obj_numbers4)}
if (global.damage ==5){instance_create_depth(800, 400, 0, obj_numbers5)}
if (global.damage ==6){instance_create_depth(900, 400, 0, obj_numbers6)}

The attack value is 1 because it is only one dice that is used for damage for now. The software I am using is Game Maker Studio 2




No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...