//outlined text overlay
Overlay* CreateOverlayText(int x, int y, int width, FontType font, int color, int bgColor, String text) {
int border = 2;
textOverlay = DynamicSprite.Create(width + border * 2, GetTextHeight(text, font, width) + border * 2);
DrawingSurface* ds = textOverlay.GetDrawingSurface();
ds.Clear(COLOR_TRANSPARENT); // background color
ds.DrawingColor = bgColor;
ds.DrawStringWrapped(border, border, width, font, eAlignLeft, text);
ds.DrawStringWrapped(-border, border, width, font, eAlignLeft, text);
ds.DrawStringWrapped(border, -border, width, font, eAlignLeft, text);
ds.DrawStringWrapped(-border, -border, width, font, eAlignLeft, text);
ds.DrawingColor = color;
ds.DrawStringWrapped(0, 0, width, font, eAlignLeft, text);
ds.Release();
return Overlay.CreateGraphical(x, y, textOverlay.Graphic, true);
}// game starts at 10:00 on day 1
int _minutes = 600;
int _day = 1;
TimeOfDay _timeOfDay = eTODMorning;
void UpdateScreen() {
// tint screen, update label etc.
}
void TimePasses(int minutes) {
_minutes += minutes;
// if end of day was reached
if (_minutes >= 1440) {
_minutes -= 1440;
_day++;
}
TimeOfDay now = ((_minutes + 240) / 360) % 4;
if (now != _timeOfDay) {
_timeOfDay = now;
UpdateScreen();
}
}Quote from: Crimson Wizard on Today at 00:33:49Quote from: GildedSpaceHydra on Today at 00:23:18I can't seem to figure out a way to tint the room background with script. Is there something I'm missing?
AmbientTint is not applied to the background for some reason.
If you want to apply a shading effect to the whole room, including objects and characters in that room, then create a screen-sized GUI, give it certain background color, and assign non-zero transparency.
If you want to apply a shading effect only to the room background, then create a DynamicSprite from the original room background, tint that sprite, and draw onto the room bg. The DynamicSprites and drawing is explained in these articles:
https://adventuregamestudio.github.io/ags-manual/DynamicSprite.html
https://adventuregamestudio.github.io/ags-manual/DrawingSurface.html
EDIT:
Or you may draw a whole new room background for the night time, add it as a second background to your room, and switch when necessary:
https://adventuregamestudio.github.io/ags-manual/Globalfunctions_Room.html#setbackgroundframe
Actually, I think that's the best solution, as then you may also include different lighting, shadows, and other time related changes.
// new module script
// game starts at 10:00 on day 1
int _minutes = 600;
export _minutes;
int _day = 1;
// background tint stuff
DynamicSprite* bgSprite;
DrawingSurface *bgSurface;
void TimePasses(int minutes) {
_minutes += minutes;
// if end of day was reached
if (_minutes >= 1440) {
_minutes -= 1440;
_day++;
}
}
int _frames;
function repeatedly_execute() {
//Display("Repeatedly exceute.");
// display time on label
int hours = _minutes / 60;
int minutes = _minutes % 60;
lblTime.Text = String.Format("%02d:%02d", hours, minutes);
//Display("Displaying time on label.");
// increase by one
_frames++;
//Display("Frame increased.");
// if a minute of IRL time has passed
if (_frames >= GetGameSpeed() * 60) {
_frames -= GetGameSpeed() * 60;
TimePasses(MINUTES_PER_MINUTE); // advance game time
Display("Time passes.");
// display time on label
//int hours = _minutes / 60;
//int minutes = _minutes % 60;
lblTime.Text = String.Format("%02d:%02d", hours, minutes);
//Display("Displaying time on label.");
}
// set Time Of Day
if ((hours >= 4) && (hours <= 9)) {
//TimeOfDay = eTODMorning;
lblTimeOfDay.Text = String.Format("Day %d: Morning", _day);
//Tint characters & objects
SetAmbientTint(64, 64, 0, 50, 75);
//Tint room background
bgSprite = DynamicSprite.CreateFromBackground(GetBackgroundFrame());
bgSprite.Tint(64, 64, 0, 50, 75);
bgSurface = Room.GetDrawingSurfaceForBackground();
bgSurface.DrawImage(0, 0, bgSprite.Graphic);
bgSurface.Release();
bgSprite.Delete();
}
else if ((hours >= 10) && (hours <= 15)) {
//TimeOfDay = eTODMidday;
lblTimeOfDay.Text = String.Format("Day %d: Mid-Day", _day);
//Tint characters & objects
SetAmbientTint(0, 0, 0, 0, 100);
//Tiny room background
bgSprite = DynamicSprite.CreateFromBackground(GetBackgroundFrame());
bgSprite.Tint(0, 0, 0, 0, 100);
bgSurface = Room.GetDrawingSurfaceForBackground();
bgSurface.DrawImage(0, 0, bgSprite.Graphic);
bgSurface.Release();
bgSprite.Delete();
}
else if ((hours >= 16) && (hours <= 21)) {
//TimeOfDay = eTODEvening;
lblTimeOfDay.Text = String.Format("Day %d: Evening", _day);
//Tint characters & objects
SetAmbientTint(0, 0, 128, 50, 75);
//Tint room background
bgSprite = DynamicSprite.CreateFromBackground(GetBackgroundFrame());
bgSprite.Tint(0, 0, 128, 50, 75);
bgSurface = Room.GetDrawingSurfaceForBackground();
bgSurface.DrawImage(0, 0, bgSprite.Graphic);
bgSurface.Release();
bgSprite.Delete();
}
else {
//TimeOfDay = eTODNight;
lblTimeOfDay.Text = String.Format("Day %d: Night", _day);
//Tint characters & objects
SetAmbientTint(0, 0, 128, 75, 50);
//Tint room background
bgSprite = DynamicSprite.CreateFromBackground(GetBackgroundFrame());
bgSprite.Tint(0, 0, 128, 75, 50);
// Now copy it back to the background
bgSurface = Room.GetDrawingSurfaceForBackground();
bgSurface.DrawImage(0, 0, bgSprite.Graphic);
// Clean up
bgSurface.Release();
bgSprite.Delete();
}
}
By continuing to use this site you agree to the use of cookies. Please visit this page to see exactly how we use these.
Page created in 0.072 seconds with 15 queries.