G
GerPronouncedGrr
Guest
I'm attempting to generate random character sprites using Kenney's roguelike sprites, but am running into an issue I don't understand. Currently, I have it set up with an object, the character, and a script that draws each element in order at the x and y coordinates of the character object. I'll post both bits of code here:
DrawCharacter()
Colour is set to white because I have a drawGUI event in another object set to draw in black.
objCharacter/Step
So, the behaviour that I get is that, when I click, the debug messages are shown but nothing else happens. I thought maybe I was destroying the previous instance wrong, but if I strip that code out I still get nothing. Previously, I had the sprite generation code in the draw event, but then the character was generating non-stop, impossibly fast, regardless of whether I clicked or not.
DrawCharacter()
Code:
draw_set_color(c_white);
draw_sprite(sprBodies, irandom_range(0, 7), x, y);
draw_sprite(sprFeet, irandom_range(0, 11), x, y);
draw_sprite(sprLegs, irandom_range(0, 7), x, y);
draw_sprite(sprTops, irandom_range(0, 119), x, y);
draw_sprite(sprHair, irandom_range(0, 91), x, y);
draw_sprite(sprHats, irandom_range(0, 35), x, y);
draw_sprite(sprLeft_Hand, irandom_range(0, 69), x, y);
draw_sprite(sprRight_Hand, irandom_range(0, 117), x, y);
objCharacter/Step
Code:
character = instance_find(objCharacter, 1);
if (mouse_check_button_pressed(mb_left))
{
instance_destroy(character);
show_debug_message("Character Destroyed");
instance_create_layer(x, y, "Instances", objCharacter);
DrawCharacter();
show_debug_message("Character Generated");
}