Author Topic: Porting game to MonoAGS  (Read 4093 times)

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Porting game to MonoAGS
« on: 13 May 2018, 21:12 »
Hi!
I want to port Cornelius Cat from AGS to MonoAGS. It is a fairly short game and has neither save/load nor translations, which is not available in MonoAGS, yet.
I thought I'd create a new thread for this, now that there is a separate board, to keep things organised.

I'm currently trying to set up the basic game structure (using mostly the Demo game and a bit of CW's games) and already have the first questions:

Is a player character needed, because it is loaded before the splash screen?

The splash screen (loadSplashScreen) has nothing to do with the Splash asset, right? It is the AGSSplashScreen from the engine but there does not seem to be documentation for it?

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #1 on: 13 May 2018, 21:14 »
Is a player character needed, because it is loaded before the splash screen?

No, you may make a game without characters at all (none of my games have any).
Changing rooms is done using Game.State.ChangeRoomAsync(room), so it is not directly related to character's going there, unlike AGS.

I am not sure how player character's position is synchronized with changing the room, haven't investigated that yet. Probably you may set Game.State.Player, but idk if it changes room automatically after the character.
« Last Edit: 13 May 2018, 21:19 by Crimson Wizard »

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #2 on: 14 May 2018, 00:44 »
The splash screen (loadSplashScreen) has nothing to do with the Splash asset, right? It is the AGSSplashScreen from the engine but there does not seem to be documentation for it?
What do you mean by "splash asset"?
Yes, sorry, the splash screen is not currently documented, and is very basic for now. It's basically a blank room with a loading text that tweens its scaling until you tell it to move to another room.
You can change the text by setting the "LoadingText" property.
You can change the font/text color/outline/shadow/etc by setting the "TextConfig" property.
And when you call the load function on the splash screen you get back a reference to your room so you can set a background or add more stuff to the room (like any other room).
Here's an example which changes the text, changes it to a blue color and adds a background image:

Code: C#
  1. var mySplashScreen = new AGSSplashScreen();
  2. mySplashScreen.LoadingText = "My Loading Text";
  3. mySplashScreen.TextConfig = new AGSTextConfig(brush: game.Factory.Graphics.Brushes.LoadSolidBrush(Colors.Blue));
  4. var room = mySplashScreen.Load(game);
  5. room.Background = myBackgroundImage;
  6. await game.State.ChangeRoomAsync(room);
  7.  
  8. ...
  9. //Load stuff here
  10. ...
  11.  
  12. await game.State.ChangeRoomAsync(firstGameRoom);
  13.  

Quote
I am not sure how player character's position is synchronized with changing the room, haven't investigated that yet. Probably you may set Game.State.Player, but idk if it changes room automatically after the character.
If you change the player character's room it automatically changes the room in the game state as well, so the behavior matches what you expect when you change the player's position in AGS, but like CW said, you don't need to have a player character as you can just change the room in the state (which won't move the player character to that room). I think I set the player first because at the beginning I had the exact AGS behavior so the player was mandatory, but at some point I changed it.

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #3 on: 14 May 2018, 08:06 »
Thanks for the explanation
What do you mean by "splash asset"?
In the assets folder->rooms there is a splash screen, but I don't think it is ever used.

One reason for this thread is to point out stuff that is either confusing in the demo game, needs more documentation or should be improved.



Monsieur OUXX

  • Cavefish
  • Mittens Vassal
  • Mittens Half Initiate
    • I can help with proof reading
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
Re: Porting game to MonoAGS
« Reply #4 on: 14 May 2018, 15:08 »
Itis ndeed not used, however that's not the important thing about the Splashscree room.
the important thing is that it has a different structure from the other rooms. It is designed to have an unpredictable framerate, which means that onRepeatelyExecute and the tweens update are called manually from this room's loading function itself.
If you don't feel too confortable with that weird room, I'd say that you may skip the splash screen altogether and just go directly to an actual room. It will take a few seconds to load, but for a small game it's no big deal.


 

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #5 on: 14 May 2018, 15:15 »
If you don't feel too confortable with that weird room, I'd say that you may skip the splash screen altogether and just go directly to an actual room. It will take a few seconds to load, but for a small game it's no big deal.

Don't remember if I mentioned this before, but IMHO DemoGame is not the best example of resource management, because it loads everything at the start (last time I checked), hence the need for "loading" screen. You may write a trivial resource manager which loads stuff for each room only when game is going there, that would reduce waiting time significantly.

Since we are at that, a small warning: MonoAGS currently does not support audio streaming (playing & loading at the same time), for that reason loading audio clips takes longer than in AGS.
« Last Edit: 14 May 2018, 15:17 by Crimson Wizard »

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #6 on: 14 May 2018, 20:24 »
If you don't feel too confortable with that weird room, I'd say that you may skip the splash screen altogether and just go directly to an actual room. It will take a few seconds to load, but for a small game it's no big deal.
I'm comfortable enough to use it, I just want to point out issues that may confuse other game developers. Like the missing documentation or the unused graphic in the assets folder.

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #7 on: 14 May 2018, 22:20 »
Added a doc for the splash screen and added the splash background asset to the splash screen in the demo game so it's being used now.

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #8 on: 15 May 2018, 20:12 »
I pulled the latest version but I get an exception when starting DemoQuest.Desktop at AGS.Engine.FileSystemResourcePack.autoD etectAssetsFolder line 104

System.ArgumentException: 'URI formats are not supported.'

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #9 on: 15 May 2018, 20:46 »
I have a fix for this which I'll hopefully push tonight.
Meanwhile you can work around it by passing the path to your assets folder to the constructor of FileSystemResourcePack which bypasses the auto detection code.

I.e change the line here: https://github.com/tzachshabtay/MonoAGS/blob/f7be8974648591740752d2c3be23ac2ea7990a4a/Source/Demo/DemoQuest/Program.cs#L23

to:

Code: C#
  1. string pathToMyAssetsFolder = "c:\cat\game\Assets";
  2. game.Factory.Resources.ResourcePacks.Add(new ResourcePack(new FileSystemResourcePack(AGSGame.Device.FileSystem, AGSGame.Device.Assemblies.EntryAssembly, pathToMyAssetsFolder), 0));
  3.  

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #10 on: 15 May 2018, 21:06 »
No worries, I spent the evening learning about async/await (https://docs.microsoft.com/en-us/dotnet/csharp/async). It a bit mind-bending because I'm used to JS promises, but I think I start to understand it.

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #11 on: 15 May 2018, 21:35 »
Cool, javascript has async/await too now, btw (they copied from c# and f#): https://javascript.info/async-await

Anyway, in case it's helpful, here's a really quick primer for AGSers on async/await:

AGS:     cEgo.Walk(eNoBlock)
MonoAGS: cEgo.WalkAsync()

AGS:     cEgo.Walk(eBlock)
MonoAGS: await cEgo.WalkAsync()

AGS:     cEgo.Walk(eNoBlock); /* Do stuff */ while (cEgo.IsMoving) Sleep(1);
MonoAGS: var walkTask = cEgo.WalkAsync(); /* Do stuff */ await walkTask;

This 3rd scenario is where async/await starts to add value. For walk you can check IsMoving on AGS, but for "say background" you'll need IsSpeaking, and you'll need more APIs for each async (non blocking) operation, whereas the API is always going to be the same with async/await. And it's not even going to be perfectly accurate in the AGS way of doing things, as while you were sleeping it might be possible (in case you have multiple threads) for the character to walk again because another command told the character to walk so you'll keep waiting. With the async/await scenario you know you're waiting for YOUR walk command, so you can't have this problem.

And where it really starts to shine is when you chain multiple async/await in whatever way you want.
For example, imagine a guard walking in the background between 4 different points in an endless loop.
In AGS, I would write something like this:

Code: Adventure Game Studio
  1. onRepeatedlyExecute()
  2. {
  3.     if (cGuard.X == 0 && cGuard.Y == 0 && !cGuard.IsMoving) cGuard.Walk(50, 0, eNoBlock);
  4.     else if (cGuard.X == 50 && cGuard.Y == 0 && !cGuard.IsMoving) cGuard.Walk(50, 50, eNoBlock);
  5.     else if (cGuard.X == 50 && cGuard.Y == 50 && !cGuard.IsMoving) cGuard.Walk(0, 50, eNoBlock);
  6.     else if (!cGuard.IsMoving) cGuard.Walk(0, 0, eNoBlock);
  7. }
  8.  

In MonoAGS:

Code: C#
  1. async void guardWalkLoop() //Using "async void" to let people know I'm a "fire and forget" method. If I want whoever calls me to wait for me to finish, I'd change the signature to "async Task" (but then I can have a "while true" in the method)
  2. {
  3.     while (true)
  4.     {
  5.         await cGuard.WalkAsync(50, 0);
  6.         await cGuard.WalkAsync(50, 50);
  7.         await cGuard.WalkAsync(0, 50);
  8.         await cGuard.WalkAsync(0, 0);
  9.     }
  10. }
  11.  

Now imagine you want the guard to say something between a few of the points, or if you want to change routes, of have multiple guards walking in parallel but occasionally need to sync with each other, it gets really hard in AGS and is trivial with async/await.
« Last Edit: 15 May 2018, 21:38 by tzachs »

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #12 on: 16 May 2018, 06:56 »
Nice! I haven't been coding for a year now (and at work I was limited to older script versions) so it's about time for me to get up-to-date :)

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #13 on: 16 May 2018, 18:15 »
I pulled the latest version but I get an exception when starting DemoQuest.Desktop at AGS.Engine.FileSystemResourcePack.autoD etectAssetsFolder line 104

System.ArgumentException: 'URI formats are not supported.'

I pushed a fix for this, can you pull again and retry?
Thanks.

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #14 on: 16 May 2018, 20:01 »
Yes, it's working now.

Edit: And another question about LoadOutfitFromFolders:
I see in the demo game that only speakLeftFolder for talk and walkLeftFolder and walkDownFolder for walk are used. How does the engine decide which one to use for what, e.g do I always have to provide speakLeftFolder when I want to have the same animation for all talk animations or could I also use speakRightFolder? This is missing in the code comments/documentation (or did I just not find it?)
« Last Edit: 16 May 2018, 20:30 by cat »

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #15 on: 17 May 2018, 15:34 »
Edit: And another question about LoadOutfitFromFolders:
I see in the demo game that only speakLeftFolder for talk and walkLeftFolder and walkDownFolder for walk are used. How does the engine decide which one to use for what, e.g do I always have to provide speakLeftFolder when I want to have the same animation for all talk animations or could I also use speakRightFolder? This is missing in the code comments/documentation (or did I just not find it?)

Yes, you can use speakRightFolder instead of speakLeftFolder (in general, the engine will try to use the closest directional animation it has). Documentation mentions it here.

And predicting a potential next question, yes, it currently does support only 8 directions, should add support to 360 (or rather, infinite because it will probably be a float) possible directions at some point (and we'll still have shortcuts to the 8 directions -> up will point to 0, down to 180, etc) and we'll probably also want explicit support for top-down views which will just rotate the sprite.

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #16 on: 19 May 2018, 21:55 »
Ok, I finally got the first background shown. I'm still not done with setup, but I want to find a way to make it cleaner than in the demo game.

I have basically just one huge scrolling background for the game and a few questions:
  • It's just one background, no objects, music and stuff - yet, the loading screen is shown for a full second or so. Why does it take so long? Is it because of the big background?
  • When the background is shown, after fade in, it quickly pans to the location which is undesired. Is this done automatically? I think it should fade directly to the position where I call change room. Or is it something different here?
  • I couldn't find documentation for Character.ChangeRoomAsync, especially how the coordinates work (i.e. where is 0,0)
  • It's hard to find/understand errors that occur. When resources for the walkcycle were not there, loading wouldn't work and I was stuck on splash screen, I only found the cause of the error when stepping through initialization with the debugger.
  • My character is not visible yet. Do I have to do something special to show it? I changed the room and the screen is on the correct position.
  • I tried to say something after the room change, but the game crashes on me:
    System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.' at AGS.Engine.OpenGLBackend line 30.

Here is my init code:
Code: Adventure Game Studio
  1. private async Task loadGameData(IGame game)
  2.         {
  3.             Debug.WriteLine("Startup: Initializing Splash Screen");
  4.             IRoom splashScreen = new AGSSplashScreen().Load(game);
  5.             game.State.Rooms.Add(splashScreen);
  6.             splashScreen.Events.OnAfterFadeIn.SubscribeToAsync(async () =>
  7.             {
  8.                 await Rooms.LoadAsync(game);
  9.                 await Characters.LoadAsync(game);
  10.                 game.State.Player = Characters.Cornelius;
  11.                 await game.State.Player.ChangeRoomAsync(Rooms.Stage, 2000, 500);
  12.                 Characters.Cornelius.Say("Hello, here I am.");
  13.             });
  14.             await game.State.ChangeRoomAsync(splashScreen);
  15.         }
  16.  



tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #17 on: 20 May 2018, 06:06 »
Would it be possible for you to share a copy of your project with me?
Without it it's going to be much harder to help.

It's just one background, no objects, music and stuff - yet, the loading screen is shown for a full second or so. Why does it take so long? Is it because of the big background?
I don't know. How big is the background (file size)?
You can try commenting out the line that loads the background and comparing the time differences.
Also, if you feel up to the challenge, you can profile the loading time to see what's taking up time. There's a built in profiler when you debug in visual studio: https://docs.microsoft.com/en-us/visualstudio/profiling/beginners-guide-to-performance-profiling
(If you share your project, I'll profile it).

When the background is shown, after fade in, it quickly pans to the location which is undesired. Is this done automatically? I think it should fade directly to the position where I call change room. Or is it something different here?
It should fade directly to the position when you change room. Are you changing the viewport positions manually? Or are you moving the character in "after fade in"? Because if you move the character after the room fades in then the camera will not change at once but will do a smooth movement so maybe that's what happenning?

I couldn't find documentation for Character.ChangeRoomAsync, especially how the coordinates work (i.e. where is 0,0)
Yes, I need to add a doc page on all the co-ordinates systems in the engine.
(0,0) is the bottom left.
Docs for Character.ChangeRoomAsync is here (though there's not much there).
And you can access it directly from the ICharacter page.
A tip if you tried using the search: there's currently a bug in DocFX that the search misses things. You can work around it by searching for "ChangeRoomAsync*" instead of "ChangeRoomAsync".
Here's a link to the bug. If you (or anybody) wants to comment on it and maybe put some more pressure on them to fix it already it would be nice.

It's hard to find/understand errors that occur. When resources for the walkcycle were not there, loading wouldn't work and I was stuck on splash screen, I only found the cause of the error when stepping through initialization with the debugger.
If you're running in "Debug" from visual studio there's printouts to the output tab. Did you look there for errors?
Otherwise, not sure, I'll need to reproduce and see what went on there.

My character is not visible yet. Do I have to do something special to show it? I changed the room and the screen is on the correct position.
Besides having the character in the same room, you also need to start the idle animation (or any animation, or set an image). You just need to do it the first time, it will then transition back to idle automatically after walk animations.

I tried to say something after the room change, but the game crashes on me:
System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.' at AGS.Engine.OpenGLBackend line 30.
Can you share the complete stacktrace of the exception?
Also, can you try changing from "Characters.Cornelius.Say("Hello, here I am.");" to "await Characters.Cornelius.SayAsync("Hello, here I am.");" and see if it helps?
If it doesn't help, you can also try doing the say (or say async) in the "after fade in" event of the "stage" room instead of the splash screen room and see if that works.

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #18 on: 20 May 2018, 09:27 »
Would it be possible for you to share a copy of your project with me?
Without it it's going to be much harder to help.
Sure, I'll send you a link. I know it would be easier to make a public github repo for it, I'm just not sure I really want to make it all public (not because of the code but the general copyright to the game and assets).

Quote
I don't know. How big is the background (file size)?
Actually, it's pretty big, ~3MB png. It's a high-res photo.
Quote
You can try commenting out the line that loads the background and comparing the time differences.
A bit faster, but not much. But today it seems to start quicker than yesterday. Who knows what Windows was doing yesterday (mining bitcoins? :P)
It's not a big issue anyway, I was just curious.

Quote
It should fade directly to the position when you change room. Are you changing the viewport positions manually? Or are you moving the character in "after fade in"? Because if you move the character after the room fades in then the camera will not change at once but will do a smooth movement so maybe that's what happenning?
I just did what is shown in the code I posted, i.e. set the character as player and then call ChangeRoomAsync

Quote
Docs for Character.ChangeRoomAsync is here (though there's not much there).
And you can access it directly from the ICharacter page.
A tip if you tried using the search: there's currently a bug in DocFX that the search misses things. You can work around it by searching for "ChangeRoomAsync*" instead of "ChangeRoomAsync".
Here's a link to the bug. If you (or anybody) wants to comment on it and maybe put some more pressure on them to fix it already it would be nice.
Ah, that's why I didn't find it in the doc. Btw, when searching for ChangeRoomAsync* only IHasRoomComponent is in the result, not ICharacter.

Quote
If you're running in "Debug" from visual studio there's printouts to the output tab. Did you look there for errors?
Otherwise, not sure, I'll need to reproduce and see what went on there.
Right, I checked again and I see a null reference exception in output. However, the program doesn't crash but nothing else happens and the game is stuck. When I press the pause button, execution seems to be in AGSGamesWindow at line 65 public void SwapBuffers() => _gameWindow.SwapBuffers(); I think it might be better to let the game crash (at least in debug mode) instead of being just stuck.

Quote
Besides having the character in the same room, you also need to start the idle animation (or any animation, or set an image). You just need to do it the first time, it will then transition back to idle automatically after walk animations.
Thanks, that did it.

Quote
I tried to say something after the room change, but the game crashes on me:
System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.' at AGS.Engine.OpenGLBackend line 30.
Can you share the complete stacktrace of the exception?
Also, can you try changing from "Characters.Cornelius.Say("Hello, here I am.");" to "await Characters.Cornelius.SayAsync("Hello, here I am.");" and see if it helps?
If it doesn't help, you can also try doing the say (or say async) in the "after fade in" event of the "stage" room instead of the splash screen room and see if that works.
With SayAsync it does not crash but I also don't see text.
Add spoiler tag for Hidden:
Stacktrace (local paths obscured)

at OpenTK.Graphics.OpenGL.GL.Clear(ClearBufferMask mask)
   at AGS.Engine.OpenGLBackend.ClearScreen()
   at AGS.Engine.AGSGame.onRenderFrame(Object sender, FrameEventArgs e) in <local>\CorneliusCat\MonoAGS\Source\Engine\AGS.Engine\Game\AGSGame.cs:line 203
   at AGS.Engine.Desktop.AGSGameWindow.onRend erFrame(Object sender, FrameEventArgs args)
   at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
   at OpenTK.GameWindow.OnRenderFrame(FrameEventArgs e)
   at OpenTK.GameWindow.OnRenderFrameInternal(FrameEventArgs e)
   at OpenTK.GameWindow.RaiseRenderFrame(Double elapsed, Double& timestamp)
   at OpenTK.GameWindow.DispatchUpdateAndRend erFrame(Object sender, EventArgs e)
   at OpenTK.GameWindow.Run(Double updates_per_second, Double frames_per_second)
   at OpenTK.GameWindow.Run(Double updateRate)
   at AGS.Engine.Desktop.AGSGameWindow.Run(Double updateRate)
   at AGS.Engine.AGSGame.Start(IGameSettings settings) in <local>\CorneliusCat\MonoAGS\Source\Engine\AGS.Engine\Game\AGSGame.cs:line 142
   at CorneliusCat.GameStarter.Run() in <local>\CorneliusCat\CorneliusCat\GameStarter.cs:line 16
   at CorneliusCat.Desktop.Program.Main(String[] args) in <local>\CorneliusCat\CorneliusCat.Desktop\Program.cs:line 10

Btw, is there another way of setting the character outfit? I want to reuse some frames for an animation and not copy them several times in resources. I'd like to build the animation manually.
« Last Edit: 20 May 2018, 09:29 by cat »

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #19 on: 21 May 2018, 16:03 »
I pushed fixes to master for both the camera panning issue and the character speaking.
Note that I removed Character.Say, SayAsync should be used instead, that's because the blocking say can't work in all scenarios (like in after fade in, because it's blocking it also blocks the completion of the event so you will not see it happening). If I return it (technically it's not needed, SayAsync can do everything Say can do) I'll need to think of a more sophisticated way for it.

Also, I saw that there's a bug with how the fade transition works in your loading screen (instead of fading in the new room, it's fading in the splash screen). Not yet sure what's going on there, it seems more complicated, I will look at it after I finish my current work.
For the mean time, if it bothers you as it bothers me, you can remove the fade transition from the game load event, and move it to after your first (non splash screen) room fades in. Note that this will also reduce the time of the splash screen (by default the fade transition is 1 second fade in and 1 second fade out).

I know it would be easier to make a public github repo for it, I'm just not sure I really want to make it all public (not because of the code but the general copyright to the game and assets).
You can also create a private repository. It costs money on github, but it's free on both VSTS and BitBucket.

Quote
Btw, when searching for ChangeRoomAsync* only IHasRoomComponent is in the result, not ICharacter.
This is because ICharacter doesn't really contain ChangeRoomAsync, it's composed out of components (like IHasRoomComponent) which contain the actual behaviors.

Quote
Right, I checked again and I see a null reference exception in output. However, the program doesn't crash but nothing else happens and the game is stuck.
Can you describe what changes I need to make to reproduce this? Also, if possible can you share the stacktrace of the null reference exception?
Thanks.

Quote
Btw, is there another way of setting the character outfit? I want to reuse some frames for an animation and not copy them several times in resources. I'd like to build the animation manually.
Yes, you can.
An outfit is a collection of directional animations (idle/walk/etc), a directional animation is a collection of animations (left/right/etc), an animation is a collection of animation frames, each animation frame is sprite + more configurations for the frame (sound and delays), and a sprite is an image + more configurations for the sprite (rotation, scale).
So you can pick and choose at what level you want to share your resources, which dictates which factory method(s) to use: the graphics factory has methods to load directional animations, to load animations, to load images, and also to get empty sprites.

So here's an untested example that combines some of those together to create an outfit.
We'll load the idle directional animation directly from folders, we'll create the walking directional animation by loading a few animation folders ourselves and create the directional animation from it, we'll create the speaking directional animations by loading images, creating animations from them and add to a directional animation, and finally, we'll create a jump directional animation by taking the images from the idle directional animations and just shift their offsets a bit to do a (really silly) "programmatic" jump.

Code: C#
  1. var factory = game.Factory.Graphics;
  2.  
  3. var idle = await factory.LoadDirectionalAnimationFromFoldersAsync("Animations/Idle", "Left", "Down", "Right", "Up");
  4.  
  5. var walkLeft = await factory.LoadAnimationFromFolderAsync("Animations/Walk/Left");
  6. var walkDown = await factory.LoadAnimationFromFolderAsync("Animations/Walk/Down");
  7. var walk = new AGSDirectionalAnimation { Left = walkLeft, Down = walkDown };
  8.  
  9. var speakLeftImage1 = await factory.LoadImageAsync("Animations/Speak/Left/1.png");
  10. var speakLeftImage2 = await factory.LoadImageAsync("Animations/Speak/Left/2.png");
  11. var speakLeftSprite1 = factory.GetSprite();
  12. var speakLeftSprite2 = factory.GetSprite();
  13. speakLeftSprite1.Image = speakLeftImage1;
  14. speakLeftSprite2.Image = speakLeftImage2;
  15.  
  16. //I'm missing a factory method to create an empty animation, so using the resolver for this (for now):
  17. var speakLeft = AGSGame.Resolver.Container.Resolve<IAnimation>();
  18. speakLeft.Frames.Add(new AGSAnimationFrame(speakLeftSprite1) { Delay = 3});
  19. speakLeft.Frames.Add(new AGSAnimationFrame(speakLeftSprite2) { MinDelay = 4, MaxDelay = 8});
  20. var speak = new AGSDirectionalAnimation { Left = speakLeft };
  21.  
  22. var jumpLeft = AGSGame.Resolver.Container.Resolve<IAnimation>();
  23. float yOffset = 0f;
  24. foreach (var idleFrame in idle.Left)
  25. {
  26.     var sprite = factory.GetSprite();
  27.     sprite.Image = idleFrame.Sprite.Image;
  28.     sprite.Y = yOffset;
  29.     yOffset += 0.5f;
  30.     var jumpFrame = new AGSAnimationFrame(sprite) { Delay = idleFrame.Delay };
  31.     jumpLeft.Frames.Add(jumpFrame);
  32. }
  33. var jump = new AGSDirectionalAnimation { Left = jumpLeft };
  34.  
  35. var outfit = new AGSOutfit();
  36. outfit[AGSOutfit.Idle] = idle;
  37. outfit[AGSOutfit.Walk] = walk;
  38. outfit[AGSOutfit.Speak] = speak;
  39. outfit["Jump"] = jump;
  40.  

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #20 on: 21 May 2018, 20:45 »
I pushed fixes to master for both the camera panning issue and the character speaking.
Nice! It's working now :)

Quote
Note that I removed Character.Say, SayAsync should be used instead, that's because the blocking say can't work in all scenarios
Right, better remove it than having a half-broken version.

Quote
Also, I saw that there's a bug with how the fade transition works in your loading screen (instead of fading in the new room, it's fading in the splash screen). Not yet sure what's going on there, it seems more complicated, I will look at it after I finish my current work.
For the mean time, if it bothers you as it bothers me, you can remove the fade transition from the game load event, and move it to after your first (non splash screen) room fades in. Note that this will also reduce the time of the splash screen (by default the fade transition is 1 second fade in and 1 second fade out).
Wow, it's really much quicker that way.

Quote
You can also create a private repository. It costs money on github, but it's free on both VSTS and BitBucket.
Thanks, I'll think about it.

Quote
This is because ICharacter doesn't really contain ChangeRoomAsync, it's composed out of components (like IHasRoomComponent) which contain the actual behaviors.
I understand that, but the whole interface composition will be too complicated for the regular game developer. The documentation needs to have an article where everything you can do with a character is explained in the style of the old AGS doc.

Quote
Quote
Right, I checked again and I see a null reference exception in output. However, the program doesn't crash but nothing else happens and the game is stuck.
Can you describe what changes I need to make to reproduce this? Also, if possible can you share the stacktrace of the null reference exception?
Thanks.
For example, during character creation, I assign an outfit only for left:
IOutfit outfit = await game.Factory.Outfit.LoadOutfitFromFolde rsAsync(_baseFolder, walkLeftFolder: "Walk", speakLeftFolder: "Walk", idleLeftFolder: "Walk");
and then I start the idle animation for down (because I didn't pay attention):
_character.StartAnimation(_character.Outfit[AGSOutfit.Idle].Down);
The problem is, the game gets stuck on the loading screen and the exception is only visible in output.

Quote
An outfit is a collection of directional animations (idle/walk/etc)...
Thanks! It would be great to have a shortcut, like factory.LoadSpriteFromFile or similar. Especially when doing multiple animations manually, it creates lots of code atm. Can I safely reuse a sprite for different frames or should I create/clone a new one?
Oh well :(. I tried creating the animation manually but didn't get it to work, yet. The viewport jumps weirdly and I just have flickering and no proper animation. I need to investigate further.


One more (not exactly MonoAGS) issue I have: I installed the VS Community Edition, which I thought was free? But now VS says that my 30 days trial license will expire in a few days ???

Monsieur OUXX

  • Cavefish
  • Mittens Vassal
  • Mittens Half Initiate
    • I can help with proof reading
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
Re: Porting game to MonoAGS
« Reply #21 on: 22 May 2018, 14:38 »
One more (not exactly MonoAGS) issue I have: I installed the VS Community Edition, which I thought was free? But now VS says that my 30 days trial license will expire in a few days ???

Sometimes the installer is the same but it's the license that matters. Check in google if there isn't a thing like "get your VS community key" which might lead you to a page where all you have to do is to provide your (any) email address to get the key.
Nowadays most of the time you can even generate a key directly from within VS. Chek ou the "help" or "tools" menu.
« Last Edit: 22 May 2018, 15:22 by Monsieur OUXX »
 

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #22 on: 22 May 2018, 15:00 »
I understand that, but the whole interface composition will be too complicated for the regular game developer. The documentation needs to have an article where everything you can do with a character is explained in the style of the old AGS doc.
The character page has everything you can do with the character in link format, so it's similar to the AGS doc except for the link itself does not to point to the same page. I'm not sure there's an easy way to copy the link contents to the character page, I'll need to get a deeper understanding of how the documentation is auto generated. Hopefully I'll get to that at some point.
I reported the new scenario for the broken search, and they're investigating it, so hopefully it will improve the situation (and interestingly if you search for "*ChangeRoomAsync*" it does work).
Also note that I plan to have the documentation for the interactions available from within the (yet to be written) interaction editor (so each interaction will have a "?" button next to it or something like that).


Quote
Thanks! It would be great to have a shortcut, like factory.LoadSpriteFromFile or similar.
Done ("LoadSprite" and "LoadSpriteAsync").

Quote
Can I safely reuse a sprite for different frames or should I create/clone a new one?
It depends. If you share the sprite it means you also share the sprite's configuration (rotation, scaling, translation offset, pivot, tinting, brightness). In other words, if you use the same sprite on 2 animation frames, and you rotate the sprite in one of the frames it will also rotate it for the other animation frame. If that's what you want, or, if you don't intend to change configurations for individual sprites (and if you intend to port the game from AGS as is without changes, then you don't) you can safely share the sprites. But if you want independent configurations, then use different sprites (but they can still share the same image, which is safe).

Quote
One more (not exactly MonoAGS) issue I have: I installed the VS Community Edition, which I thought was free? But now VS says that my 30 days trial license will expire in a few days ???
It is free, but you need to sign in, see here: https://www.visualstudio.com/vs/support/community-edition-expired-buy-license/

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #23 on: 22 May 2018, 17:19 »
Done ("LoadSprite" and "LoadSpriteAsync").
Already saw it this afternoon and used it in my code - thanks :)

Quote
Quote
One more (not exactly MonoAGS) issue I have: I installed the VS Community Edition, which I thought was free? But now VS says that my 30 days trial license will expire in a few days ???
It is free, but you need to sign in, see here: https://www.visualstudio.com/vs/support/community-edition-expired-buy-license/
Ah, I thought it might be something like that :-\ Well, can't complain too much about a free product. I assume when the MonoAGS editor is finished, people will not need VS installed, right?

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #24 on: 22 May 2018, 17:42 »
Ah, I thought it might be something like that :-\ Well, can't complain too much about a free product. I assume when the MonoAGS editor is finished, people will not need VS installed, right?
Technically, you don't need VS even now. Any IDE/text editor which can compile c# code can be used (in theory, at least).
Once the first version of the MonoAGS editor will be released, you should be able to use any text editor even if it can't compile c# yourself as the editor will be able to compile the code. However, you'll probably still want to use an IDE for debugging purposes.
Then I'll look into the option of bundling the editor with an existing IDE (we previously talked about either MonoDevelop or VS Code as potential candidates), and also of having the editor as an add-in to VS itself (so 3 flavors: standalone, standalone bundled with text editor and debugger, add-in to VS -> hoping it wouldn't be too big a burden, otherwise we'll need to make a choice and cut).

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #25 on: 22 May 2018, 19:03 »
I think an editor without the need to register an account somewhere is a must.

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #26 on: 06 Jun 2018, 17:27 »
For example, during character creation, I assign an outfit only for left:
IOutfit outfit = await game.Factory.Outfit.LoadOutfitFromFolde rsAsync(_baseFolder, walkLeftFolder: "Walk", speakLeftFolder: "Walk", idleLeftFolder: "Walk");
and then I start the idle animation for down (because I didn't pay attention):
_character.StartAnimation(_character.Outfit[AGSOutfit.Idle].Down);
The problem is, the game gets stuck on the loading screen and the exception is only visible in output.
This should be fixed now (the game will properly crash with an error message).

Quote
Also, I saw that there's a bug with how the fade transition works in your loading screen (instead of fading in the new room, it's fading in the splash screen). Not yet sure what's going on there, it seems more complicated, I will look at it after I finish my current work.
This should also be fixed now.

Monsieur OUXX

  • Cavefish
  • Mittens Vassal
  • Mittens Half Initiate
    • I can help with proof reading
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
Re: Porting game to MonoAGS
« Reply #27 on: 12 Sep 2018, 16:50 »
For the record I've completely given up on this. I lost steam while writing Readers in C# for .xml files for rooms, characters, objects, etc.
Not MonoAGS' fault, though. I still think it has great potential. Just not mature enough for the use I want to make of it. If some sort of easy resources loader appeared, mirroring AGS' game.agf file (with sections split into several files) I'd give it another try.
 

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #28 on: 12 Sep 2018, 16:57 »
I figured, but thanks for the heads up.
My efforts are currently still targeted at having a functional working editor, and I'll update when I have something to show (going to take a while).

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #29 on: 13 Sep 2018, 10:12 »
For the record I've NOT given up on this, it's just a matter of time. I hope I'll find some time soon for setting up an account and getting my VS running again. I know it's not difficult, but I hate having to bother with this kind of stuff.

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #30 on: 13 Sep 2018, 15:46 »
Cool!
Depending on how desperate you are to avoid setting up an account (and how adventurous you are), you can try using another IDE.
MonoDevelop is free and open source and no registration is needed.
VSCode is another free and open source and no registration is needed, but you might need to work harder to make it work there (as it's general purpose, not c# specific like MonoDevelop, so you'll need to install a bunch of plugins and configure stuff).

Eventually I'll get to try those out myself (I have used MonoDevelop on Linux, actually, but did not try on Windows) and probably add a small tutorial for setting those up (if needed).

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #31 on: 13 Sep 2018, 19:06 »
Quoting the MonoDevelop homepage
Quote
MonoDevelop for Windows is available from source only
Please refer to the building guide for more information about how to install and configure your MonoDevelop.
The Prerequisites for building under Windows require Visual Studio with F# enabled :P

Why on earth can't they just provide a Windows installer?

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #32 on: 13 Sep 2018, 19:30 »
8-0
Facepalm.
Sorry, they had packages for linux and I assumed they would have an installer/downloadable for windows.

Why on earth can't they just provide a Windows installer?
Yeah, this is bizarre ???. I'm guessing everybody just uses VS on Windows and their main audience is mac & linux, but still...
I opened an issue on their repo: https://github.com/mono/monodevelop/issues/5961

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #33 on: 13 Sep 2018, 19:51 »
Yeah, I mean building it myself is cumbersome enough but then also requiring VS is just weird. Since I don't do C# any more, I think I don't even have VS on my work PC.
Let's see if someone reacts to your issue. But I guess I'll get VS to run sooner or (more likely) later anyway.

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #34 on: 13 Sep 2018, 20:10 »
Sorry, they had packages for linux and I assumed they would have an installer/downloadable for windows.

Why on earth can't they just provide a Windows installer?
Yeah, this is bizarre ???. I'm guessing everybody just uses VS on Windows and their main audience is mac & linux, but still...
I opened an issue on their repo: https://github.com/mono/monodevelop/issues/5961

Lol, this looks like Linux users are trolling Windows users by not requiring to build from source on Linux and requiring to do so on Windows on contrary. Maybe they are angry on Microsoft for some reason?

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #35 on: 14 Sep 2018, 11:25 »
In the meantime, I tried SharpDevelop, but this seems to be too old, it can't even load the projects.

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #36 on: 15 Sep 2018, 19:52 »
I've set up an account and can run VS again now.
When I now pull the latest master, I get a few error messages:
Code: Adventure Game Studio
  1. Error   CS0535  'GameStarter' does not implement interface member 'IGameStarter.Settings
  2. Error   CS0117  'AGSGame' does not contain a definition for 'CreateEmpty'
  3. Error   CS0117  'AGSGameSettings' does not contain a definition for 'DefaultSpeechFont'
  4. Error   CS0117  'AGSGameSettings' does not contain a definition for 'DefaultTextFont'  
  5. Error   CS0117  'AGSGameSettings' does not contain a definition for 'DefaultSpeechFont'
  6. Error   CS0117  'AGSGameSettings' does not contain a definition for 'CurrentSkin'      
  7.  

What do I have to change? Are there release notes or something?

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #37 on: 15 Sep 2018, 22:18 »
There are no official release notes, yet, I'm afraid (I haven't technically released anything yet). My current plan is to have a functional editor (which like I said, gonna take a while) and then release a v0.1 and start making organized releases and release notes from there on (I'm guessing that's the point the project will start looking more interesting to people).

You can however look at the list of the merged pull requests (I make sure to create pull requests for everything, so it should have all of the changes): https://github.com/tzachshabtay/MonoAGS/pulls?q=is%3Apr+is%3Aclosed
Each PR in itself has a list of commits which you can browse (some are more detailed than others...).
Though currently I haven't (unfortunately) made any efforts in listing breaking changes.

The errors you get are because of 2 breaking changes:
1. Made changes to how a game is started, this is to allow having 2 games that live side by side (as the editor is in itself a game which hosts your game).
2. Moved some defaults into their own class, which you can access from game.Settings.Defaults.

You can follow the structure in the demo game to make this changes: https://github.com/tzachshabtay/MonoAGS/blob/master/Source/Demo/DemoQuest/Program.cs

The relevant lines with changes are: 10, 17, 28-30, 44-51.

And if you're interesting in examining the commits that made these changes:
https://github.com/tzachshabtay/MonoAGS/commit/f58e4bfc633a225b26b77e50601ecc4af8d2a8cf
https://github.com/tzachshabtay/MonoAGS/commit/84050bcb7d49e6a0a8d9b14f22fe7f5a266959ca#diff-f3b30bc060275a41bac549848c305912

Let me know if you're having problems, I can make the changes for you.



cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #38 on: 16 Sep 2018, 09:56 »
Right, I got the program and the usage of dependency injection fixed. I can start the game and as a nice surprise, the custom font is now working (that didn't work before).

There are still other issues (that already were there before), but now that I can compile again, I'll have a look at them one after each other.

Oh, and I like the new point syntax and deconstruction. Gotta get used to the new language features :)
« Last Edit: 16 Sep 2018, 09:59 by cat »

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #39 on: 16 Sep 2018, 10:46 »
Whoops, looks like I have the slot-machine version of adventure gaming. When I run the game from VS, I get randomly one of the following results:
  • The game runs just fine
  • It is stuck on loading screen
  • I get a "System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'" in OpenGLBackend line 30 (public void ClearScreen() => GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);)
    Add spoiler tag for Hidden:
    System.AccessViolationException
      HResult=0x80004003
      Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
      Source=<Cannot evaluate the exception source>
      StackTrace:
    <Cannot evaluate the exception stack trace>

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #40 on: 16 Sep 2018, 13:36 »
Oh, that doesn't sound good. 
Can you send me your project? I'll investigate.

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #41 on: 18 Sep 2018, 12:11 »
Not sure if anyone else is following this thread, but I've sent my code to tzachs. He investigated the issue and found a temporary workaround.

A question on a completely different topic:
For the original AGS game I used a GUI to represent the border around the stage. It's basically a non-clickable GUI covering the whole screen and the center is transparent. What would be the best way to implement this in MonoAGS?

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #42 on: 18 Sep 2018, 15:22 »
It depends.

1. If you already have an image for the border which is the size of the entire screen, then you can do the same.
The equivalent of "A GUI" is a panel which you can get from the GUI factory (it's already "click-through" by default):

Code: C#
  1. factory.UI.GetPanel("MyPanel", myImage, x, y);
  2.  

Note that unlike GUIs in AGS, if you want the panel to only be associated with a specific room and not all rooms, you can write it that like this:

Code: C#
  1. var panel = factory.UI.GetPanel("MyPanel", myImage, x, y, addToUI: false);
  2. myRoom.Objects.Add(panel);
  3.  

2. If you don't have a specific image you want for your border, you can use the "Border" property and set a built-in border (or you can code your own custom border rendering, but that's more involved and the API is not stable currently, the way it's done is very likely to change in the future).
Built in borders include a solid color border, a gradient border or a 9-slice image border (9-slice image border is similar to the 9 images you set on a border in AGS for message boxes, only a little more fancy, similar to a css border image: https://css-tricks.com/almanac/properties/b/border-image/).
So to create a transparent panel with a solid color border, for example, you can write:

Code: C#
  1. var panel = factory.UI.GetPanel("MyPanel", width, height, x, y);
  2. panel.Tint = Colors.Transparent;
  3. panel.Border = factory.Graphics.Borders.SolidColor(Colors.Blue, lineWidth: 3f, hasRoundCorners: true);
  4.  


cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #43 on: 18 Sep 2018, 15:44 »
Ah, in this case I will try a panel.

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #44 on: 18 Sep 2018, 21:02 »
The panel frame is working :)

Is it possible to define a mask myself without a file? I just need a rectangle for the walkable area. If not, no worries, I'll just draw a mask.

Oh, and since you are the moderator in this board: Do you prefer that I edit posts with additional info or should I create a new post to bump the thread?


Edit: I just realized, I can probably do it with GetBitmap and then CreateMask?
Edit2: Seemed to work! I cannot walk yet, but PlaceOnWalkableArea() moves the character to where the WA is supposed to be :)
« Last Edit: 18 Sep 2018, 21:44 by cat »

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #45 on: 18 Sep 2018, 22:33 »
Edit: I just realized, I can probably do it with GetBitmap and then CreateMask?
Edit2: Seemed to work! I cannot walk yet, but PlaceOnWalkableArea() moves the character to where the WA is supposed to be :)
Cool! Very happy you figured it out without any specific documentation :)
Another way (just for posterity, what you did sounds better) would have been to create "new AGSMask" and give it a 2d boolean array.

I cannot walk yet
Ah, so I think your game uses left to interact and right to look, right?
I have an incomplete implementation of that scheme in: https://github.com/tzachshabtay/MonoAGS/blob/master/Source/Engine/AGS.Engine/Input/Schemes/TwoButtonsInputScheme.cs
Not sure if what's there is in a working state or not (haven't touched it in a while but from brief examination of the code walking at least should work), you can try it by writing:
Code: C#
  1. var scheme = new TwoButtonsInputScheme(game, game.Input);
  2. scheme.Start();
  3.  
If it's working you should be able to walk.

If you're feeling up for it, it should be relatively simple to complete the implementation (just hadn't gotten around to it yet).
It's basically just looking at how it's done in the rotating cursors scheme (https://github.com/tzachshabtay/MonoAGS/blob/master/Source/Engine/AGS.Engine/Input/Schemes/RotatingCursorScheme.cs) without the actual rotating cursors stuff.
If not, then I'll get to it soon enough, hopefully in the next few days.

Oh, and since you are the moderator in this board: Do you prefer that I edit posts with additional info or should I create a new post to bump the thread?
Bumping is fine. If you edit there's a chance I won't see it. Also I'm susbcribed to the topic so I'm getting an email whenever you post and can give you a quicker response.

Monsieur OUXX

  • Cavefish
  • Mittens Vassal
  • Mittens Half Initiate
    • I can help with proof reading
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
Re: Porting game to MonoAGS
« Reply #46 on: 19 Sep 2018, 10:58 »
Why on earth can't they just provide a Windows installer?
Because linuxians. They like to capture the souls of innocent passerbys and torture them until they have entirely drained the will to live from them. They take a specific perverted pleasure in doing so by providing tools meant for Windows but made on Linux and yet not compiled for Windows.

What do you mean, "slightly biased comment"?
 

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #47 on: 20 Sep 2018, 21:36 »
Cool! Very happy you figured it out without any specific documentation :)
Another way (just for posterity, what you did sounds better) would have been to create "new AGSMask" and give it a 2d boolean array.
I used Bitmap.SetPixels() with a list I built using nested loops. Is there a better way?

Quote
Code: C#
  1. var scheme = new TwoButtonsInputScheme(game, game.Input);
  2. scheme.Start();
  3.  
When I use this and click somewhere, nothing happens in the game but I see an exception in the output window:
Exception thrown: 'System.IndexOutOfRangeException' in AGS.Engine.dll

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #48 on: 21 Sep 2018, 13:37 »
Quote from: cat link=topic=56055.msg636595179#msg636595179
I used Bitmap.SetPixels() with a list I built using nested loops. Is there a better way?
Well, if you only want a rectangle, then just getting an empty bitmap should be enough, I think: factory.Graphics.GetBitmap(width,height)

Quote
When I use this and click somewhere, nothing happens in the game but I see an exception in the output window:
Exception thrown: 'System.IndexOutOfRangeException' in AGS.Engine.dll
Ok, I'll look into it.

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #49 on: 21 Sep 2018, 14:12 »
I want a rectangle that doesn't cover the whole screen, only a small part.

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #50 on: 22 Sep 2018, 21:00 »
In the meantime, I added the first object and to make things interesting, it's an object with animation. Good news first: it works :)
I'm just having trouble positioning the object. Using the original coordinates from the AGS game does not work. How is the position determined? Is there a proper way to calculate from AGS to MonoAGS coords?

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #51 on: 22 Sep 2018, 21:21 »
I'm just having trouble positioning the object. Using the original coordinates from the AGS game does not work. How is the position determined? Is there a proper way to calculate from AGS to MonoAGS coords?

Y axis is turned other way, pointing up :)
Also, in MonoAGS object's image related to Position is determined by Pivot (or was it Anchor? I may not remember correct property's name).
So, if your AGS object was located at X,Y your MonoAGS object should be located at X, Y = AgsRoomHeight - agsY, plus some extra offset depending on pivot/anchor.

I made this function to port AGS scripts:
https://github.com/ivan-mogilko/MonoAGSGames/blob/master/Games/LastAndFurious/Rooms/RoomScript.cs#L57
« Last Edit: 22 Sep 2018, 21:26 by Crimson Wizard »

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #52 on: 23 Sep 2018, 10:40 »
Thanks, that did it! So it's the other way round. And I didn't know I had to reset the pivot first. What is the reason for having it 0.5, 0 initially?

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #53 on: 23 Sep 2018, 11:04 »
The pivot point is by default 0.5,0 for characters and 0,0 for objects. The reason it's 0.5,0 for characters is that it makes walk cycle animations align even when the front/back frames are in a different width from the side animations. Also I find it to be more intuitive when setting walk areas.

Also sorry that I haven't been more helpful lately, currently I'm on a 3 week vacation and a bit low on free time with proper internet..

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #54 on: 23 Sep 2018, 11:12 »
The pivot point is by default 0.5,0 for characters and 0,0 for objects.
Sorry I have to correct you, but at least with version a4b22 the default pivot point for objects is 0.5, 0. I looked at it via debugger and when I reset the pivot to 0,0 the object is moved to the correct position.
I agree about the character pivot point and reasoning, though.

Quote
Also sorry that I haven't been more helpful lately, currently I'm on a 3 week vacation and a bit low on free time with proper internet..
No worries, enjoy your vacation! I see what I can do in the meantime by myself. Also a good way to see how self-explanatory the documentation is ;)

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #55 on: 23 Sep 2018, 13:29 »
I think in the end it may be worth to not rely on engine's defaults and have a set of utility functions that init objects of different kinds. For example in the racing game I've referenced above I had function that setup a racing car object and it sets pivot to (0.5, 0.5), because it lets you to trivially apply rotation around sprite center.

This reminds me, when I last saw (several months ago) both alignment and rotation was performed around pivot, and there was a suggestion to split properties into one determining position alignment and another for object's own transform operations:
https://github.com/tzachshabtay/MonoAGS/issues/284


UPD.
Also, the Y axis pointing up makes it inconvenient to work with GUI, since you have to position, for example, menu items vertically in opposite direction (first item having largest Y). I wrote a class for the game menu that does calculations internally to simplify things for myself:
https://github.com/ivan-mogilko/MonoAGSGames/blob/master/Games/LastAndFurious/GameMenuComponent.cs#L169

I think I was asking if it's possible to implement a surface with custom axis direction, but don't remember what was tzach's decision on that.
« Last Edit: 23 Sep 2018, 14:13 by Crimson Wizard »

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #56 on: 23 Sep 2018, 15:53 »
Thanks Crimson. I'll have another close look at your repostitory, since you have answers to many of my questions already :)

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #57 on: 23 Sep 2018, 22:25 »
When I use this and click somewhere, nothing happens in the game but I see an exception in the output window:
Exception thrown: 'System.IndexOutOfRangeException' in AGS.Engine.dll
I can't reproduce this, so I need more information.
Is this the entire error message, no additional stack trace? Also, where did you put this code? And can you also write the code you used to add the walkable area? Or alternatively, can you send me your project again (with the error reproducing)?

I used Bitmap.SetPixels() with a list I built using nested loops. Is there a better way?
...
I want a rectangle that doesn't cover the whole screen, only a small part.
Not necessarily better, but you can get an empty bitmap as I said before, and then add a translate component which gives you the ability to "move" an area on the screen.
It will look something like this, for example:
Code: C#
  1. var bitmap = factory.Graphics.GetBitmap(1000, 1000);
  2. var mask = factory.Masks.Load("walkablemask1", bitmap, true);
  3. var area = factory.Room.GetArea("walkablearea1", mask, _room, true);
  4. area.AddComponent<ITranslateComponent>().X = 2000f;
  5.  

Sorry I have to correct you, but at least with version a4b22 the default pivot point for objects is 0.5, 0. I looked at it via debugger and when I reset the pivot to 0,0 the object is moved to the correct position.
I agree about the character pivot point and reasoning, though.
Ah, right, I think I changed it to all images after realizing the same logic applies, you can have multiple animations with different widths and it makes it easier to align by default (and also it's more consistent). I don't necessarily have too strong opinions on this, willing to discuss if you have a better suggestion.

I think in the end it may be worth to not rely on engine's defaults and have a set of utility functions that init objects of different kinds. For example in the racing game I've referenced above I had function that setup a racing car object and it sets pivot to (0.5, 0.5), because it lets you to trivially apply rotation around sprite center.
This makes sense for a racing game, but I wouldn't want the average user to have to create utility functions for a point&click game. The engine should be geared with defaults that apply to the most common use-cases for point&click (or in the future, like we discussed, we might have templates with different defaults, geared to that specific template use case).
I think cat's struggle here stems for the fact that she's porting an existing game, I don't think she'd encounter this issue when creating a new game (we'll see when people actually create new games, though).

Also, the Y axis pointing up makes it inconvenient to work with GUI, since you have to position, for example, menu items vertically in opposite direction (first item having largest Y). I wrote a class for the game menu that does calculations internally to simplify things for myself:
https://github.com/ivan-mogilko/MonoAGSGames/blob/master/Games/LastAndFurious/GameMenuComponent.cs#L169
Check out the built in Stack layout component which solves this problem (at least for laying out menu items). You add your buttons to a panel, then you add the layout component to the panel and it automatically lays them out for you (and you can set the spacing between the items).

This reminds me, when I last saw (several months ago) both alignment and rotation was performed around pivot, and there was a suggestion to split properties into one determining position alignment and another for object's own transform operations:
https://github.com/tzachshabtay/MonoAGS/issues/284
Right, the jury is still out on this one. I'm keeping the issue open, but as I said, I'm not sure the added flexibility here is worth the added complexity.

I think I was asking if it's possible to implement a surface with custom axis direction, but don't remember what was tzach's decision on that.
Same here, it can be done and it adds flexibility, but I'm again not sure the added flexibility is worth the added complexity.

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #58 on: 24 Sep 2018, 11:54 »
I think in the end it may be worth to not rely on engine's defaults and have a set of utility functions that init objects of different kinds. For example in the racing game I've referenced above I had function that setup a racing car object and it sets pivot to (0.5, 0.5), because it lets you to trivially apply rotation around sprite center.
This makes sense for a racing game, but I wouldn't want the average user to have to create utility functions for a point&click game. The engine should be geared with defaults that apply to the most common use-cases for point&click (or in the future, like we discussed, we might have templates with different defaults, geared to that specific template use case).

You may find different use cases for the Origin (I will use this term, which is equivalent to Pivot at the moment) within same game or even within same room. For example:
Origin with Y = 0 will be convenient when setting up objects that need to be on "floor", because you want to align their feet/bottom to particular place there.
Origin in center (0.5, 0.5) is convenient for top-down views, but may be also useful if you are making small flying objects like projectiles, visual effects etc.
Origin with Y = 1 might be useful if you align things in top to bottom order on screen programmatically (e.g. GUIs). And also if you have something walking on the ceiling, I guess :).
I think in general that whenever you are aligning objects programmatically alot in your game you may want to make sure they have convenient origins for that.

Otherwise you'd had to do extra maths in all non-default situations. AGS does not have custom origin, so I had to do additional calculations to position car "characters" in my racing game, converting from physics coordinates into AGS character coordinates. In MonoAGS I simply set the pivot.
« Last Edit: 24 Sep 2018, 11:58 by Crimson Wizard »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #59 on: 24 Sep 2018, 21:23 »
Since I was referencing examples of my work I decided to update my games to the latest version of MonoAGS too. Some issues were easy to fix, but I am currently trying to figure out what happened to the IImageRenderer interface which I implemented as SpriteFontRenderer in my game.

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #60 on: 24 Sep 2018, 22:05 »
Since I was referencing examples of my work I decided to update my games to the latest version of MonoAGS too. Some issues were easy to fix, but I am currently trying to figure out what happened to the IImageRenderer interface which I implemented as SpriteFontRenderer in my game.
The IImageRenderer interface was removed and replaced with IRenderer and IRenderInstruction, see this PR: https://github.com/tzachshabtay/MonoAGS/pull/279
This was a follow-up to our discussion on refactoring the rendering logic: https://github.com/tzachshabtay/MonoAGS/issues/207

For the most simple example of this in action, see the pivot renderer component (basically just draws a cross where the pivot point is): https://github.com/tzachshabtay/MonoAGS/blob/master/Source/Engine/AGS.Engine/Graphics/Drawing/PivotRendererComponent.cs

You may find different use cases for the Origin (I will use this term, which is equivalent to Pivot at the moment) within same game or even within same room.
Sure, I'm not disputing that, I'm just not sure we understood each other's point. What I argued against is your quote about "not relying on engine defaults and creating utility functions". I think that if you build a standard point & click game with this engine, then most chances are that the defaults match what you need (and if that's not the case, we should change that). If you're creating a different genre game, or have fancy non standard puzzles/sequences in your game, then yes, you might want to create utility functions for those (or, perhaps, we might have in the future, a feature similar to Unity's prefabs, that you can use instead of utility factories), but I don't think that applies to the vast majority of the games that will be created with this engine, and I don't think it applies to cat's game which is a standard point&click (mechanics wise, ignoring the wonderful puppets ;-D) with standard puzzles.

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #61 on: 25 Sep 2018, 20:08 »
When I use this and click somewhere, nothing happens in the game but I see an exception in the output window:
Exception thrown: 'System.IndexOutOfRangeException' in AGS.Engine.dll
I can't reproduce this, so I need more information.
Is this the entire error message, no additional stack trace? Also, where did you put this code? And can you also write the code you used to add the walkable area? Or alternatively, can you send me your project again (with the error reproducing)?

I put the init code in the loadUi function in the GameStarter.

I turned on "break on exception" and get this:
Add spoiler tag for Hidden:
>   AGS.Engine.dll!AGS.Engine.StaticGrid.GetNodeAt(int iX, int iY) Line 128   C#
    AGS.Engine.dll!AGS.Engine.JumpPointParam.JumpPointPara m(AGS.Engine.BaseGrid iGrid, AGS.Engine.GridPos iStartPos, AGS.Engine.GridPos iEndPos, bool iAllowEndNodeUnWalkable, bool iCrossCorner, bool iCrossAdjacentPoint, AGS.Engine.HeuristicMode iMode) Line 56   C#
    AGS.Engine.dll!AGS.Engine.EPPathFinder.getWalkPoints(AGS.Engine.BaseGrid grid, AGS.API.Position from, AGS.API.Position to) Line 45   C#
    AGS.Engine.dll!AGS.Engine.EPPathFinder.GetWalkPoints(AGS.API.Position from, AGS.API.Position to) Line 40   C#
    AGS.Engine.dll!AGS.Engine.AGSWalkComponent.getWalkPoin ts(AGS.API.Position destination) Line 337   C#
    AGS.Engine.dll!AGS.Engine.AGSWalkComponent.walkAsync(AGS.Engine.AGSWalkComponent.WalkInstruc tion currentWalk, AGS.API.Position location, bool straightLine, System.Collections.Generic.List<AGS.API.IObject> debugRenderers) Line 275   C#
    AGS.Engine.dll!AGS.Engine.AGSWalkComponent.processWalk Instruction(AGS.Engine.AGSWalkComponent.WalkInstruc tion previousWalk, AGS.Engine.AGSWalkComponent.WalkInstruc tion currentWalk) Line 262   C#
    AGS.Engine.dll!AGS.Engine.AGSWalkComponent.getWalkInst ruction() Line 211   C#
    AGS.Engine.dll!AGS.Engine.AGSWalkComponent.onRepeatedl yExecute() Line 126   C#
    AGS.Engine.dll!AGS.Engine.AGSEvent<AGS.API.IRepeatedlyExecuteEventArgs>.InvokeAsync(AGS.API.IRepeatedlyExecuteEventArgs args) Line 64   C#
    AGS.Engine.dll!AGS.Engine.AGSGame.onUpdateFrame(object sender, AGS.Engine.FrameEventArgs e) Line 189   C#
    AGS.Engine.dll!AGS.Engine.AGSUpdateThread.RaiseUpdateF rame(double elapsed, ref double timestamp) Line 219   C#
    AGS.Engine.dll!AGS.Engine.AGSUpdateThread.DispatchUpda teFrame(object sender, System.EventArgs e) Line 185   C#
    AGS.Engine.dll!AGS.Engine.AGSUpdateThread.threadLoop() Line 167   C#

Quote
Not necessarily better, but you can get an empty bitmap as I said before, and then add a translate component which gives you the ability to "move" an area on the screen.
I guess I'll just stick to my implementation for now.

Quote
Ah, right, I think I changed it to all images after realizing the same logic applies, you can have multiple animations with different widths and it makes it easier to align by default (and also it's more consistent). I don't necessarily have too strong opinions on this, willing to discuss if you have a better suggestion.
Quote
I think cat's struggle here stems for the fact that she's porting an existing game, I don't think she'd encounter this issue when creating a new game (we'll see when people actually create new games, though).
I think the main issue with the pivot is (apart from being a bit obscure in the first place), that you don't set it to a specific pixel position but to a relative point within the sprite. This does not matter when positioning an object manually in an editor, but it is confusing when doing it in code. Especially with low-res games, where every pixel counts, this can be problematic, because you don't know the exact pixel position you have to use when pivot is 0.5.

Quote
The engine should be geared with defaults that apply to the most common use-cases for point&click (or in the future, like we discussed, we might have templates with different defaults, geared to that specific template use case).
This sounds like a good idea. I thought about suggesting something already.

I don't think it applies to cat's game which is a standard point&click (mechanics wise, ignoring the wonderful puppets ;-D) with standard puzzles.
:-*

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #62 on: 26 Sep 2018, 09:14 »
From the stacktrace it seems that the issue is related to the way you created the walkable area, can you write the code you used for that (or send me the current project)? Thanks.

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #63 on: 05 Oct 2018, 19:49 »
A quick update for everyone following here:
tzach fixed the issue and a few others I've found. They are already merged to the master branch.

And again I have a question:
The default position of text shown for character.SayAsync is a bit strange: it is a bit above (OK) but on the right side next to the character. Why?
I know I could write a custom ISayLocationProvider, but ideally, this basic thing should work right out of the box.



Edit: One more question: What does the ? do in
Code: Adventure Game Studio
  1. _bottle?.GetComponent<IHotspotComponent>().Interactions.OnInteract(AGSInteractions.INTERACT).SubscribeToAsync(onBottleInteract);
« Last Edit: 05 Oct 2018, 20:17 by cat »

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #64 on: 05 Oct 2018, 20:17 »
The default position of text shown for character.SayAsync is a bit strange: it is a bit above (OK) but on the right side next to the character. Why?
Because for some reason I thought the text should go to the right of the character (I was imagining a speech bubble).
Sorry, will fix soon.

In the meantime, you can set a TextOffset for your characters with a negative x to move the text to the left (you can also set a bigger label size so the text in the screenshot won't wrap, the default label width is 250 but your game is high resolution so makes sense to have a bigger label -> we should probably make the default label size resolution dependent).

For example:
Code: C#
  1. cornelius.SpeechConfig.TextOffset = (-100,0);
  2. cornelius.SpeechConfig.LabelSize = (500,500);
  3.  

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #65 on: 05 Oct 2018, 20:22 »
Yes, I think having the size resolution dependent makes sense.

About the other question I sneaked in (the ? in _bottle?.GetComponent...) - it's hard to google a question mark :P

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #66 on: 05 Oct 2018, 20:27 »
What does the ? do in
Code: Adventure Game Studio
  1. _bottle?.GetComponent<IHotspotComponent>().Interactions.OnInteract(AGSInteractions.INTERACT).SubscribeToAsync(onBottleInteract);
The "?." is called the null conditional operator (sometimes nicknamed "the Elvis operator"). If "_bottle" is null it will skip the subscription afterwards.
Here's some more details on this operator: http://www.informit.com/articles/article.aspx?p=2421572

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #67 on: 05 Oct 2018, 21:01 »
Nice!

Monsieur OUXX

  • Cavefish
  • Mittens Vassal
  • Mittens Half Initiate
    • I can help with proof reading
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
Re: Porting game to MonoAGS
« Reply #68 on: 22 Oct 2018, 14:04 »
usually when I'm searching weird operators I just type the name of the character in full letters into Google, followed by the name of the language, and there's always some stackoverflow question that deals with it. All I have to do then it to spot the official name of that operator somewhere in the discussion (here : "conditional operator") and then feed it again in google.

Example :
Code: Adventure Game Studio
  1. what is "C#" "question mark" operator
 

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #69 on: 22 Oct 2018, 19:24 »
Good idea, I'll keep that in mind 👍

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #70 on: 01 Nov 2018, 15:23 »
I found some time to work on the game again today and already found another bug :P

I click somewhere to walk there (walk-to-point). While the character is still walking, I right-click somewhere and the character says something async. The following happens:
  • The character switches to the speak animation but still moves towards the walk-to-point. Since there is no 'speakandwalk' outfit, I guess the character should stop walking?
  • When the say async is done, the character will quickly slide to the walk-to-point without any animation. This happens no matter if I click to stop the sayasync or not.

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #71 on: 01 Nov 2018, 15:41 »
Ah, you're right, the character should stop walking. Even if there was a 'speak and walk' animation, you'd still expect that when you right click, it will cancel the existing walk. A 'speak and walk' animation might be interesting to do, though, when you programmatically say something while walking.

As for the second bug, I think I understand why it's happening, after the say async is completed it doesn't switch back to the walk animation, and because you have "MovementLinkedToAnimation" with no moving animation, it defaults to the animation speed which is really fast (because it's configured to work in tandem with the animation, not as a "regular" walking speed).

Thanks, I'll look into fixing both bugs (and the talk position issue, I haven't forgotten it) soon.

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #72 on: 01 Nov 2018, 19:30 »
Thanks, I'll look into fixing both bugs (and the talk position issue, I haven't forgotten it) soon.

Thanks! No need to hurry, there is still a lot to do on my side anyway.

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #73 on: 09 Nov 2018, 20:03 »
A question about including resources:

The default value for build action when I add a new resource is Content. I noticed that you use Embedded resource in the demo game. What is the difference between those actions and why did you pick embedded resource?

Re: Porting game to MonoAGS
« Reply #74 on: 09 Nov 2018, 20:27 »
A question about including resources:

The default value for build action when I add a new resource is Content. I noticed that you use Embedded resource in the demo game. What is the difference between those actions and why did you pick embedded resource?

Embedded resource means that the file will quite literally will be embedded into the .exe that is built by the .NET compiler. If you go into the build directory of your game you will notice that the file can't be found, but the .exe is a little bigger in size.

Content will add the file into the build directory unaltered.

Choosing one over the other is a preference, doesn't really matter. I guess if you want to hide your assets from the end consumer then embedded resource makes sense, however anyone who is really interested in seeing assets will be able to if they know how.

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #75 on: 09 Nov 2018, 21:24 »
Right, though besides the preference choice (do I want to easily allow people to view/edit individual assets in the game?), I would say that embedding make some stuff easier:
1. If you don't embed then you need to worry about shipping your asset files with the game (and making sure that they're in the same folder hierarchy).
2. If you want to debug your game on mobile devices and you don't embed your assets, then it won't copy them to the device and you will need to copy those yourself.

And not embedding, otoh, makes it easier to swap asset files when developing (and we might add support for hot reloading those assets directly in the file explorer while your game is running -> though it might be possible for embedded assets as well, not sure).

For the reasons mentioned above, the default behavior that I'm currently thinking of for the editor is to have it as contents while developing, and embedded when deploying.
Though once we have a complete editor, we might be able to eliminate those problems with some programming on the editor side, so we'll see.

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #76 on: 10 Nov 2018, 10:49 »
Good to know, I'll stick to embedded for now. Thanks, guys!

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #77 on: 10 Nov 2018, 13:34 »
In my game there is no inventory, but when you pick up things, the mouse cursor will change to it - it will basically be your active inventory item.

So, when initializing the game, I create the inventory items and assign them to the player character. Later, OnInteract with a hotspot, I set the active item:
Code: Adventure Game Studio
  1. _character.Interactions.OnInteract(AGSInteractions.INTERACT).Subscribe(_ =>
  2. {
  3.     _game.State.Player.Inventory.ActiveItem = InventoryItems.Mouse;
  4. });

However, this does not work with the TwoClickInputScheme. I will rewrite it, but the question is: What is the best approach? I could
  • Add a method for setting the active inventory to the TwoClickInputSchemeclass (public void SetActiveInventoryItem(IInventoryItem inventoryItem)). This is pretty simply but has two disadvantages: I have to remember to call it and I will somehow have to have a reference to the instance.
  • The next idea is to subscribe to repeatedly_execute in the TwoClickInputScheme and continuously check for the active item. This would be the AGS-style approach, but it feels unnecessary to do the check every cycle when the active item only changes ever so often. Which brings me to my third idea:
  • Is it somehow possible to attach an observer to ActiveItem? Then the InputScheme could just subscribe to it and do the cursor handling accordingly. The AGSInventory.Items property is already a BindingList, is there something similar for basic properties?

Any ideas/opinions?

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #78 on: 11 Nov 2018, 03:27 »
Hi, there's a new branch with a bunch of fixes for all the latest issues you mentioned: https://github.com/tzachshabtay/MonoAGS/tree/CatFixes2.
If you can test that everything works as expected I'll merge it to master.

Quote
However, this does not work with the TwoClickInputScheme. I will rewrite it, but the question is: What is the best approach? I could
  • Add a method for setting the active inventory to the TwoClickInputSchemeclass (public void SetActiveInventoryItem(IInventoryItem inventoryItem)). This is pretty simply but has two disadvantages: I have to remember to call it and I will somehow have to have a reference to the instance.
  • The next idea is to subscribe to repeatedly_execute in the TwoClickInputScheme and continuously check for the active item. This would be the AGS-style approach, but it feels unnecessary to do the check every cycle when the active item only changes ever so often. Which brings me to my third idea:
  • Is it somehow possible to attach an observer to ActiveItem? Then the InputScheme could just subscribe to it and do the cursor handling accordingly. The AGSInventory.Items property is already a BindingList, is there something similar for basic properties?
Great feedback!
What I did is a combination of 1 and 3.
The two buttons input scheme now has a SetInventoryCursor method, which you can either pass an inventory item or pass nothing which will make it take the current active item for the cursor.
In addition, I added the inventory item change event which I missed somehow.
So, you can now do:
Code: C#
  1. cornelius.Inventory.OnPropertyChange(nameof(IInventory.ActiveItem), () => scheme.SetInventoryCursor());

Quote
The character switches to the speak animation but still moves towards the walk-to-point. Since there is no 'speakandwalk' outfit, I guess the character should stop walking?
When the say async is done, the character will quickly slide to the walk-to-point without any animation. This happens no matter if I click to stop the sayasync or not.
So 2 fixes here:
1. Any user interaction will now trigger stop walking before applying the interaction.
2. I "added" a 'speak and walk' optional animation to the outfit.  If there's a programmatic SayAsync while the character is walking and you have a 'speak and walk' animation it will be used. If you don't have a 'speak and walk' animation then it will stop walking before speaking.
If you're using portraits, for example, and the walking animation itself can be used as 'speak and walk', then you can just write:
Code: C#
  1. cornelius.Outfit[AGSOutfit.SpeakAndWalk] = cornelius.Outfit[AGSOutfit.Walk];

Quote
the default label width is 250 but your game is high resolution so makes sense to have a bigger label -> we should probably make the default label size resolution dependent).
The default label size for speech is now resolution dependent (by default it's 80% of your virtual resolution).

Quote
The default position of text shown for character.SayAsync is a bit strange: it is a bit above (OK) but on the right side next to the character. Why?
Fixed, it's now centered above the character.

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #79 on: 11 Nov 2018, 19:22 »
Wow, that was quick 8-0

The two buttons input scheme now has a SetInventoryCursor method, which you can either pass an inventory item or pass nothing which will make it take the current active item for the cursor.
In addition, I added the inventory item change event which I missed somehow.
Works, but only kind of:
When the player performs a right click when an inventory is active, there is a null reference exception at AGS.Engine.TwoButtonsInputScheme.SetInv entoryCursor(IInventoryItem inventoryItem) in line 37
onRightMouseDown sets the ActiveItem to null, which then triggers the OnPropertyChanged handler.
I'd change SetInventoryCursor to reset the default cursor when null is passed and the active inventory is null. This would help regarding the exception, but also allow the programmer to change back the active inventory programmatically. This is needed when I use the active inventory item on a hotspot and this results in me losing the inventory item.

Another issue: You might want to check if the previous cursor should really be changed. Otherwise, there will be weird issues when setting two active items after each other without returning to the default cursor in between.
Consider renaming _previousCursor to _defaultCursor, then it will be more clear. You could also provide a method SetDefaultCursor. This way you can safely change the default cursor, no matter if there is currently an inventory active or not.

Quote
1. Any user interaction will now trigger stop walking before applying the interaction.
Confirmed (nod) I didn't test the SpeakAndWalk animation, though.

Quote
The default label size for speech is now resolution dependent (by default it's 80% of your virtual resolution).
Works, but 80% seems a bit too much. Maybe 70% is enough? (But this might be because of my setup with the stage frame around it.)
Btw, is it on purpose that the text wraps left-aligned instead of centered? It doesn't look that nice, especially when there is only a word or two in the second line.

Quote
Fixed, it's now centered above the character.
Confirmed (nod)

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #80 on: 11 Nov 2018, 21:38 »
When the player performs a right click when an inventory is active, there is a null reference exception at AGS.Engine.TwoButtonsInputScheme.SetInv entoryCursor(IInventoryItem inventoryItem) in line 37
onRightMouseDown sets the ActiveItem to null, which then triggers the OnPropertyChanged handler.
I'd change SetInventoryCursor to reset the default cursor when null is passed and the active inventory is null. This would help regarding the exception, but also allow the programmer to change back the active inventory programmatically. This is needed when I use the active inventory item on a hotspot and this results in me losing the inventory item.
Should be fixed now (still same branch).

Another issue: You might want to check if the previous cursor should really be changed. Otherwise, there will be weird issues when setting two active items after each other without returning to the default cursor in between.
Consider renaming _previousCursor to _defaultCursor, then it will be more clear. You could also provide a method SetDefaultCursor. This way you can safely change the default cursor, no matter if there is currently an inventory active or not.
Right, I was doing copypasta from the rotating cursors scheme... :-[
Changed it now (there's a default cursor you can pass in the constructor, and also a DefaultCursor property you can set on the scheme afterwards).

Works, but 80% seems a bit too much. Maybe 70% is enough? (But this might be because of my setup with the stage frame around it.)
Ok, I don't have any preference myself, so I changed it to 70%.

Btw, is it on purpose that the text wraps left-aligned instead of centered? It doesn't look that nice, especially when there is only a word or two in the second line.
Not on purpose, but a bit more complicated to get right for all text rendering scenarios, I'm working on it and will update.

cat

  • Mittens Baronet
  • AGS Baker
  • Angelica Crosley
    • cat worked on a game that was nominated for an AGS Award!
      cat worked on a game that won an AGS Award!
Re: Porting game to MonoAGS
« Reply #81 on: Yesterday at 19:54 »
It works except for one thing: I set the default cursor via the constructor, but it is only applied after changing to the inventory cursor and back. Of course I could set the cursor myself, but actually I'd expect this to happen automatically when TwoButtonsInputScheme.Start() is called. The same applies for the setter of the DefaultCursor property.

tzachs

  • Local Moderator
  • AGS Baker
  • Mittens Vassal
  • Parking Goat- games that goats like!
    • I can help with translating
    •  
    • tzachs worked on a game that was nominated for an AGS Award!
Re: Porting game to MonoAGS
« Reply #82 on: Today at 05:06 »
It works except for one thing: I set the default cursor via the constructor, but it is only applied after changing to the inventory cursor and back. Of course I could set the cursor myself, but actually I'd expect this to happen automatically when TwoButtonsInputScheme.Start() is called. The same applies for the setter of the DefaultCursor property.
Done.

Btw, is it on purpose that the text wraps left-aligned instead of centered? It doesn't look that nice, especially when there is only a word or two in the second line.
I'm still not finished with this, but I pushed just enough so it should work for you as you expect, I hope.