SOLVED: Sort-of Day-Night system

Started by Hobbes, Sun 28/10/2018 13:44:50

Previous topic - Next topic

Hobbes

Dear all,

I'm currently working on a prototype to see if I can make a game using a very simplistic day-night system.

My parameters are:


  • The game has a maximum of 30 playable days
  • A day consists of 5 slots: 9-12, 12-15, 15-18 & 19-22
  • Certain actions advance time.

So I'm looking for a number of global variables to run, I think.


  • Global Variable that indicates what Day-part it is (1 out of 5).
  • Global Variable that indicates what Day it is (1 out of 30).

I would then have certain activities you perform add a number to the variable of the day part. As soon as you hit day-part 4, your working day is over. The evening part is freed up for leisure.

So far I'm envisioning a game that mixes the easy job-part of Jones in the Fast Lane with a more narrative-driven part running alongside it. So players have the freedom to choose whether they go to work or not. But within these 30 days they have the time to complete the game or fail.

Next part would also be how to show this in a GUI (what day part it is, what day it is, etc).

Basically at the end of day-part 4, the screen should list a GK1-style "Gabriel decides to head home for the day" and then you'll be transported back to your apartment for day-part 5 regardless.

I'm struggling to come up with the proper integers to run this with in a global script. Since the game would have multiple activities available that advance time, it would need to be run as part of the global script. Would I put it in its own function? Would I update the GUI with the repeated_execute function?

Any help would be greatly appreciated!

Hobbes

I've done it. :)

Maybe not in the most efficient way possible, but two integer variables are counting the day parts & the days.

By reading out the days and tying them to a fictional calendar, I can also print the days of the week by name. Coupled with a calendar that I can hang in the MC's bedroom, I can also host random "Stardew Valley" esque events.

It's all running as simple "if" and "else" statements. Once I figure out how to use custom Functions (creation & calling them) I'll probably shift some of the code into there. :)

Khris

Yes, you need some sort of global AdvanceTime() function. It increases the dayPart variable and updates the GUI accordingly. It also checks if the last part of the day was reached and does whatever needs to happen.

Basically this:
Code: ags
// header
import function AdvanceDay();

// main script
int dayPart = 1;
int day = 1;
String parts[6];

// in game_start
  parts[1] = "morning"; parts[2] = "midday";
  parts[3] = "afternoon"; parts[4] = "evening"; parts[5] = "night";

function AdvanceDay() {
  dayPart += 1;
  if (dayPart == 5) {
    Display("You decide to head home for the day.");
    player.ChangeRoom(...);
  }
  if (dayPart == 6) {
    day++;
    dayPart = 1;
    Display("You decide to go to sleep.");
    Display("It's now day %d.", day);
  }
  lblDay.Text = String.Format("It is %s on day %d/30", parts[dayPart], day);
}

SMF spam blocked by CleanTalk