• 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!

Legacy GM How can I gradient on tile background?

M

making_z

Guest
First of all, I'm not programmer. I'm not good at game maker as you.
So, I don't know much about coding.
But I had followed make some making tutorial.
Now, I started making first game by myself.
I want to implement, but not included in tutorial section part.
If possible, I want to use a minimum images.

How can I gradient on tile background?
If you want let me know, would you give me some specific and accurate answer?

Thanks in advance.

I found these link. But I don't know how to use.

https://docs.yoyogames.com/source/d...s/backgrounds/background_create_gradient.html
http://docs.yoyogames.com/source/da...rawing/color and blending/make_color_rgb.html
http://www.yoyogames.com/blog/60
 
Z

ZoiJuan

Guest
As the first link you wrote here, the function is:

Code:
background_create_gradient(w, h, colour1, colour2, kind);
In W you have to write the new width you want for your background. H you write the height.

Colour 1 and colour 2 is the colour you want

Colours in Gamemaker are written like:

Code:
c_red
c_blue
c_yellow
c_orange
The kind is a number between 0 and 5.
0 is Horizontal
1 is Vertical
2 is Rectangular
3 is Ellipse
4 is Double Horizontal
5 is Double Vertical

All is very well explained in the GameMaker docs, just read it https://docs.yoyogames.com/source/d...s/backgrounds/background_create_gradient.html
 
M

making_z

Guest
Thanks for response.
But I already wrote, I don't know how to use it.
I already try to use that linked code, but just make some error.
Maybe I put the code wrong place or use wrong code.
would you give me some specific and accurate answer?
 
A

Aura

Guest
Pffft, what kind of question is that? You've literally asked us to elaborate on the best possible explanation. ^^"

Gags aside, since the function creates a background, you're supposed to call it only once. The Create event would be an ideal place. Store the index it returns in a variable.

Code:
gra_bg = background_create_gradient(640, 480, c_black, c_white, 3);
As the Manual clearly states, the first two arguments are the width and height of the new background. The next two arguments are to be used to define the colours that would create the gradient. The last argument tells which type of gradient would be created.

Since you now have the index of the newly created background, you can easily draw it using the draw_background() function or any other way to display it in the room. If you get any error messages, please post the complete error message and the code you used.
 
M

making_z

Guest
I didn't have intention laughing you.
What do you think? Why I wrote I'm not the programmers?
I can't use only the code. It's already found link by me.
I mean, More specifically how to use menu and code.
 
Z

ZoiJuan

Guest
I didn't have intention laughing you.
What do you think? Why I wrote I'm not the programmers?
I can't use only the code. It's already found link by me.
I mean, More specifically how to use menu and code.
Anyway, we explained you the function. Now use it.

If you are not a programmer is because you dont wanna learn, GML hundred of tutorial series explaining all.
 
M

making_z

Guest
Anyway, we explained you the function. Now use it.

If you are not a programmer is because you dont wanna learn, GML hundred of tutorial series explaining all.
How can have question the person don't want learn?

Nope, I already said "I had followed make some making tutorial." and " I started making first game by myself."
But It's not the tutorial, I couldn't understand.

Free tutorial is not perfect. Some tutorial has commercial part. Even I had finished paid tutorial.
I tried to paste the code in tutorial game.
But nothing change. May I paste wrong place.

One thing's for sure, I couldn't get answer I wanted.
 
Last edited by a moderator:
M

making_z

Guest
I paste the code 'no sprite' object in the room.
At the create event

I try to
gra_bg = background_create_gradient(480, 270, c_black, c_white, 3);
and
background_create_gradient(480, 270, c_black, c_white, 3);
Maybe problem was difference in visible size and full-size, I try to this, too.
background_create_gradient(room_width, room_height, c_black, c_white, 3);
 
Last edited by a moderator:
M

making_z

Guest
Thanks for try to understand me.
But already told, I can't use the documents only .

I paste the code in the create event

background_index[0] = gra_bg;
gra_bg = background_create_gradient(1024, 768, c_black, c_white, 1);
and I got error message
FATAL ERROR in
action number 1
of Create Event
for object object0:

Variable object0.gra_bg(100002, -2147483648) not set before reading it.
at gml_Object_object0_CreateEvent_1 (line 1) - background_index[0] = gra_bg;

and I tried to this, too.
background_index[0] = background_create_gradient(1024, 768, c_black, c_white, 1);
It was nothing change but no error message.
 
Last edited by a moderator:

DanMunchie

Member
At the very least, those two lines need to be the other way around.

gra_bg = background_create_gradient(1024, 768, c_black, c_white, 1);
background_index[0] = gra_bg;

Don't take this the wrong way, but from the above it looks like you need to brush up on some basic programming before diving into details like backgrounds etc.
Start simple and take it from there.
 
M

making_z

Guest
I knew that name.
I told you already some lecture finished.
I didn't wanted leak the file of paid lecturer. (I pulled out many code.)
And YouTube don't teach gradient background.
I searched about gradient and found that my first posted link.
If YouTube has that, I didn't write this discussion and came here.

If you don't have idea specifically let me know, will you forget this discussion?
 
Last edited by a moderator:

TheouAegis

Member
If you create a gradient from black to white, that is grey.

Do you want just a simple gradient to use as a background image or do you want your tiles already placed in the room to have a gradient overlay like a sunset?
 
M

making_z

Guest
I think close to like sunset.
I want change color of tile. Purple to navy.
My plan was change the color gradient of every stage, first stage purple and navy, 2nd stage navy and sky blue, 3rd stage sky blue and green....(whole rainbow)
I mean, bottom to top gradient.

If you know, would you let me know change the stage color, too?
 
Last edited by a moderator:

TheouAegis

Member
Then you draw the gradient to a surface then draw the surface using blend modes. Or you make the gradient yourself, save it as a background, then manually draw the background using blend modes.
 

TheouAegis

Member
You can still do it like that. I'm not sure if you can do it in the BegiN Draw event; but even if you can't, you could have a controller object, place it at the very top of the instance order list, set its depth to whatever the lowest tile layer is minus 1 (so if your lowest tile layer is 99, you'd set its depth to 98; so the backgrounds/tiles will be drawn, then the gradient will be drawn over them (don't forget to reset the blend_mode back), then the rest of the objects will be drawn normally. The only catch to this is there can't be other objects at a depth higher than that, otherwise they'll have the gradient over them too. An object with a depth the same as the controller should still be run after the controller, though.

Alternatively, tell all objects not to draw themselves in the draw event (just put a comment in the draw event) and in Draw End event, put draw_self() or whatever you need to. Then you can just use the normal draw event in your controller without any concerns about depth, because only the controller will do anything in the Draw event and everything else will be in the Draw End event.
 
M

making_z

Guest
You mean, put the tile in the room and the code in tile? By draw event?

Would you more specifically show or explain to me?

I've got link the failed gradient 'gmz' file.
http://file.upload.pe/cNY
 
Last edited by a moderator:
Top