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

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!