Hey there! Definitely gorgeous graphics there! And I love where this is all going! Can't wait to play this game! Keep up the good work!

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts MenuQuote from: Snarky on Sat 18/10/2014 21:30:34
Hmmyes, I see what you mean. It's a bug/limitation of SetViewport(), it only updates the viewport one frame after the character position is updated, so the character flickers between two positions on the screen. There is a workaround that might fix this (see here), but it gets a bit complicated. I'll see if I can add it in...
Edit: Try this. Since the code was getting mildly complicated, I broke it out into a separate function.Code: AGS // GlobalScript.asc int animationCounter=0; int animationFrameOld; void scrollWithBoundaries() { animationCounter++; if(animationFrameOld != player.Frame) animationCounter=0; if(animationCounter == player.AnimationSpeed || !player.MovementLinkedToAnimation) { // Scroll viewport so player is at the center of the screen (default behavior) int viewportX = player.x - System.ViewportWidth/2; int viewportY = player.y - System.ViewportHeight/2; // Don't scroll into left sidebar if(viewportX < GetRoomProperty("SidebarLeft")) viewportX = GetRoomProperty("SidebarLeft"); // Don't scroll into right sidebar else if(viewportX + System.ViewportWidth >= Room.Width - GetRoomProperty("SidebarRight")) viewportX = Room.Width - System.ViewportWidth - GetRoomProperty("SidebarRight"); SetViewport(viewportX, viewportY); } animationFrameOld = player.Frame; } function repeatedly_execute_always() { scrollWithBoundaries(); }
Quote from: Snarky on Sat 18/10/2014 21:09:49
Can't reproduce: for me the screen scrolls to follow the character. What values do you have for the sidebars? (Note that if for example your right-hand sidebar is 50 pixels wide on a 900-pixel wide background, the SidebarRight value should be 50, not 850.)
Quote from: Snarky on Sat 18/10/2014 20:31:19
Please be more specific than "still isn't working."
Once you've fixed typos and stuff like that it should have worked for the left-hand side. There was an error in the calculation of the right-hand side (I forgot to take into account the width of the screen) that meant it would ALWAYS show the right sidebar if the character was on the right-hand side of the screen: that would be a useful thing to report.
I've tested it with this code, and it's working for me (AGS 3.3):Code: ags function repeatedly_execute_always() { // Scroll viewport so player is at the center of the screen (default behavior) int viewportX = player.x - System.ViewportWidth/2; int viewportY = player.y - System.ViewportHeight/2; // Don't scroll into left sidebar if(viewportX < GetRoomProperty("SidebarLeft")) viewportX = GetRoomProperty("SidebarLeft"); // Don't scroll into right sidebar else if(viewportX + System.ViewportWidth >= Room.Width - GetRoomProperty("SidebarRight")) viewportX = Room.Width - System.ViewportWidth - GetRoomProperty("SidebarRight"); SetViewport(viewportX, viewportY); }
If not, have you remembered to set the actual values of those two properties? Are you sure the names match exactly, capitalization and all?
Quote from: Crimson Wizard on Fri 17/10/2014 21:23:21Quote from: Snarky on Fri 17/10/2014 16:52:13Not in 3.3, since 3.4 alpha.
Edit: This is based on the 3.2.1 documentation. I seem to remember that in 3.3, GetRoomProperty() is now Room.GetProperty(), for consistency.
int - is short for integer.
Quote from: Crimson Wizard on Fri 17/10/2014 21:23:21Quote from: Snarky on Fri 17/10/2014 16:52:13Not in 3.3, since 3.4 alpha.
Edit: This is based on the 3.2.1 documentation. I seem to remember that in 3.3, GetRoomProperty() is now Room.GetProperty(), for consistency.
int - is short for integer.
Quote from: Snarky on Fri 17/10/2014 16:52:13
Gosh, you've really screwed yourself on this one, haven't you? Do I take it the bars aren't necessarily the same width on each side of the image, either?
Like I said, create a custom room property (look it up in the manual; you want type int and default 0), or in this case two properties, and call them something like "SidebarLeft" and "SidebarRight". Set them to the correct values for each room.
Then replace SIDEBAR_WIDTH with the respective room property, like so:Code: AGS if(viewportX < GetRoomProperty("SidebarLeft")) viewportX = GetRoomProperty("SidebarLeft"); else if(viewportX + System.ViewportWidth >= Room.Width - GetRoomProperty("SidebarRight")) viewportX = Room.Width - GetRoomProperty("SidebarRight") - 1;
You put this in the global script, and it should work for every room where you've set the custom property values.
Quote from: Crimson Wizard on Thu 16/10/2014 18:31:04
Hmm, maybe you should use custom UserMode instead. There are two extra cursor modes called Usermode1 and 2. Just use their events as "custom action" for your door; that is -
ProcessClick(mouse.x, mouse.y, eUsermode1);
and create a new event handler for that mode.
You may also rename the mode to something more appealing, like "CustomAction".
Quote from: Snarky on Thu 16/10/2014 21:38:24
If all the screens have equally wide black bars, do this:Code: AGS #define SIDEBAR_WIDTH 32 // or whatever function repeatedly_execute_always() { // Other stuff ... viewportX = player.X - System.ViewportWidth/2; viewportY = player.Y - System.VewportHeight/2; if(viewportX < SIDEBAR_WIDTH) viewportX = SIDEBAR_WIDTH; else if(viewportX + System.ViewportWidth >= Room.Width - SIDEBAR_WIDTH) viewportX = Room.Width - SIDEBAR_WIDTH - 1; Room.SetViewport(viewportX, viewportY); // Other stuff ... }
Untested, but I think that's the gist of it. If different rooms have different black bars, I would create a custom room property to store the width of the bar, and use that in the calculation instead of SIDEBAR_WIDTH.
Quote from: Cassiebsg on Thu 16/10/2014 20:04:17
Wouldn't it then be better to change the camera when the character reaches "the critical" point in the BG, and move the camera so it never shows the black edge (maybe using a region)?
I'm no expert in coding, but it would probably be easier to add a few lines of code to each room, instead of having to redraw all the areas, and behinds and hotspots, an objects, if you are that far along.
Quote from: Crimson Wizard on Thu 16/10/2014 18:31:04
Hmm, maybe you should use custom UserMode instead. There are two extra cursor modes called Usermode1 and 2. Just use their events as "custom action" for your door; that is -
ProcessClick(mouse.x, mouse.y, eUsermode1);
and create a new event handler for that mode.
You may also rename the mode to something more appealing, like "CustomAction".
Quote from: Snarky on Thu 16/10/2014 18:19:06
Yes, it's possible, but given your other scripting questions, are you really that far along that it wouldn't be better to just reimport them?
I'm also wondering why you imported them with black bars in the first place, and why you didn't fix it right away when you noticed the problem.
Quote from: Crimson Wizard on Thu 16/10/2014 16:50:11
If I understood you right, you wanted to use Interact to open/close the door, and Any (other) Click to do something else, right?
First replace the mode you use to trigger AnyClick for WalkTo cursor to something except Interact, for example - Pointer:Code: ags // if there's a hotspot under mouse cursor if (GetLocationType(mouse.x, mouse.y) == eLocationHotspot) { // then fire "interact" event ProcessClick(mouse.x, mouse.y, eModePointer); return; // do not do anything else }
Now, in the AnyClick event you need to check the mouse cursor mode. If it is Interact, then do nothing, otherwise continue as usual. This way if player clicked on hotspot with Interact cursor, it will process only actions in Interact handler, and not AnyClick actions.Code: ags function hDoor1_AnyClick() //Hotspot of Opened door { if (mouse.Mode != eModeInteract) { player.ChangeRoom(5, 948, 232); } }
Quote from: Crimson Wizard on Wed 15/10/2014 21:40:21
Well, you don't have to use "interact" there, you may change for, e.g., eModePointer (this is the most "generic" mode I know).Code: ags ProcessClick(mouse.x, mouse.y, eModePointer);
Quote from: Crimson Wizard on Wed 15/10/2014 20:59:59
Have you considered using 9-verb MI template? It already simulates 9 commands in Lucas Arts style (Push, Pull, Open, Close etc).
Quote from: Crimson Wizard on Wed 15/10/2014 20:59:59
For example (based on default template):Code: ags function on_mouse_click(MouseButton button) // called when a mouse button is clicked. button is either LEFT or RIGHT { if (IsGamePaused() == 1) // Game is paused, so do nothing (ie. don't allow mouse click) { } else if (button == eMouseLeft) { // if it is walk-to command if (mouse.Mode == eModeWalkto) { // if there's a hotspot under mouse cursor if (GetLocationType(mouse.x, mouse.y) == eLocationHotspot) { // then fire "interact" event ProcessClick(mouse.x, mouse.y, eModeInteract); return; // do not do anything else } } // in all other cases - just do default action ProcessClick(mouse.x,mouse.y, mouse.Mode); } else // right-click, so cycle cursor { mouse.SelectNextMode(); } }
By continuing to use this site you agree to the use of cookies. Please visit this page to see exactly how we use these.
Page created in 0.146 seconds with 13 queries.