forked from Mirrors/openclonk
clean up moon and star objects
parent
871873b9bc
commit
1cf1e309ea
|
@ -5,7 +5,3 @@ Category=C4D_StaticBack|C4D_Background|C4D_Parallax
|
|||
Width=128
|
||||
Height=128
|
||||
Offset=-64,-64
|
||||
Vertices=1
|
||||
VertexY=0
|
||||
Mass=1
|
||||
StretchGrowth=1
|
||||
|
|
|
@ -1,23 +1,31 @@
|
|||
/*-- Moon --*/
|
||||
/**
|
||||
Moon
|
||||
Moon which are shown in the night sky.
|
||||
*/
|
||||
|
||||
local phase;
|
||||
|
||||
|
||||
protected func Initialize()
|
||||
{
|
||||
var alpha=0;
|
||||
if(GetTime() < 300 || GetTime() > 1140) alpha=255;
|
||||
SetClrModulation(RGBa(255,255,255,alpha));
|
||||
var alpha = 0;
|
||||
var time = FindObject(Find_ID(Environment_Time));
|
||||
if (time && time->IsNight())
|
||||
alpha = 255;
|
||||
SetClrModulation(RGBa(255, 255, 255, alpha));
|
||||
|
||||
SetAction("Be");
|
||||
Update();
|
||||
this["Parallaxity"] = [30,30];
|
||||
this.Parallaxity = [30, 30];
|
||||
return;
|
||||
}
|
||||
|
||||
public func NextMoonPhase()
|
||||
{
|
||||
SetMoonPhase(phase+1);
|
||||
SetMoonPhase(phase + 1);
|
||||
}
|
||||
|
||||
/** @return values from 0..100, depending on the full-ness of the moon */
|
||||
// Return values from 0 to 100, depending on the full-ness of the moon
|
||||
public func GetMoonLightness()
|
||||
{
|
||||
return 100 - Abs(100 * phase / this.ActMap.Be.Length - 50);
|
||||
|
@ -27,43 +35,48 @@ public func GetMoonPhase()
|
|||
{
|
||||
return phase;
|
||||
}
|
||||
public func SetMoonPhase(int iphase)
|
||||
|
||||
public func SetMoonPhase(int to_phase)
|
||||
{
|
||||
phase = iphase % this.ActMap.Be.Length;
|
||||
phase = to_phase % this.ActMap.Be.Length;
|
||||
Update();
|
||||
return;
|
||||
}
|
||||
|
||||
private func Update() {
|
||||
private func Update()
|
||||
{
|
||||
SetPhase(phase);
|
||||
|
||||
var phases = this.ActMap.Be.Length;
|
||||
|
||||
var x = phase - phases/2;
|
||||
var height = LandscapeHeight() / (6 - (x*x)/phases);
|
||||
var width = 100 + phase * (LandscapeWidth()-200) / phases;
|
||||
var x = phase - phases / 2;
|
||||
var height = LandscapeHeight() / (6 - (x * x) / phases);
|
||||
var width = 100 + phase * (LandscapeWidth() - 200) / phases;
|
||||
|
||||
SetPosition(width,height);
|
||||
SetPosition(width, height);
|
||||
return;
|
||||
}
|
||||
|
||||
// only appears during the night
|
||||
// Only appears during the night.
|
||||
public func IsCelestial() { return true; }
|
||||
|
||||
// Not stored by itself because it's created by the time environment
|
||||
func SaveScenarioObject() { return false; }
|
||||
public func SaveScenarioObject() { return false; }
|
||||
|
||||
|
||||
/*-- Properties --*/
|
||||
|
||||
local ActMap = {
|
||||
|
||||
Be = {
|
||||
Prototype = Action,
|
||||
Name = "Be",
|
||||
Procedure = DFA_FLOAT,
|
||||
Length = 8,
|
||||
Delay = 0,
|
||||
X = 0,
|
||||
Y = 0,
|
||||
Wdt = 128,
|
||||
Hgt = 128,
|
||||
NextAction = "Hold"
|
||||
}
|
||||
Be = {
|
||||
Prototype = Action,
|
||||
Name = "Be",
|
||||
Procedure = DFA_FLOAT,
|
||||
Length = 8,
|
||||
Delay = 0,
|
||||
X = 0,
|
||||
Y = 0,
|
||||
Wdt = 128,
|
||||
Hgt = 128,
|
||||
NextAction = "Hold"
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,21 +1,29 @@
|
|||
/*-- Stars --*/
|
||||
/**
|
||||
Stars
|
||||
Stars which are shown in the night sky.
|
||||
*/
|
||||
|
||||
|
||||
protected func Initialize()
|
||||
{
|
||||
var alpha=0;
|
||||
if(GetTime()<300 || GetTime()>1140) alpha=255;
|
||||
var g = RandomX(1,9);
|
||||
if(g > 1) SetGraphics(Format("%d",g));
|
||||
SetClrModulation(RGBa(255,255,255,alpha));
|
||||
var g = RandomX(1, 9);
|
||||
if (g > 1)
|
||||
SetGraphics(Format("%d", g));
|
||||
|
||||
var alpha = 0;
|
||||
var time = FindObject(Find_ID(Environment_Time));
|
||||
if (time && time->IsNight())
|
||||
alpha = 255;
|
||||
SetClrModulation(RGBa(255, 255, 255, alpha));
|
||||
SetObjectBlitMode(GFX_BLIT_Additive);
|
||||
|
||||
var parallax = RandomX(8,12);
|
||||
this["Parallaxity"] = [parallax,parallax];
|
||||
this.Parallaxity = [parallax, parallax];
|
||||
return;
|
||||
}
|
||||
|
||||
// Only appears during the night.
|
||||
public func IsCelestial() { return true; }
|
||||
|
||||
// Not stored by itself because it's created by the time environment
|
||||
// (Also, a million stars in Objects.c would suck)
|
||||
func SaveScenarioObject() { return false; }
|
||||
|
||||
local Name = "Stars";
|
||||
// Not stored by itself because it's created by the time environment.
|
||||
public func SaveScenarioObject() { return false; }
|
||||
|
|
Loading…
Reference in New Issue