GMS 2 [SOLVED]Problem with drawing ONCE

Hey everyone!

I'm making a food service game, mostly to learn game maker, but I've ran into a problem:

I'm drawing the ingredients on 3 different spots (Left, Middle, Right) and for this I'm using a ds_list containing the current ingredient and a switch to draw them. When the ingredients are drawn, they stay on spot to know what the player is currently cooking.

Since it's now working, I want to upgrade it to draw sprites with random values (choose different kind of the same ingredient, draw them with a rotation) to make the game more visually appealing.

Problem is, since the sprites are constantly re-drawing themselves, I can't put any change to it, because if for example I input rotation, it will spit indefinitely.

Here's the code for the Left spot (similar to the construction of the other):

cookL[1] = ds_list_find_value(global.cooking_L, 0)
cookL[2] = ds_list_find_value(global.cooking_L, 1)
cookL[3] = ds_list_find_value(global.cooking_L, 2)
cookL[4] = ds_list_find_value(global.cooking_L, 3)
cookL[5] = ds_list_find_value(global.cooking_L, 4)

switch cookL[1]{
case "Cheese": draw_sprite_ext(ingr_cheese,0,spot1.x, spot1.y,1,1,1,c_white,1); break;
case "Bun" :   draw_sprite(ingr_bun_bun,0,spot1.x, spot1.y); break;
case "Meat":  draw_sprite(ingr_meat,0,spot1.x, spot1.y); break;
case "Vegetables": draw_sprite(ingr_vegetable,0,spot1.x, spot1.y); break;
case "Sauce": draw_sprite(ingr_sauce_sauce ,0,spot1.x, spot1.y); break;

switch cookL[2]{
case "Cheese": draw_sprite(ingr_cheese,0,spot1.x, spot1.y -10); break;
case "Bun" :   draw_sprite(ingr_bun_bun,0,spot1.x, spot1.y -10); break;
case "Meat":  draw_sprite(ingr_meat,0,spot1.x, spot1.y -10); break;
case "Vegetables": draw_sprite(ingr_vegetable,0,spot1.x, spot1.y -10); break;
case "Sauce": draw_sprite(ingr_sauce_sauce ,0,spot1.x, spot1.y -10); break;

switch cookL[3]{
case "Cheese": draw_sprite(ingr_cheese,0,spot1.x, spot1.y-20); break;
case "Bun" :   draw_sprite(ingr_bun_bun,0,spot1.x, spot1.y-20); break;
case "Meat":  draw_sprite(ingr_meat,0,spot1.x, spot1.y-20); break;
case "Vegetables": draw_sprite(ingr_vegetable,0,spot1.x, spot1.y-20); break;
case "Sauce": draw_sprite(ingr_sauce_sauce ,0,spot1.x, spot1.y-20); break;

switch cookL[4]{
case "Cheese": draw_sprite(ingr_cheese,0,spot1.x, spot1.y-30); break;
case "Bun" :   draw_sprite(ingr_bun_bun,0,spot1.x, spot1.y-30); break;
case "Meat":  draw_sprite(ingr_meat,0,spot1.x, spot1.y-30); break;
case "Vegetables": draw_sprite(ingr_vegetable,0,spot1.x, spot1.y-30); break;
case "Sauce": draw_sprite(ingr_sauce_sauce ,0,spot1.x, spot1.y-30); break;

switch cookL[5]{
case "Cheese": draw_sprite(ingr_cheese,0,spot1.x, spot1.y-40); break;
case "Bun" :   draw_sprite(ingr_bun_bun,0,spot1.x, spot1.y-40); break;
case "Meat":  draw_sprite(ingr_meat,0,spot1.x, spot1.y-40); break;
case "Vegetables": draw_sprite(ingr_vegetable,0,spot1.x, spot1.y-40); break;
case "Sauce": draw_sprite(ingr_sauce_sauce ,0,spot1.x, spot1.y-40); break;

TL;DR: I want the sprites to be drawn only once, yet update when there's a change

-I've tried changing the "Switch" into simple "If" statement,
-I've tried adding a variable saying that this ingredient is always drawn, but it draws then disappears
-I've tried putting the draw event into a script, but I can't get my head around it somehow

I did a bit of research and it seems like Surfaces, which I don't fully understand, could suit my needs very well, but I really don't know how to proceed in this particular case.

Any clue?

Thanks in advance.

Simon Gust

Drawing once is not possible, you have to do it every step.
But that doesn't mean you can't make a variable for every ingredient that controls it's rotation.
Another array maybe

cookR[1] = irandom(360);
cookR[2] = irandom(360);
cookR[3] = irandom(360);
cookR[4] = irandom(360);
cookR[5] = irandom(360);
use cookR 1 to 5 for rotation for the draw_sprite_ext functions.
Everytime you do something with an ingredient, also change it's cookR array entry.
I get what you're thinking and that's already a step, but I still can't understand where and how I should do the randomization :confused:

I can't think straight on this problem somehow
OOOh yeah I get it now and it appear to be working :)

I'm shuffling them when sending/trashing the order, so that the next time a layer appears, it has new random values!

Thanks a lot Simon, I've been struggling on this (more like smashing my head against the wall) since the beginning of the project.