Hi, I'm very new to AGS and scripting and I've been slowly working on a little game to learn the ins and outs. I'm almost finished and have hit a bit of a wall: Credits. I want to try and add classic scrolling credits to the game (moreso to learn how to do it), but I don't know where to begin. I've been scouring the forums for a few hours and haven't found anything that could help. The only things showing up are outdated modules that I can't get to work and tweening, which I've tried to use to no avail.
Can anyone help? I'm kinda lost.
Thank you so much in advance.
I just throw it all on a label that is in a GUI and then I tween:
https://github.com/ericoporto/dont-give-up-the-cat/blob/fc2810d9d580f6e1b51742489fa388fbd96cdbd0/dont-give-up-the-cat/Credits.asc#L57
I think the old credits module still works too, but not sure which one you found where...
Thank you! I'll try this as soon as I can tomorrow!
For the module, it was this one
https://www.adventuregamestudio.co.uk/forums/modules-plugins-tools/module-credits-v1-19/msg636573826/#msg636573826
I've seen someone else in the thread mention it working, but I couldn't get it.
I see I posted an alternative code there, unfortunately I am on my phone right now so I can't check it. But afaik it should be working - just copy and paste the header and script in an empty header and script in your project. I don't remember how to use it though since I switched to using GUIs with Tween because it's simple and works well for me.
I completely forgot to check out that alt code, I'll do that too. I decided to hop on the engine and try again with the code from your Github but all I'm getting is a black screen for the room (the only differences are the fonts and sizes).
It's hard to tell anything since you haven't posted your code. But my first thing to suggest would be to check that you are actually calling the function - you can print to the log using System.Log use a Display call or throw a breakpoint in your function, just something to check that the function you wrote the credits stuff that you think you are calling is actually being called.
The way I do it is as eri0o said, putting all the credits in a gui label, and then either using the tween module with GUI.TweenPosition().
Or I do something like this:
StartCutscene(eSkipAnyKey); //make credit scroll skippable with key press
while(gCredits.Y > (0 - gCredits.Height)){ //set credits destination
gCredits.Y -=1; // move credits (increase number to speed up credits)
Wait(1); //increase wait time to slow down credits
}
EndCutscene(); //skipping credits goes to here
I went ahead and wrote a small credits module:
https://drive.google.com/file/d/1-1C-yqWM86pjfXGUwKDhTYol-aKuBYKV/view?usp=sharing
My approach was to give maximum control to the developer, so I made it non-blocking and only return a sprite.
Which means in order to use it, you need a bunch of code.
Here's an example room script showing all its features:
https://drive.google.com/file/d/1-3u8aMBTZnc3HMR1nxXSMyfKdDRkaQfh/view
And what it looks like in-game:
(https://i.imgur.com/NL9sSav.gif)
I want to thank all of you for the swift responses and apologise for taking so long to respond, I found myself without any time to get behind my pc properly.
I've tried all the code you all have sent me, tbh just mostly copied with slight adjustments to names and such, but nothing works. I tried eri0o's suggestion of using System.log and such, and indeed nothing happens (though I can't see anything in the log so I might also have screwed up there). I really don't know what I'm doing wrong.
StartCutscene(eSkipAnyKey);
while(gCredits.Y > (0 - gCredits.Height)){
gCredits.Y -=10;
Wait(1);
}
EndCutscene();
QuitGame(0);
This is Rootbound's code.
function room_FirstLoad()
{
int yellow = Game.GetColorFromRGB(255, 255, 0);
int white = Game.GetColorFromRGB(255, 255, 255);
Credits.SetFont(eFontFont0, 15); // font, line height
Credits.SetColor(white); // default text color
Credits.SetShadow(17, 1, 1); // color, offsetX, offsetY
Credits.SetWidth(200); // total width of credits text
Credits.SetDelay(1, -5); // 1 pixel per frame, 5 pixels per frame when mouse is held down
Credits.AddLine("Made with", eAlignCenter, 0, yellow);
Credits.AddLine("Adventure Game Studio");
Credits.AddSpace();
Credits.AddLine("Special Thanks To", eAlignCenter, 0, yellow); // yellow text
Credits.AddLine("Alice", eAlignLeft);
Credits.AddLine("Bob", eAlignRight, -1); // offset -1: add text to previous line
Credits.AddLine("Charles", eAlignLeft);
Credits.AddLine("Dick", eAlignRight, -1);
Credits.AddLine("Eddie");
Credits.AddSpace(50); // add gap of 50 pixels
Credits.AddLine("THE END");
}
bool credits_running;
function room_Load()
{
}
DynamicSprite* credits; // create pointer
void StartCredits() {
credits_running = true; // set flag for room_RepExec
gCredits.Visible = true; // show GUI
credits = Credits.Tick(); // run first update to get sprite
gCredits.BackgroundGraphic = credits.Graphic; // set GUI background
}
void CreditsEnded() {
gCredits.Visible = false; // hide GUI
credits.Delete(); // clean up
credits_running = false; // reset flag
QuitGame(0); // or go to main menu
}
void DoCredits() {
Credits.Tick(); // advance credits display
if (Credits.Done()) CreditsEnded(); // credits have finished
}
function room_RepExec()
{
if (credits_running) DoCredits();
}
void on_key_press(eKeyCode k) {
if (k == eKeySpace) StartCredits();
}
This is from Khris' module, I don't think I changed anything here but I couldn't get it to work.
void _do_one_call(String call_text) {
credits_call_label.Width = 1920;
credits_call_label.Height = 1080;
credits_call_label.Y = 178;
credits_call_label.X = 0;
credits_call_label.Font = eFontFont0;
System.Log(eLogInfo, "Oh joy I'm dying.", player.Room);
gCredits.Transparency = 100;
credits_call_label.Text = call_text;
gCredits.Visible = true;
gCredits.TweenTransparency(1.0, 0, eEaseInBackTween, eBlockTween);
Wait(SecondsToLoops(4.0));
gCredits.TweenTransparency(1.5, 100, eEaseLinearTween, eBlockTween);
gCredits.Visible = false;
Wait(SecondsToLoops(1.0));
}
String _append_credits(String txt, String call_txt)
{
txt = txt.Append(call_txt);
txt = txt.Append("[[");
return txt;
}
void credits_do_calls()
{
_do_one_call("Created by Érico Porto");
_do_one_call("Music by Jon Paul Sapsford");
_do_one_call("Ghosts, graves and icon by Haloa");
_do_one_call("Gameplay Testing[thanks to[Morgan Willcock,[Heltenjon[and Newwaveburritos");
}
void credits_do_rolling()
{
String txt = "";
txt = _append_credits(txt, "Don't Give Up the Cat");
txt = _append_credits(txt, "");
txt = _append_credits(txt, "Created by Erico Porto");
txt = _append_credits(txt, "Music by Jon Paul Sapsford");
txt = _append_credits(txt, "Ghosts, graves and icon by Haloa");
txt = _append_credits(txt, "Gameplay Testing[thanks to[Morgan Willcock,[Heltenjon[and Newwaveburritos");
txt = _append_credits(txt, "");
txt = _append_credits(txt, "Made in Adventure Game Studio");
txt = _append_credits(txt, "");
txt = _append_credits(txt, "with Tween Module by Edmundito");
txt = _append_credits(txt, "and with Timer and Typed Text modules by Crimson Wizard");
txt = _append_credits(txt, "");
txt = _append_credits(txt, "");
txt = _append_credits(txt, "Using assets");
txt = _append_credits(txt, "");
txt = _append_credits(txt, "Forest trees, stones, flowers and base palette using STRINGSTAR FIELDS by Trixie");
txt = _append_credits(txt, "Clouds using SunnyLand by ansimuz");
txt = _append_credits(txt, "Home using 3D Model House by Lanthanum");
txt = _append_credits(txt, "Save cat animation using kitka by kotnaszynce");
txt = _append_credits(txt, "Smoke using Smoke & Fire Animated Particle by KnoblePersona");
txt = _append_credits(txt, "Title Screen Cat using Camp Cat by Ben");
txt = _append_credits(txt, "");
txt = _append_credits(txt, "Forest crickets and atmosphere using Swamp Environment Audio by LokiF");
txt = _append_credits(txt, "Cat Footsteps using Animal footsteps on dry leaves by melle_teich");
txt = _append_credits(txt, "Cat Jump using Cat jump by FOX2814");
txt = _append_credits(txt, "");
txt = _append_credits(txt, "");
txt = _append_credits(txt, "Thank you for playing it!");
txt = _append_credits(txt, "");
txt = _append_credits(txt, "");
txt = _append_credits(txt, "Made for MAGS theme \"Ghost\"");
txt = _append_credits(txt, "November 2022");
txt = _append_credits(txt, "");
credits_call_label.Font = eFontFont1;
credits_call_label.Height = GetTextHeight(txt, eFontFont1, credits_call_label.Width) + 64;
credits_call_label.Text = txt;
credits_call_label.Y = Screen.Height + 32;
gCredits.Visible = true;
gCredits.Transparency = 0;
credits_call_label.TweenY(40.0, -credits_call_label.Height, eEaseLinearTween, eBlockTween);
gCredits.Visible = false;
}
This is eri0o's code, I didn't change anything here except for the GUI name. Didn't even change the text/credits, I just wanted to see if I could make it work first.
In your game how do you envision showing the credits?
If it's a room you would need to call the function that rolls the credit in the after fade in event - you also have to link it to your room.
In Khris code for instance the credits show if you press the space bad, did you press the space bar?
Also what do you mean no log is showing up? Which AGS are you using? The log panel was added in AGS 3.6.1 so you would have to be running at least that version.
Aha, I'm using 3.6.0. I suppose I should get an update. I also completely missed the spacebar thing, very dumb of me.
Can you make credits go without it being a room specifically? I'm sorry for these possibly stupid questions but I really don't know.
Right now I don't have much vision for the credits, just the "made by x" stuff, maybe a title and an illustration after the credits stop rolling.
For most of the attempts I did indeed try to put it into the 'after fade-in' function, but it never worked.
Hi
@DiggingUpGraves Sorry my code didn't work for you. Did you make sure of the following?
-Your GUI gCredits is set to "visible" when the room is loaded
-Your GUI label containing the credits themselves is also set to visible in its properties pane
-Text is not the same color as the background
-Credits GUI is not blocked by another GUI or room object
If all that is true, I suggest slowing down the speed of movement. Moving 10 pixels per loop is very fast (adds up to 400 pixels per second if your game speed is set at 40). I would try 1 pixel per loop (that is, gCredits.Y -=1) and Wait(2) to see if that changes anything.
Oh my god thank you so much. I feel so stupid not thinking of any of your suggestions. I've finally got it now and I can't thank you enough.
No worries, I've been making games for a while and I still make lots of simple mistakes. After a while you'll get a feel for all the usual places to check when something isn't working right. :)