Didjynn
Member
Hello everybody, it's me again !
I don't know if I'm crazy, clumsy or stupid but softwares don't stop acting strange with me, so do Game Maker Studio 2.
First let me say something without any link with my bug but I have a "if" with 2 conditions "condition1 = 1 && condition2 = 1 that is not acting like it should in fact it's acting like if I wrote "if condition1 = 1 or condition2 = 1".
I replaced the "&&" with a "or" and now it's acting like if I wrote "&&"... is it me or is it broken sometimes ? (it happens only once but.... strange.)
Ok now I'll speak about my new problem. I generate a map and I use arrays for this. The code below creates 3 arrays : one for each square kind of ground, one for the density and one for the sprite it should use.
Here is the problem : it remembers perfectly the type of ground but reset randomly the density and the sprite to the orinignal state !
I used show_debug_message and the values are good as soon as it is in the "for". The last part of the code, the double for check each array in the same order and... ground type are kept but not the 2 others !
All this code is in the "create" event of the only object I use.
And it's not so random... Don't be affraid there is a lot of code because the more I go to the left on the map, the less there is tress,etc. Much code is just a repetition.
When I told you it's not so random... The more we go to the bottom the less density is equal to 0 (and it can only be equal to 0 if the base value haven't been changed) and the less it uses the "basic" sprite.
Like Lilu would say in the fifth element, "Please, Help".
Thx for your help and your time !
Edit : I don't know why there is 2 attached files to this post, I don't know how to delete them and they are useless since the first pictures already shows everything. Sorry about that
I don't know if I'm crazy, clumsy or stupid but softwares don't stop acting strange with me, so do Game Maker Studio 2.
First let me say something without any link with my bug but I have a "if" with 2 conditions "condition1 = 1 && condition2 = 1 that is not acting like it should in fact it's acting like if I wrote "if condition1 = 1 or condition2 = 1".
I replaced the "&&" with a "or" and now it's acting like if I wrote "&&"... is it me or is it broken sometimes ? (it happens only once but.... strange.)
Ok now I'll speak about my new problem. I generate a map and I use arrays for this. The code below creates 3 arrays : one for each square kind of ground, one for the density and one for the sprite it should use.
Here is the problem : it remembers perfectly the type of ground but reset randomly the density and the sprite to the orinignal state !
I used show_debug_message and the values are good as soon as it is in the "for". The last part of the code, the double for check each array in the same order and... ground type are kept but not the 2 others !
All this code is in the "create" event of the only object I use.
And it's not so random... Don't be affraid there is a lot of code because the more I go to the left on the map, the less there is tress,etc. Much code is just a repetition.
Code:
for(var m = room_width/16; m >= 0; m --) {
for(var n = room_height/16; n >= 0; n --) {
terrain[m, n] = ""
densite[m, n] = 0
carresprite[m, n] = socean
}
}
for (var i = 0; i < room_width/size; i ++) {
for (var j = 0; j < room_height/size; j ++) {
var xpourcent = round(i * 100 /(room_width/16))
var ypourcent = round(j * 100 /(room_height/16))
var pourcent = round(random(100))
var pourcentcomp = round(random(100))
if j = 0 or i = room_width/size or (pourcent > 60 && (terrain[i, j-1] = "ocean" or terrain[i+1, j] = "ocean")){
terrain[i, j] = "ocean"
}else if ypourcent <= pourcent {
//show_debug_message("plutôt au dessus")
if xpourcent > pourcent/3*2 {
if pourcentcomp < 40 {
terrain[i, j] = "foret"//40
}else if pourcentcomp < 40 + 30 {
terrain[i, j] = "foretdense"//30
}else if pourcentcomp < 40 + 30 + 20 {
terrain[i, j] = "foretclairsemée" //20
}else{
terrain[i, j] = "clairiere" //10
}
}else if xpourcent > pourcent/3 {
if pourcentcomp < 40 {
terrain[i, j] = "foret"//40
}else if pourcentcomp < 40 + 15 {
terrain[i, j] = "foretdense"//15
}else if pourcentcomp < 40 + 15 + 25 {
terrain[i, j] = "foretclairsemée" //25
}else{
terrain[i, j] = "clairiere" //20
}
}else{
if pourcentcomp < 50 {
terrain[i, j] = "plaine"
}else if pourcentcomp <= 50 + 20 {
terrain[i, j] = "foretclairsemée"
}else{
terrain[i, j] = "rocher"
}
}
}else{
//show_debug_message("plutôt en dessous")
if xpourcent > pourcent/3*2 {
if pourcentcomp < 30 {
terrain[i, j] = "foret"//40
}else if pourcentcomp < 30 + 35 {
terrain[i, j] = "marais"//30
}else if pourcentcomp < 40 + 30 + 20 {
terrain[i, j] = "plaine" //20
}else{
terrain[i, j] = "foretclairsemée" //10
}
}else if xpourcent > pourcent/3 {
if pourcentcomp < 40 {
terrain[i, j] = "plaine"
}else if pourcentcomp <= 40+30 {
terrain[i, j] = "montagne"
}else{
terrain[i, j] = "rocher"
}
}else{
//show_debug_message("plutôt au milieu")
if pourcentcomp < 40 {
terrain[i, j] = "foret"//40
}else if pourcentcomp < 40 + 15 {
terrain[i, j] = "foretdense"//15
}else if pourcentcomp < 40 + 15 + 25 {
terrain[i, j] = "foretclairsemée" //25
}else{
terrain[i, j] = "clairiere" //20
}
}
show_debug_message(terrain[i, j])
// HERE it just gie a different density and sprite depending of the ground's type
if terrain[i, j] = "ocean" {
carresprite[i, j] = socean
densite[i, j] = .5
}else if terrain[i, j] = "riviere" {
carresprite[i, j] = sriviere
densite[i, j] = .5
}else if terrain[i, j] = "foretclairsemée"{
densite[i, j] = .5
carresprite[i, j] = sforetclairsemee
}else if terrain[i, j] = "foret" {
densite[i, j] = 1
carresprite[i, j] = sforet
}else if terrain[i, j] = "foretdense"{
densite[i, j] = 1.5
carresprite[i, j] = sforetdense
}else if terrain[i, j] = "plaine"{
densite[i, j] = .5
carresprite[i, j] = splaine
}else if terrain[i, j] = "marais"{
if i * 16 < room_width/2 {
terrain[i, j] = "geyser"
densite[i, j] = 1
carresprite[i, j] = sgeyser
}else{
densite[i, j] = 1.5
carresprite[i, j] = smarais
}
}else if terrain[i, j] = "montagne"{
//var rand = round(random(10))
//if rand = 5 souslieu = "grotte"
densite[i, j] = 1.5
carresprite[i, j] = smontagne
}else if terrain[i, j] = "rocher"{
densite[i, j] = 1
carresprite[i, j] = splainerocheuse
}else if terrain[i, j] = "clairiere"{
densite[i, j] = .5
carresprite[i, j] = sclairiere
}else{
show_debug_message("pas de case, pas de sprite")
}
show_debug_message(string(densite[i, j]))
show_debug_message(string(carresprite[i, j]))
if i = rw/2/16 && j = rh/2/16 {
lieu[i, j] = "arbremere"
}else{
lieu[i, j] = ""
}
}
}
}
for (var i = 0; i < room_width/size; i ++) {
for (var j = 0; j < room_height/size; j ++) {
show_debug_message("densite = " + string(densite[i, j]))
show_debug_message(string(carresprite[i, j]))
}
}
When I told you it's not so random... The more we go to the bottom the less density is equal to 0 (and it can only be equal to 0 if the base value haven't been changed) and the less it uses the "basic" sprite.
Like Lilu would say in the fifth element, "Please, Help".
Thx for your help and your time !
Edit : I don't know why there is 2 attached files to this post, I don't know how to delete them and they are useless since the first pictures already shows everything. Sorry about that
Attachments
-
300.8 KB Views: 4
-
161.2 KB Views: 3