MetalES / Project-Zelda

Project Zelda, made using Solarus
12 stars 1 forks source link

Re-rework (again) the Tone System script #39

Closed MetalES closed 8 years ago

MetalES commented 8 years ago

This is a good start to get rid of sol.main.load_file("tone_manager")(game) and replace it with require. This is also a good thing because it will allow system such as #18 (Light effect) to be done, once and for all

Also there is a odd situation where, when the script is reloaded during night, the screen becomes dark. So the tone applyer function seems to has some bugs, even if a range of hour has been defined.

MetalES commented 8 years ago

Changelog

->The tone system now use Light effects (Wrightmat's code re-adapted and cleaned) -> The tone system now use a complete different way of applying tone, this is based on RPG Maker's tone calculation (timer that calculate the tone replaced by math calcs)

This is how it works

local d = 60 * 30+ 1

Where d = 60 (an hour in minutes) * 30 (framerate) + 1

This is how it is done in on_draw() This is adapted from RPG Maker XP's code

if not game:is_paused() and not game:is_suspended() then cr = cr ~= tr and (cr * (d - 1) + tr) / d or cr cg = cg ~= tg and (cg * (d - 1) + tg) / d or cg cb = cb ~= tb and (cb * (d - 1) + tb) / d or cb ca = ca ~= ta and (ca * (d - 1) + ta) / d or ca d = d - 1 end

Strangely it fixed a stability bug where there were lags at night

MetalES commented 8 years ago

The final step is to apply the target tone on the current tone when game:set_time(hour, minutes, day) is called

MetalES commented 8 years ago

Finally done