Template for scrolling with out player .

Started by Candle, Tue 05/07/2005 23:44:32

Previous topic - Next topic

Candle

Anyone have one that I could see how it is done ?
Want to scroll in long rooms but won't have a player char in the room .

Scummbuddy

just make sure "hide player character is ticked in the room settings area, and then I have this:
Code: ags


int ypos = 0;

while (ypos < 875) 
{
  SetViewport(0,ypos);
  Wait(1);
  ypos++;
}

int xpos = 0;

while (xpos < 986)
{
  SetViewport(xpos, 875);
  Wait(1);
  xpos++;
}


character[EGO].ChangeRoom(1, 120, 140);


which will scroll down a long ways, and then when thats done, it will scroll to the right some, and then change rooms.
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

Candle

Do I need the change rooms part ? I have hotspots and such for going to new rooms .
And where does that code go ?

Scummbuddy

no, you dont need the new room code. and this bit of code went in my rooms interaction window->rep. exec. -> run script you may need to taylor the numbers. i doubt your room is, say, 1200 pixels high/long and 900 pixels wide.
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

Candle

What is this part  rooms interaction window->rep. exec. -> run script I don't see that part ?is that the full name ?
My room is 800x480 .

Scummbuddy

First, I'm sorry. I was wrong. I put it in my "Player enters screen (after fadein)" which is one of the many selectables underneath the "Room" tree, within the Interaction Editor. When under "Player enters screen (after fadein) you select "Run Script", and then right below it a button appears stating "Edit script", then you click on that, and then thats where the code goes.
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

Candle

Ok I had put it there but when the room opens it likes it is doing a loop and the watch says up and the gui is grayed out and have to do a alt x and kill it to get out?
What I have .
Code: ags

  // script for room: Player enters screen (after fadein)
int ypos = 0;

while (ypos < 480)
{
  SetViewport(0,ypos);
  Wait(1);
  ypos++;
}

int xpos = 0;

while (xpos < 800)
{
  SetViewport(xpos, 800);
  Wait(1);
  xpos++;
}  


Room is 800x480

Scummbuddy

it shouldn't loop, but since you didnt put in the part about going to a new room, then it should just stay there, and if you want the gui not gray, but still disabled, then you need to change the setting on the game options page (the first page that pops up when ags opens)
and then in the first part of that room go to "Player enters room (before fadein) and do another run script, and do something like this:

gStatusline.Visible = false;
gIconbar.Visible = false;

mouse.Visible = false;  // works like the old HideMouseCursor

=============

and I see that you put the exact bounds of your bg into the equations I gave you earlier, but that will just add time to how long it takes, take off at least 50 pixels in both so that it "reaches" that bound faster.
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

Candle

Ummm maybe we are not on the same track here ?
What does this script do .
I want to be able to move in the room from left to right with out a player in the room so they can click on things etc and have Interaction in the room with out a player walking around like a myst type
game .

Scummbuddy

ahh, okay, im sorry. well, okay, at least you have the "hide player character" down. ok, well you will need to, in rep.exec. to check the screen coordinates to see if the mouse cursor is close, such as within 15 pixels to either side, and if so, then scroll the room over.

I haven't seen code for this myself, but that may give you some ideas to get you on your way.
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

Candle

Ya thats kind why I wanted to see a template so I knew how to how to do it .
Maybe someone has one or knows how to do it .

Candle

#11
What do you think of this . Say i make a small ball or orb type thing that could move around the room
Like it was floating and it could give out light when needed etc ?
Something like one of these maybe
http://www.humorcafe.com/artwork/orbs.jpg

BorisZ

Quote from: Candle on Wed 06/07/2005 01:53:00
Ya thats kind why I wanted to see a template so I knew how to how to do it .
Maybe someone has one or knows how to do it .

Well,  for start you can make invisible character follow mouse cursor (on rep.exec). That way your room will scroll with cursor.
If it doesn't suit you, you can try working with wievports, but it may be tricky.

Candle

Quote from: BorisZ on Wed 06/07/2005 22:23:37
Quote from: Candle on Wed 06/07/2005 01:53:00
Ya thats kind why I wanted to see a template so I knew how to how to do it .
Maybe someone has one or knows how to do it .


Well, for start you can make invisible character follow mouse cursor (on rep.exec). That way your room will scroll with cursor.
If it doesn't suit you, you can try working with wievports, but it may be tricky.
Yes thats whaT I have been doing but if mouse goes over the player you see his name popup on the part of the @OVERHOTSPOT@ .. LOL

strazer

First off, from the original description of your problem

Quote
Want to scroll in long rooms but won't have a player char in the room .

it was very hard to tell what kind of scrolling you actually wanted. What ScummBuddy was trying to provide you with was script for scrolling the screen across a room for a cutscene, without player interaction.

In the future, please be more specific what kind of behaviour you're actually looking for so we can help you better.

Now, how about this?:

Code: ags

// room script

#define SCROLL_SPEED 3
#define SCROLL_EDGE_LEFT 5
#define SCROLL_EDGE_RIGHT 5
#define SCROLL_EDGE_TOP 20
#define SCROLL_EDGE_BOTTOM 5

function room_a() { // (Room editor -> "i" -> "Repeatedly execute" -> "Edit script...")
  // script for Room: Repeatedly execute
  //...

  int newvpx = GetViewportX(); // get current viewport x-position
  int newvpy = GetViewportY(); // get current viewport y-position
  if (mouse.x > (system.viewport_width - SCROLL_EDGE_RIGHT)) newvpx += SCROLL_SPEED; // if mouse is over right scrolling edge, move new viewport x position right
  else if (mouse.x < SCROLL_EDGE_LEFT) newvpx -= SCROLL_SPEED; // if mouse is over left scrolling edge, move new viewport x position left
  if (mouse.y > (system.viewport_height - SCROLL_EDGE_BOTTOM)) newvpy += SCROLL_SPEED; // if mouse is over bottom scrolling edge, move new viewport y position down
  else if (mouse.y < SCROLL_EDGE_TOP) newvpy -= SCROLL_SPEED; // if mouse is over top scrolling edge, move new viewport y position up
  SetViewport(newvpx, newvpy); // set viewport to (new) position

  //...
}

Candle

Looks nice but didn't work .
I added it to the page, check the hide player and it didn't do anything .

strazer

Have you created the room_a (or room_b or room_c or ...) function first by doing
  Room editor -> "i" button -> "Repeatedly execute" -> "Edit script..."
?
If you just paste the above code into the room script like that, it isn't linked with the room interaction and isn't executed.
You have to create the interaction function first, then paste the code between the two //... in there (and the #define stuff at the top of the room script by pressing the "{}" button).

If you don't know what I just said, try renaming
  function room_a() {
to
  function repeatedly_execute_always() {

Candle

#17
Thank you , got it to work now .

Candle

Quick question ? Can that be added to somewhere so I don't have to add it to every room I want to have scroll .

strazer

Yes, the code should also work if you put it into the global repeatedly_execute/_always function.

SMF spam blocked by CleanTalk