Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / background image as sky and day and night cycle

Author
Message
haliop_New
User Banned
Posted: 19th Nov 2014 09:37
im building a platformer and i want to create a sprite or some sprites that will act as the background sky.. also i want to cycle trough night and day time..

im thinking of how i would do it but i guess some of you may already built something similar and any suggestions will be greatly appreciated .

any thoughts ?

thank you for your time , haliop.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 19th Nov 2014 12:39
u can fade in/out with color or alpha.

maybe with sinus 180° = 24 hours
u can multiply with a value for color or alpha channel.
for day use 0 to 1
for night 1- (0 to 1)

means if day is 0.8 night is 0.2 = (1.0 - 0.8)

AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
haliop_New
User Banned
Posted: 19th Nov 2014 17:46
so what i did was kinda simple

left clearcolor to 0,0,0 so its black
added a fixed sprite trought the whole screen called it skyimage
gave it a nice bluish color and created a timer for it.

the timer is set to 1 second , so every 1 second the skyimage is getting darker when it gets to 0 alpha it starts climbing up to 255 according to timer.

Markus , Thank you.
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 19th Nov 2014 23:32
That's what I'd have done. Though I'd use a black sprite instead of clearColor since it's not all that stable on many devices.
For something more advanced you could add on layers of gradients for sunrise and sunset. It might really make it pop. Also, maybe a moon and stars, and different clouds.

haliop_New
User Banned
Posted: 20th Nov 2014 09:00
yeah i added the stars they show up when the alpha color is below 70
however i do expriance some flickering lights so i'll try to add a new black sprite the same size and see how that goes. thank you.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 20th Nov 2014 10:07 Edited at: 20th Nov 2014 10:16
I would personally use the DrawBox command. Attached is a day / night cycle system I just wrote for you as an example. It is just the sky colour for now, it draws a gradient onto an image that is used on a sprite. It would be pretty easy to add stars and clouds in front of this image for a basic sky. All of the colours and speed the day cycles can be adjusted in the init_sky subroutine. Might use it myself some time...


EDIT: For clarity it's only rendering to a 1x4 image which is enough for a nice gradient and super quick

If you want to manually adjust the time set sky.timeFactor to zero and edit sky.time 0.0 is night, 0.5 is midday and 1.0 is night again.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 21st Nov 2014 18:09
I would use several layers, like the sky with a moon and a sun opposite eachother, and some cloud layers. Then I'd just rotate them - so the sun and moon would move across the sky in an arc. With that, you could have a neat lens flare effect, sun rise maybe - as you could work out the sun and moon positions easily with trig. You could also have backdrop layers for hills and mountains, city scape etc. I did this with an iOS game and really like how it turned out, with some layers of backdrop detail and clouds rotating at different rates I think it would look awesome.

I am the one who knocks...
george++
AGK Tool Maker
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 21st Nov 2014 18:39
I think that the "DrawBox" solution is not the ideal solution concerning the speed.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 22nd Nov 2014 14:15
I was around 1200fps with my draw box solution. Is that not fast enough?
george++
AGK Tool Maker
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 22nd Nov 2014 15:06 Edited at: 22nd Nov 2014 15:07
Quote: "Is that not fast enough?"

No!
OK, I am joking.
But the code is a few lines. I suppose this does not apply to real world applications
haliop_New
User Banned
Posted: 23rd Nov 2014 05:51
im using now the drawbox example shown here its pretty damn awesome just had to change the bottom lines from purplish to black or more black then it was before... it works great thank you.

Login to post a reply

Server time is: 2024-11-25 11:23:57
Your offset time is: 2024-11-25 11:23:57