Credits for game - slightly different than normal [SOLVED]

Started by NiksterG, Fri 29/06/2007 01:36:27

Previous topic - Next topic

NiksterG

Hi there!

I've finally finished my game so that it is playable. All I want to do now is add a small cutscene at the end that shows the credits. However, I'm not quite sure what to script...

I'm using textual overlays for the actual credits, and there's a scene in the background where there are some people jumping up and down in celebration. Then the screen scrolls over to the right and reveals even more celebrating going on. To make the screen scroll, I used the player character with an invisible view and had him walk to the right. The scrolling works very well, but the characters in the background don't do anything because of a wait command. I wanted to have them jump with the repeatedly_execute_always function, but their jumping function is blocking, so that doesn't work.

Here's the code I have: cPlayer = player character, cTga - cTgc = people jumping

Code: ags

// room script file

#sectionstart room_a  // DO NOT EDIT OR REMOVE THIS LINE
function room_a() {
  // script for Room: Player enters room (before fadein)

  cPlayer.LockView(35); // sets character view to invisible

#sectionend room_a  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart room_b  // DO NOT EDIT OR REMOVE THIS LINE
function room_b() {
  // script for Room: Player enters room (after fadein)

  FadeIn(1);
	Wait(80);
	Overlay* credits1 = Overlay.CreateTextual(80, 120, 160, 3, 65472, "Title goes here");

	cPlayer.Walk(518, 152, eNoBlock, eAnywhere);
	Wait(400);
	credits1.Remove();
}
#sectionend room_b  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart room_c  // DO NOT EDIT OR REMOVE THIS LINE
function room_c() {
  // script for Room: Repeatedly execute

  int i=0;
  while (i<400) {
	  jump(cTga.ID, 125, 145);
	  jump(cTgb.ID, 80, 100);
	  jump(cTgc.ID, 180, 200);
              i++;
  }
}
#sectionend room_c  // DO NOT EDIT OR REMOVE THIS LINE



Code: ags

// global script

function jump(int characterID, int ymin, int ymax) { // characterID jumps from ymax to a height of ymin, then comes back down
  int i = 0;
  while (i<2) {
	if (character[characterID].y <= ymin) {
		while (character[characterID].y < ymax ) {
			character[characterID].y++;
			Wait(1);
		}
	}
	else if (character[characterID].y >= ymax) {
		while (character[characterID].y > ymin) {
			character[characterID].y--;
			Wait(1);
		}
	}
	i++;
	}
}


I will keep trying to come up with my own answer, but any help would be appreciated! Thanks  ;D
Check out my games! (Not all made with AGS)

Gilbert

Try with this (not tested) modification:

Code: ags

// room script file
int jumpdira=0, jumpdirb=0, jumpdirc=0
#sectionstart room_a  // DO NOT EDIT OR REMOVE THIS LINE
function room_a() {
  // script for Room: Player enters room (before fadein)

  cPlayer.LockView(35); // sets character view to invisible

#sectionend room_a  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart room_b  // DO NOT EDIT OR REMOVE THIS LINE
function room_b() {
  // script for Room: Player enters room (after fadein)

  FadeIn(1);
	Wait(80);
	Overlay* credits1 = Overlay.CreateTextual(80, 120, 160, 3, 65472, "Title goes here");

	cPlayer.Walk(518, 152, eNoBlock, eAnywhere);
	Wait(400);
	credits1.Remove();
}
#sectionend room_b  // DO NOT EDIT OR REMOVE THIS LINE



#sectionstart room_c  // DO NOT EDIT OR REMOVE THIS LINE
function room_c() {
  // script for Room: Repeatedly execute
}
#sectionend room_c  // DO NOT EDIT OR REMOVE THIS LINE
//Or better, remove this function from the interaction editor

function repeatedly_execute_always() { //Use 'always' instead
	  jumpdira=jump(cTga.ID, 125, 145, jumpdira);
	  jumpdirb=jump(cTgb.ID, 80, 100, jumpdirb);
	  jumpdirc=jump(cTgc.ID, 180, 200, jumpdirc);
}

function jump(int characterID, int ymin, int ymax, dir) { // characterID jumps from ymax to a height of ymin, then comes back down
	if (dir==0) {
		character[characterID].y++;
		if (character[characterID].y >= ymax) dir=1;
	} else if (dir==1) {
		character[characterID].y--;
		if (character[characterID].y <= ymin) dir=0;
	}
}


(Also, if the jump function is not used by other rooms you can just put it in that room's script; if it is used by some other rooms and you need it in the original form, put the above room-specific "jump" function into the room using some other function name)

NiksterG

I haven't tried your code yet, but just a question: would it actually look like the characters are jumping, or would they suddenly pop to the highest point in their jump and then pop back down? That's what happened everytime I tried to change the coordinates of the people without updating the scene. It looked like the characters were vibrating, rather than jumping.

I found an alternate solution, though: this article gave me the idea. Since Idleviews animate even during Wait commands, this worked out pretty nicely. the player moves (blocking) across the screen, therefore scrolling it. The people in the background bounce. Perfect. Thank you, BFAQ!!! :D
Check out my games! (Not all made with AGS)

SMF spam blocked by CleanTalk