Objects Id connected to draw sprite

T

Two_kings_Games

Guest
Hello everyone. Have a cool person who used pseudo code to help me understand. I'm pretty sure im getting it but something isnt working right and Im not sure. Been reading in on for loops, with statements and ds_list for days. Been on this issue a little long and think it's time to ask for help. Hopefully they'll get back to me soon but I'd like the opinion of the community to.


///obj_controller Draw event//

if (obj_game_controller.state == "Battle"){

draw_rectangle_color(Battel_Bar.Bar_Start,300, Battel_Bar.Bar_End,310,c_white,c_white,c_white,c_white,true)
for (var i = 0; i < ds_list_size(global.Add_ally); i++){
with (ds_list_find_value(global.Add_ally,i)){
draw_sprite(spr_player_icon,0,ix,290)
}
}
}

ok so what I want. When the game state equals battle. draw a rectangle. then for every ally within the ds_list, take their value (the objects id), then with the ds_list_find_value draw a sprite with the objects Id.

This is what I'm getting from that with the code above. But the only problem seems to be that the icon will not be drawn. i thought it may have been the ds_list. But that cant be it. I have a method for testing if the ds_list exist and it works.

So anyone who reads please help me out. I am new to this and Im happy that my friend is using pseudo code to help me start thinking in the way that I need. But I've only ever been stuck for a day at the most before getting it.


at 24 second bottom 2 right corner is what I'm going for
 
T

Two_kings_Games

Guest
well it's all being drawn in the obj_game controller with nothing attached to it. The player and enemies have their own objects. The icon itself is just a sprite and seems to be the only thing not appearing
 
if (obj_game_controller.state == "Battle"){

draw_rectangle_color(Battel_Bar.Bar_Start,300, Battel_Bar.Bar_End,310,c_white,c_white,c_white,c_white,true)
for (var i = 0; i < ds_list_size(global.Add_ally); i++){
with (ds_list_find_value(global.Add_ally,i)){
draw_sprite(spr_player_icon,0,ix,290) <<<< ix? if 'i' is an id being drawn from the list it should be i.x
}
}
}
 
T

Two_kings_Games

Guest
ah my bad. ix is another variable in a create event for the x position.
 
ah my bad. ix is another variable in a create event for the x position.
I realised I read that wrong...my bad!

So....you're reading a ds list with id's on it, and then using that in a with statement. Have you tried doing it so that the calling object draws it instead?


Code:
if (obj_game_controller.state == "Battle")
{

draw_rectangle_color(Battel_Bar.Bar_Start,300, Battel_Bar.Bar_End,310,c_white,c_white,c_white,c_white,true)
for (var i = 0; i < ds_list_size(global.Add_ally); i++)
{
is_id = ds_list_find_value(global.Add_ally, i);
draw_sprite(is_id.spr_player_icon, 0, is_id.ix, 290) // ??
}
}
Not sure if that's correct for how you've implemented things, but I'm trying to have obj_Controller get the sprite info and position from 'is_id' and then just draw it itself within the same event.

A possibility might be that the draw depth for obj_Controller means its drawing the bar over the character images, so by having it draw all of them you wouldn't have that happen...I think, can't say for sure.

EDIT: Draw depth doesn't seem to matter.
Code:
if do_draw
{draw_rectangle(x - 200, y - 200, x + 200, y + 200, false)
with (object10)
{draw_sprite(sprite3, 0, x, y)
}
}
Regardless of which draw event I had this in, or the depth of object10 / the calling object, it still drew the sprites over the rectangle. Perhaps manually drawing sprites ignores draw depth, and instead works on the order in which they are drawn?

But your original code should work the same as above, so what is different?

You say the ds list exists, but have you confirmed it has any content - using ds_list_size to make sure it has any info to begin with?
 
Last edited:
Top