M
Master_of_Balls
Guest
A set of textures and some text underneath them is drawn whenever I enter a room. This worked without a hitch when I was drawing to the application surface, but in this case I'm drawing the surfaces as well, and now the text, which is randomized every time the room is entered, piles up on top of the text which was supposed to be discarded once I left the room previously.
Create event:
Draw event:
Room end event
If I put the code the draws the surface before the code that draws onto the surface then, when I exit and enter the room again, I can see the previous sprites being drawn for a split second before they are replaced with the sprites that are supposed to be drawn in the current room pass, so I'm guessing the same thing that happens to the text also happens to them, except that they all have the same shape and size and so anything underneath them isn't visible, whereas the text and numbers being drawn get visibly scrambled.
Create event:
Code:
//declare surface
surfEjobs = surface_create(720, 480);
(((A whole lot of declaring randomized variables, will post them if you think it helps.
Ex: randImg1 = irandom(2);)))
Code:
//draws 3 characters with randomised features
//side by side on surface
if surface_exists(surfEjobs)
{
image_xscale = 4;
image_yscale = 4;
surface_set_target(surfEjobs);
//draws left composite applicant
draw_sprite_ext(spr_apBody, randImg1, 120, 160, 4, 4, 0, c_white, 1);
draw_sprite_ext(spr_apClothes, randImg2, 120, 160, 4, 4, 0, c_white, 1);
draw_sprite_ext(spr_apHair, randImg3, 120, 160, 4, 4, 0, c_white, 1);
//draws middle composite applicant
draw_sprite_ext(spr_apBody, randImg4, 360, 160, 4, 4, 0, c_white, 1);
draw_sprite_ext(spr_apClothes, randImg5, 360, 160, 4, 4, 0, c_white, 1);
draw_sprite_ext(spr_apHair, randImg6, 360, 160, 4, 4, 0, c_white, 1);
//draws right composite applicant
draw_sprite_ext(spr_apBody, randImg7, 600, 160, 4, 4, 0, c_white, 1);
draw_sprite_ext(spr_apClothes, randImg8, 600, 160, 4, 4, 0, c_white, 1);
draw_sprite_ext(spr_apHair, randImg9, 600, 160, 4, 4, 0, c_white, 1);
//Draws random names roughly below each character image
draw_text(120, 320, string(name[randN1]));
draw_text(360, 320, string(name[randN2]));
draw_text(600, 320, string(name[randN3]));
//Draws random wage demands below character img and name
draw_text(120, 340, "$" + string(randWage1));
draw_text(360, 340, "$" + string(randWage2));
draw_text(600, 340, "$" + string(randWage3));
//Draws random fortiture attribute below each applicant
draw_text(120, 360, "fort:" + string(randFort1));
draw_text(360, 360, "fort:" + string(randFort2));
draw_text(600, 360, "fort:" + string(randFort3));
//Draws random constitution below each applicant
draw_text(120, 380, "const" + string(randConst1));
draw_text(360, 380, "const" + string(randConst2));
draw_text(600, 380, "const" + string(randConst3));
//Draws random charisma below each applicant
draw_text(120, 400, "char" + string(randCha1));
draw_text(360, 400, "char" + string(randCha2));
draw_text(600, 400, "char" + string(randCha3));
surface_reset_target();
draw_clear_alpha(c_aqua, 0);
draw_surface(surfEjobs, 0, 0); //Draws the surface
}
else
{
surfEjobs = surface_create(720, 480);
surface_set_target(surfEjobs);
draw_clear_alpha(c_aqua, 0);
surface_reset_target();
}
Code:
if surface_exists(surfEjobs);
{
surface_free(surfEjobs);
}