Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411469 Posts in 69368 Topics- by 58422 Members - Latest Member: daffodil_dev

April 23, 2024, 04:39:39 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Changing Static Background Color
Pages: [1]
Print
Author Topic: Changing Static Background Color  (Read 616 times)
AuntEggma
Level 0
**



View Profile
« on: September 19, 2016, 11:03:31 AM »

This is my first game. I'm working on a small platformer which consists of four static levels.  Each level has either a sun or moon object that moves slowly in a parabola across the width of the screen until it hits the end of the screen, and then moves to the next level.

I am trying to achieve a sort of really basic 'sunset/sunrise' effect where the background changes gradually depending on the position of the oSky (moon/sun) object.  I've been looking at what I have access to and it seems to me that changing the background's intensity is my best bet when it comes to generally 'lightening' or 'darkening' the background.

I can change the saturation to make my sky's colors more intense, and the value to make the background more light/dark.

Since I have a more-or-less static background image, I was wondering what the best way to change how light/dark/intense the background is over time.  Or in my case, not over time, but depending on the position of the oSky object along it's path.

To give more detail, I want to change my background's color properties(intensity) depending on where the oSky object is along its respective path.

If I'm not being clear enough, let me know and I'll find a way to distribute the code I've got so far.
Logged
emptyfortress
Level 0
**



View Profile WWW
« Reply #1 on: September 19, 2016, 11:15:36 AM »

(assuming I understood correctly and you're working with plain backgrounds, not images) You can set the variable background_colour to the colour you want, combining this with the function make_colour_hsv() should get you the effect you want.
Logged
AuntEggma
Level 0
**



View Profile
« Reply #2 on: September 19, 2016, 11:38:21 AM »

(assuming I understood correctly and you're working with plain backgrounds, not images) You can set the variable background_colour to the colour you want, combining this with the function make_colour_hsv() should get you the effect you want.

I have a feeling a solution like this is probably what I'll wind up working with.

I'll use the oSkyObj's step event to change the background color depending on where it is along its path.

I was just wondering if there were any other ways of doing it gradually.
Logged
AuntEggma
Level 0
**



View Profile
« Reply #3 on: September 20, 2016, 12:37:10 PM »

I found a pretty cool answer by asking this elsewhere.  Here's how Hotline Miami did their title screen (which has all the elements of my changing background)

https://youtu.be/Z_WtTC-Kd_E?t=16s

In CREATION CODE of ObjBackground
Code:
dir = 0;
lastbonus = 0;
Bcolor1=$d800cd;   //change this colors to the value you want
Bcolor2=$0100fc;


DRAW EVENT of ObjBackground
Code:
//Adds direction .25
dir+=0.25

//Back color
color2=merge_color(c_white,c_gray,0.30)

//Front color             ,                                                                                                                   ,
color1=merge_color(c_black,merge_color(merge_color(Bcolor1,c_purple,0.5+lengthdir_x(0.5,dir*3.12)),c_fuchsia,0.125+lengthdir_y(0.125,dir*1.73)),0.75+lengthdir_y(0.25,dir*1.73))
draw_rectangle_color(view_xview[0]-60,view_yview[0]-60,view_xview[0]+view_wview[0]+60,view_yview[0]+view_hview[0]+60
Logged
emptyfortress
Level 0
**



View Profile WWW
« Reply #4 on: September 21, 2016, 07:24:02 AM »

Oooh, that's clever.

I also didn't know the GML colour functions had both UK and US English spelling, cool.
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic