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
|
Width=128
|
||||||
Height=128
|
Height=128
|
||||||
Offset=-64,-64
|
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;
|
local phase;
|
||||||
|
|
||||||
|
|
||||||
protected func Initialize()
|
protected func Initialize()
|
||||||
{
|
{
|
||||||
var alpha=0;
|
var alpha = 0;
|
||||||
if(GetTime() < 300 || GetTime() > 1140) alpha=255;
|
var time = FindObject(Find_ID(Environment_Time));
|
||||||
SetClrModulation(RGBa(255,255,255,alpha));
|
if (time && time->IsNight())
|
||||||
|
alpha = 255;
|
||||||
|
SetClrModulation(RGBa(255, 255, 255, alpha));
|
||||||
|
|
||||||
SetAction("Be");
|
SetAction("Be");
|
||||||
Update();
|
Update();
|
||||||
this["Parallaxity"] = [30,30];
|
this.Parallaxity = [30, 30];
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public func NextMoonPhase()
|
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()
|
public func GetMoonLightness()
|
||||||
{
|
{
|
||||||
return 100 - Abs(100 * phase / this.ActMap.Be.Length - 50);
|
return 100 - Abs(100 * phase / this.ActMap.Be.Length - 50);
|
||||||
|
@ -27,43 +35,48 @@ public func GetMoonPhase()
|
||||||
{
|
{
|
||||||
return phase;
|
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();
|
Update();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
private func Update() {
|
private func Update()
|
||||||
|
{
|
||||||
SetPhase(phase);
|
SetPhase(phase);
|
||||||
|
|
||||||
var phases = this.ActMap.Be.Length;
|
var phases = this.ActMap.Be.Length;
|
||||||
|
|
||||||
var x = phase - phases/2;
|
var x = phase - phases / 2;
|
||||||
var height = LandscapeHeight() / (6 - (x*x)/phases);
|
var height = LandscapeHeight() / (6 - (x * x) / phases);
|
||||||
var width = 100 + phase * (LandscapeWidth()-200) / 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; }
|
public func IsCelestial() { return true; }
|
||||||
|
|
||||||
// Not stored by itself because it's created by the time environment
|
// Not stored by itself because it's created by the time environment
|
||||||
func SaveScenarioObject() { return false; }
|
public func SaveScenarioObject() { return false; }
|
||||||
|
|
||||||
|
|
||||||
|
/*-- Properties --*/
|
||||||
|
|
||||||
local ActMap = {
|
local ActMap = {
|
||||||
|
Be = {
|
||||||
Be = {
|
Prototype = Action,
|
||||||
Prototype = Action,
|
Name = "Be",
|
||||||
Name = "Be",
|
Procedure = DFA_FLOAT,
|
||||||
Procedure = DFA_FLOAT,
|
Length = 8,
|
||||||
Length = 8,
|
Delay = 0,
|
||||||
Delay = 0,
|
X = 0,
|
||||||
X = 0,
|
Y = 0,
|
||||||
Y = 0,
|
Wdt = 128,
|
||||||
Wdt = 128,
|
Hgt = 128,
|
||||||
Hgt = 128,
|
NextAction = "Hold"
|
||||||
NextAction = "Hold"
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,21 +1,29 @@
|
||||||
/*-- Stars --*/
|
/**
|
||||||
|
Stars
|
||||||
|
Stars which are shown in the night sky.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
protected func Initialize()
|
protected func Initialize()
|
||||||
{
|
{
|
||||||
var alpha=0;
|
var g = RandomX(1, 9);
|
||||||
if(GetTime()<300 || GetTime()>1140) alpha=255;
|
if (g > 1)
|
||||||
var g = RandomX(1,9);
|
SetGraphics(Format("%d", g));
|
||||||
if(g > 1) SetGraphics(Format("%d",g));
|
|
||||||
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));
|
||||||
SetObjectBlitMode(GFX_BLIT_Additive);
|
SetObjectBlitMode(GFX_BLIT_Additive);
|
||||||
|
|
||||||
var parallax = RandomX(8,12);
|
var parallax = RandomX(8,12);
|
||||||
this["Parallaxity"] = [parallax,parallax];
|
this.Parallaxity = [parallax, parallax];
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only appears during the night.
|
||||||
public func IsCelestial() { return true; }
|
public func IsCelestial() { return true; }
|
||||||
|
|
||||||
// Not stored by itself because it's created by the time environment
|
// Not stored by itself because it's created by the time environment.
|
||||||
// (Also, a million stars in Objects.c would suck)
|
public func SaveScenarioObject() { return false; }
|
||||||
func SaveScenarioObject() { return false; }
|
|
||||||
|
|
||||||
local Name = "Stars";
|
|
||||||
|
|
Loading…
Reference in New Issue