• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Wierd Graphical issue

boi513

Member
I have an object called character that pulls information from a json file and changes the sprites colors according to what the json file dictates.

Both the player and npc's use the same shader and character object to be created and also pull data from the same json file.

Some how the npc's (!="Player") colors 3 and 4 show as black, while the first two colors render correctly.

All of the the player's colors render as intended.

My code is posted below.

Code:
if global.curr_char = "Player"
{
schemes = ds_map_find_value (global.rmap, "colors");
var _colorlist = ds_map_find_value (global.rmap,"color" + string(color_scheme) +"_1");
for (var i = 0; i < 3; i++)
{
  base_color1[i] = _colorlist[| i];
}
var _colorlist = ds_map_find_value (global.rmap,"color" + string(color_scheme) +"_2");
for (var i = 0; i < 3; i++)
{
  base_color2[i] = _colorlist[| i];
}
var _colorlist = ds_map_find_value (global.rmap,"color" + string(color_scheme) +"_3");
for (var i = 0; i < 3; i++)
{
  base_color3[i] = _colorlist[| i];
}
var _colorlist = ds_map_find_value (global.rmap,"color" + string(color_scheme) +"_4");
for (var i = 0; i < 3; i++)
{
  base_color4[i] = _colorlist[| i];
}}

if global.curr_char != "Player"
{
   var my_color = ds_map_find_value (global.cmap,"scheme")
   var _colorlist = ds_map_find_value (global.rmap,"color" + string(my_color) +"_1");
   for (var i = 0; i < 3; i++)
   base_color1[i] = _colorlist[| i];
   base_color2[i] = _colorlist[| i];
   base_color3[i] = _colorlist[| i];
   base_color4[i] = _colorlist[| i];
}
   
   
//get shader uniforms
uni_colorOut1 = shader_get_uniform (infinite_shader,"colorOut1")
_colorOut1 = [base_color1[0]/255,base_color1[1]/255,base_color1[2]/255,base_color1[3]/255]
uni_colorOut2 = shader_get_uniform (infinite_shader,"colorOut2")
_colorOut2 = [base_color2[0]/255,base_color2[1]/255,base_color2[2]/255,base_color2[3]/255]
uni_colorOut3 = shader_get_uniform (infinite_shader,"colorOut3")
_colorOut3 = [base_color3[0]/255,base_color3[1]/255,base_color3[2]/255,base_color3[3]/255]
uni_colorOut4 = shader_get_uniform (infinite_shader,"colorOut4")
_colorOut4 = [base_color4[0]/255,base_color4[1]/255,base_color4[2]/255,base_color4[3]/255]

   }
First the player is made and then any npc afterward.

This code should be the only difference between them as far as appearance is concerned right now.

The code then takes the data collected from the json file and converts it into color info for the shader.

How is it that colors 3 and 4 of the npc are not showing while colors 3 and 4 of the player do?
 
Hi. I noticed something that seems strange to me. You're using 4 colour channels it seems, because you reference base_colorX[0 to 3]. However, all of your loops end before i == 3.

It also seems that in the != "Player" case, that base_colors 1 through 4 are all the same colour.
 

boi513

Member
I fixed it. Thank you for your help.

As for my loops ending the way they do... I dont know but it works.
 
Top