Scroll screen when ShowPlayerCharacter = False?

Started by rickious, Sun 29/09/2013 23:17:58

Previous topic - Next topic

rickious

So, you look at a cupboard, the room changes to a close-up of the cupboard, its tall and thin so I dont want to waste room either sie, plus I want to show all the detail so I decided to make the room background double height. BUT its a first person view room.  So what methods and how can I scroll up and down?  I want to avoid physical arrows on the screen, it just wouldnt be fitting. 

So maybe a way to move up and down when you move the mouse up and down, the further from the centre of the screen the faster it moves up and down? 

Otherwise im open to ideas, and ideally ones where you can explain how to do it (laugh)
--COMING SOON--
'Body Pharm' beta demo.

Body Pharm - coming soon!

Khris

You could also map the mouse's y coord to the viewport's directly. In the room's repeatedly_execute, use:

Code: ags
  int h = System.ViewportHeight;
  int rh = Room.height;
  SetViewport(0, (mouse.y*(rh-h))/h);

rickious

How exactly would I implement this code for a specific room only?

Presuming in GlobalScript.asc under...

Code: ags
function repeatedly_execute() {
--COMING SOON--
'Body Pharm' beta demo.

Body Pharm - coming soon!

monkey0506

The room script files (e.g., "room1.asc") can have their own repeatedly execute method, which is stupidly named by default, "room_RepExec". Make sure you actually set this up in the room events pane first, like you do for interaction events.

Code: ags
// room script

function room_RepExec()
{
  int h = System.ViewportHeight;
  int rh = Room.Height;
  SetViewport(0, (mouse.y * (rh - h)) / h);
}

rickious

--COMING SOON--
'Body Pharm' beta demo.

Body Pharm - coming soon!

rickious

#5
I know this is an old thread, but it was my post originally and its directly related to this.

So originally I asked how to scroll a room in 1st person view vertically.  Well now I need to do it horizontally and changing this script in the obvious ways isnt doing it for me.

Iv swapped y for x and height for width etc, but nothing is happening. 

so the following worked fine for a vertically larger background to scroll up and down...
Code: ags

function room_RepExec()
{
  int h = System.ViewportHeight;
  int rh = Room.Height;
  SetViewport(0, (mouse.y * (rh - h)) / h);
}


I have tried the following but no luck
Code: ags
function room_RepExec()
{
  int h = System.ViewportWidth;
  int rh = Room.Width;
  SetViewport(0, (mouse.x * (rh - h)) / h);
}

Code: ags
function room_RepExec()
{
  int w = System.ViewportWidth;
  int rw = Room.Width;
  SetViewport(0, (mouse.x * (rh - w)) / w);
}


Anyone know what Im missing and can explain it to my thick skull!

Thanks

EDIT *SOLVED... again

Khris just pm'd me and fixed this.

Code: ags

{
  int w = System.ViewportWidth;
  int rw = Room.Width;
  SetViewport((mouse.x * (rw - w)) / w, 0);
}



FINALLY...

How would you do this in both vertical and horizontal? so a background thats larger than the viewpoint in both directions?
--COMING SOON--
'Body Pharm' beta demo.

Body Pharm - coming soon!

Khris

SetViewport expects x, then y. Just combine the two. Here's a slighty clearer way:

Code: ags
function room_RepExec()
{
  int w = System.ViewportWidth;
  int x = (mouse.x * (Room.Width - w)) / w;

  int h = System.ViewportHeight;
  int y = (mouse.y * (Room.Height - h)) / h;

  SetViewport(x, y);
}

rickious

--COMING SOON--
'Body Pharm' beta demo.

Body Pharm - coming soon!

SMF spam blocked by CleanTalk