Looping 3 rooms until escape pressed? (solved)

Started by Timosity, Mon 21/07/2003 13:03:45

Previous topic - Next topic

Timosity

Read posts further down, October not July

I have an intro with 3 screens and I want it to continually repeat through them until the escape key is pressed.

I thought this would be really simple using StartCutscene(1); in room 0

then in the 3rd room having

****script here etc*********

NewRoom(0);
EndCutscene();
NewRoom(4);

but that didn't work, cause there is 2 NewRoom() in the same script, I thought It might just skip the script to the EndCutscene, but it still reads the script inbetween without executing it.

Then I thought I would put the EndCutscene() in room 4
The problem then is, when It goes back to room 0 it is already in the cutscene, therefore I get an error.

I can't think of a way around it, I'm sure there's something simple.

otherwise I'll just have to have the intro perform once and have it skipable with the cutscene not repeating.

hope it all makes sense

~Tim

SSH

#1
Here's an idea, probably not the only way:

Don't use the startcuscene stuff, but manually check the ESC key and have it do a NewRoom(4);

EDIT:
Or try having the loop in rooms 1-3 and room 0 is blank and just does the startcutscene and jumps to room 1 before fadein
12

Timosity

#2
I'll try the second one as the first doesn't work, If this is what you meant.

in this function:
function on_key_press(int keycode) {

have something like this
if (keycode==27) {NewRoom(4);}  // escape pressed

It works after I gain control after the cutscene and takes you back to the start at any point in the game, I could have set a global int to stop that, but seeing as it doesn't work there's no point.

The 2nd idea may work it, depends if it still thinks it's in a cutscene in room1, which it is but it's not the room that says startcutscene. I'll try it but don't like the odds.

Thanks SSH for replying so fast

~Tim

Edit: I tried the second way and it doesn't work either, as soon as the escape key is pressed the game just pauses, even the music stops, and I have to escape the game with Alt-X.

I also tried using the startcutscene in 'First time player enters screen'(in room 0) and loop back to room 0, but it did exactly the same thing as when I looped rooms 1-3 with the startcutscene in room 0.

These little seemingly easy things always get me stumped, and I usually figure out things that seem harder on my own, Why is that?? I guess that's what this forum is for

SSH

#3
Quote from: Tìmosíty on Mon 21/07/2003 13:33:03
I'll try the second one as the first doesn't work, If this is what you meant.

in this function:
function on_key_press(int keycode) {

have something like this
if (keycode==27) {NewRoom(4);}  // escape pressed

It works after I gain control after the cutscene and takes you back to the start at any point in the game, I could have set a global int to stop that, but seeing as it doesn't work there's no point.
...or just put
if ((player.room < 4) && (keycode==27)) {NewRoom(4);}

I assume you removed the startcutscene, and so this means that you have a lot of blocking stuff in your cut scene. I would think that ESC should still work between blocking actions, though. The other altenative is to make your action non-blocking. You will need to get rid of your cursor and turn off guis manually, though.

EDIT:
Or maybe you can just go back to your original code and move the endcutscene to before NewRoom(0) and make the newroom 0 conditional:

if (IsKeyPressed(27)==0) {NewRoom(0)};

This might give you a flash of cursor, though: you may be able to work around this by making it invisible until you are REALLY finished the cutscene.

Maybe CJ can add a StartIntroScene, similar to EndCutScene which jumps to a particular global function on ESC/whatever instead of hunting for the EndCutScene?

EDIT2:
Yeah, Tim, this does seem overly complicated!
12

Timosity

The problem there is that the whole scene is constantly blocking, the character is hidden for the whole scene,

room 0 and 1 are just screens with titles that are just on for a waiting period and room 2 is the main intro that runs many animations of objects.

I don't think I could do it non-blocking unless I can do something like this

****script***************
if (GetGlobalInt(90)==0){
ObjectOn(12);
SetObjectView(12,101);
AnimateObject(12,10,5,0);
SetGlobalInt(90,1);
}

if (GetGlobalInt(90)==1){
if (IsObjectAnimating(12)==0){
ObjectOn(11);
SetObjectView(11,101);
AnimateObject(11,0,50,0);
SetGlobalInt(90,2);
}
}

********etc etc*************

I haven't tried this script but I did something similar that worked for a non-blocking period when 2 npc's where performing a range of animations.

I'll give it a go.

Timosity

Quote from: SSH on Mon 21/07/2003 13:58:24
EDIT:
Or maybe you can just go back to your original code and move the endcutscene to before NewRoom(0) and make the newroom 0 conditional:

if (IsKeyPressed(27)==0) {NewRoom(0)};

This might give you a flash of cursor, though: you may be able to work around this by making it invisible until you are REALLY finished the cutscene.


No that's not complicated, that works perfectly, It was a bit confusing but I knew what you meant.

In Room 2, I put this
*****blah blah

EndCutscene();
if (IsKeyPressed(27)==0) {
NewRoom(0);
}
else {
NewRoom(4);
}


having the startcutscene  in room 0 'after fade in' (it probably could go before but I didn't get the cursor flash, not sure. I had all the gui's off and cursor invisible to begin with)

thanks for sticking with me, you kept editing before I got a chance to read them.
Your just too fast.

Thanks heaps for the help

~Tim

Timosity

New post, October

Ok, I thought I had this problem solved, but it seems that it is a tempremental problem, ie sometimes works and sometimes doesn't.

It works better on a faster machine, this is the code at the end of the room before it either loops back to start, or skips the intro

EndCutscene();
if (IsKeyPressed(27)==0) { // if escape key not pressed
NewRoom(1); //go back to intro start
}
else {
NewRoom(4); //skips intro
}

The strange thing is that if escape is pressed, sometimes it goes back to the intro start, but is supposed to skip the intro (which it does do occasionly)

The cutscene is skipable by pressing escape, then it checks to see if the escape key has been pressed, to decide which room to go to. The code seems as though it should work, and it does sometimes, but not all the time.

The scene is also totally blocking, and it only seems not to work if you press escape before the first few 'ObjectOn' and 'Wait' on the first screen, after that it works fine.

I've tried different orders of things and it still ends up with the same problem.

Can anyone think up a fresh idea of how to get around this problem

~Tim

Gilbert

Well I think the reason was that, when the user hits ESC, the engine will not immediately jumps to the place where EndCutscene() was placed. Instead when ESC was pressed, the remaining part of the script will still be processed (otherwise the engine won't be so smart to know where to jump to the end point, especially for cutscenes that span rooms, CJ just explained it in some other thread, I'm too lazy to dig it up) until it reaches the EndCutscene() line, but instead runs in "full speed" (like fast-forwarding), so the user won't notice.

Now it's the deal, since you check whether ESC is still being pressed when the cutscene ends, if that ESC was pressed in an early part of the cutscene and that the computer is not really fast, it's quite possibe that the user had released his finger before EndCutscene() was executed, which is the problem. I think if the key is pressed long enough sure you can detect the key pressed afterwards, but that of course is not a solution.

I just read the description of EndCutscene() from the manual:
QuoteThis function returns 0 if the player watched the cutscene, or 1 if they skipped it.

So it returns 1 if the user pressed ESC to skip a cutscene, which is perfect for what you need, you just change that part to:

int escpresssed = EndCutscene();
if (escpresssed==0) { // if escape key not pressed
NewRoom(1); //go back to intro start
}
else {
NewRoom(4); //skips intro
}

Timosity

Thanks Gilbot,

It works, at first I thought it didn't but then I realised I had to remove the original line EndCutscene for it to work (which does make sense)

Thanks for the help, I'm learning stuff all the time, and things are becoming clearer all the time, eg. for things that return a value like 0 or 1, I'm starting to learn the reasons behind them, and how to utilise them rather than not realising what it actually means.

When I read some peoples questions, and then see a reply 'RTFM', I often feel sorry for the person who is coping it, cause people have so many different levels of understanding, what seems obvious to some isn't to others.

Anyway thanks again for the help.

SMF spam blocked by CleanTalk