AGS 4.0 - Alpha 14 for public test

Started by Crimson Wizard, Thu 01/06/2023 14:00:59

Previous topic - Next topic

Kastchey

Ah I see, sorry I missed that in the changelog then. I was looking at the help files within the editor which still list the property as included.

Crimson Wizard

Quote from: Kastchey on Tue 30/01/2024 11:32:22Ah I see, sorry I missed that in the changelog then. I was looking at the help files within the editor which still list the property as included.

Unfortunately, we do not have a proper manual for 4.0 yet. No one have bothered to write articles about new features yet, and also our manual source currently has a problem that it's somewhat inconvenient to have version branches. Hopefully this will be resolved.

Kastchey


Crimson Wizard

#43
Updated to Alpha 8
(Please use download links in the first post)

Contains updates and fixes from 3.6.1 Beta 16 to RC5 (except ones related to backwards compatibility).

Other changes:

Editor:
- Added Enabled and Visible properties to Characters, Enabled property to Room Objects.
- Added FaceDirectionRatio property to General Settings, Room and Walkable Areas.

Script API:
- Added WalkableArea and Walkbehind structs which let work with these region types in OO-style.
- Added Character.Enabled and Visible properties, added Object.Enabled property, Character.on is deprecated.
- Added Game.FaceDirectionRatio, Room.FaceDirectionRatio, WalkableArea.FaceDirectionRatio and Character.FaceDirectionRatio.
- Added File.Rename().
- ListBox.FillSaveGameList(), RestoreGameDialog() and SaveGameDialog() now let define a range of save slots for display.
- Added MoveSaveSlot() which renames a savegame.
- Added "walkarea[]" and "walkbehind[]" global arrays.
- Global arrays of game objects (Characters, GUIs, etc) are now declared as arrays of object *pointers*. From the user's perspective this is a mere formality, as working with these arrays will be syntactically same, but this makes it easier for the engine to handle these arrays and objects internally.
- Removed Object.MergeIntoBackground() function as redundant, and complicating Object's logic.

Engine:
- AudioChannel.Position and PositionMs no longer return a very large value while skipping cutscene.
- DeleteSaveSlot() no longer causes highest save to be renamed to fill a gap in saves.







The new WalkableArea and Walkbehind structs are declared as:
Code: ags
builtin managed struct WalkableArea {
  /// Gets the walkable area at the specified position on the screen.
  import static WalkableArea* GetAtScreenXY(int x, int y);
  /// Returns the walkable area at the specified position within this room.
  import static WalkableArea* GetAtRoomXY(int x, int y);
  /// Gets the drawing surface for the 8-bit walkable mask
  import static DrawingSurface* GetDrawingSurface();
  /// Changes this walkable area's scaling level.
  import void SetScaling(int min, int max);
  /// Gets the ID number for this area.
  import readonly attribute int ID;
  /// Gets/sets whether this walkable area is enabled.
  import attribute bool Enabled;
  /// Gets this walkable area's minimal scaling level.
  import readonly attribute int ScalingMin;
  /// Gets this walkable area's maximal scaling level.
  import readonly attribute int ScalingMax;
  /// Gets/sets the optional y/x ratio of character's facing directions, determining directional loop selection for each Character while on this area.
  import static attribute float FaceDirectionRatio;
};

builtin managed struct Walkbehind {
  /// Gets the walk-behind at the specified position on the screen.
  import static Walkbehind* GetAtScreenXY(int x, int y);
  /// Returns the walk-behind at the specified position within this room.
  import static Walkbehind* GetAtRoomXY(int x, int y);
  /// Gets the drawing surface for the 8-bit walk-behind mask
  import static DrawingSurface* GetDrawingSurface();
  /// Gets the ID number for this walk-behind.
  import readonly attribute int ID;
  /// Gets/sets this walk-behind's baseline.
  import attribute int Baseline;
};

They are accessible from new global arrays:
Code: ags
WalkableArea *walkarea[AGS_MAX_WALKABLE_AREAS];
Walkbehind *walkbehind[AGS_MAX_WALKBEHINDS];

For example:
Code: ags
walkarea[0].Enabled = false;
walkbehind[4].Baseline = 200;

eri0o

Hey, on GitHub the release name has a typo, it should be "v4.0.0.3 (AGS 4.0 Early Alpha 8)". :)

Crimson Wizard

Updated to Alpha 9
(Please use download links in the first post)

Contains updates and fixes from 3.6.1 Beta RC6 (except ones related to backwards compatibility).

Other changes:

Editor:
- Fixed 8-bit images imported and converted for a 32-bit game to not get their colors clamped to a low-precision palette.
- Fixed 8-bit rooms not being usable in the new Editor version (regression in AGS 4).
NOTE: 8-bit backgrounds are still not working fully correct in this version, new imported bgs do not have their palette remapped.

Script API:
- Added VideoPlayer struct, which provides means of playing non-blocking videos rendered onto a sprite that may be displayed on any game object.

Engine:
- Camera will not follow a disabled player character.
- Fixed error occuring when trying to make a screenshot while running Direct3D renderer (regression in AGS 4).
- Fixed sprites leaving traces on background while running Software renderer (regression in AGS 4).







The new VideoPlayer struct is declared as:
Code: ags
builtin managed struct VideoPlayer {
  import static VideoPlayer* Open(const string filename, bool autoPlay=true, RepeatStyle=eOnce);
  /// Starts or resumes the playback.
  import void Play();
  /// Pauses the playback.
  import void Pause();
  /// Advances video by 1 frame, may be called when the video is paused.
  import void NextFrame();
  /// Changes playback to continue from the specified frame; returns new position or -1 on error.
  import int  SeekFrame(int frame);
  /// Changes playback to continue from the specified position in milliseconds; returns new position or -1 on error.
  import int  SeekMs(int position);
  /// Stops the video completely.
  import void Stop();

  /// Gets current frame index.
  import readonly attribute int Frame;
  /// Gets total number of frames in this video.
  import readonly attribute int FrameCount;
  /// Gets this video's framerate (number of frames per second).
  import readonly attribute float FrameRate;
  /// Gets the number of sprite this video renders to.
  import readonly attribute int Graphic;
  /// The length of the currently playing video, in milliseconds.
  import readonly attribute int LengthMs;
  /// Gets/sets whether the video should loop.
  import attribute bool Looping;
  /// The current playback position, in milliseconds.
  import readonly attribute int PositionMs;
  /// The speed of playing (1.0 is default).
  import attribute float Speed;
  /// Gets the current playback state (playing, paused, etc).
  import readonly attribute PlaybackState State;
  /// The volume of this video's sound, from 0 to 100.
  import attribute int Volume;
};


The idea is that you create a VideoPlayer object, and then use its Graphic property to assign the video frame to something, like room object, or Overlay.
NOTE: scaling video is done by scaling an object: for example, you may play a 320x180 video in a 1920x1080 game by assigning to an Overlay and changing Overlay's Width and Height - that's the simplest and fastest (performance-wise) method for stretching video in game so far.

After that you may control the video playback any way you like: start it, stop it, pause and resume, change speed and audio volume.
WARNING: proper Seek is currently not implemented, but Seek(0) works, rewinding the video back to beginning.

Video's FPS is completely disconnected from the game's FPS. Videos are played as a background "process", and their state and displayed frame is synchronized with the game once per game's update. If video's FPS is lower than the game, that would simply mean that the game may display same frame during 2 or more updates. If video's FPS is higher than the game, that would result in frame skipping, because some frames will be replaced faster than the game can display them.

On another hand, you may choose to open VideoPlayer in a non-automatic mode, by passing "autoPlay = false". Then you may use NextFrame() function to advance a frame manually, according to your own rules. There's an important nuance: video's audio track is not played with NextFrame(), but only when the video is played automatically.

Multiple simultaneous video playbacks are supported, but keep in mind that decoding and preparing a frame on screen takes time, so more videos you play in parallel, the more performance hit will be.
In general, following are the factors that slow things down:
- Number of simultaneous video playbacks;
- Video's resolution (but scaling video frame using game object is fast!);
- Video's FPS: the higher FPS the more often the frame has to be decoded and updated, increasing amount of work.


Example:
Code: ags
VideoPlayer *MyVideo;
Overlay *VideoOver;

function ButtonPlay_OnClick(GUIControl *control, MouseButton button)
{
    MyVideo = VideoPlayer.Open("video.ogv", true, eRepeat);
    if (MyVideo)
    {
        VideoOver = Overlay.CreateRoomGraphical(0, 0, MyVideo.Graphic);
        VideoOver.Width = 320;
        VideoOver.Height = 200;
    }
}

function ButtonPauseResume_OnClick(GUIControl *control, MouseButton button)
{
    if (MyVideo)
    {
        if (MyVideo.State == ePlaybackOn)
            MyVideo.Pause();
        else
            MyVideo.Play();
    }
}

function ButtonStop_OnClick(GUIControl *control, MouseButton button)
{
    if (MyVideo)
    {
        MyVideo = null;
        VideoOver = null;
    }
}

function ButtonSlower_OnClick(GUIControl *control, MouseButton button)
{
    if (MyVideo)
    {
        MyVideo.Speed = 0.5;
    }
}

function ButtonNormal_OnClick(GUIControl *control, MouseButton button)
{
    if (MyVideo)
    {
        MyVideo.Speed = 1.0;
    }
}

function ButtonFaster_OnClick(GUIControl *control, MouseButton button)
{
    if (MyVideo)
    {
        MyVideo.Speed = 2.0;
    }
}

function ButtonFrame_OnClick(GUIControl *control, MouseButton button)
{
    if (MyVideo)
    {
        MyVideo.NextFrame();
    }
}

Crimson Wizard

I reposted the recent update again (see a post above), but the problem with room backgrounds in 8-bit games was not fully fixed, and will take more time to investigate and fix.

Importing existing 8-bit games in ags4 now works properly (judging by few tests), but adding new backgrounds does not work correctly yet (they look wrong at runtime).

lapsking

#47
I think I found an issue, unfortunately. It happens on all AGS 3.6. Haven't tried it on 4.0 yet.

I'm making a high resolution game 1920x1080. Khris wrote me a specific code for a new exit hotspot function: Here

It has been working well in all of the rooms. But the last room I'm working on has a glitch. The code is the same and everything. So it took me good few hours to realize glitch happens after interacting with more objects visible=true, visible=false. Is it possible the code is not working because my game is high resolution and because of more objects appearing and disappearing this issue happens? I don't know what else it can be cause otherwise the code is doing fine. That's the only thing that comes to my mind. Some memory or I don't what issue to make code work properly? Maybe I had to post this on AGS 3.6 forums though!

Edit: Sometimes if I leave the room and come back after a reload the issue is resolved. Can it be some kind of a memory overload that doesn't  let the code function properly, since the code also has something to do with storing previous function in memory and reloading it.

Crimson Wizard

Quote from: lapsking on Mon 18/03/2024 05:40:18It has been working well in all of the rooms. But the last room I'm working on has a glitch. The code is the same and everything. So it took me good few hours to realize glitch happens after interacting with more objects visible=true, visible=false. Is it possible the code is not working because my game is high resolution and because of more objects appearing and disappearing this issue happens? I don't know what else it can be cause otherwise the code is doing fine. That's the only thing that comes to my mind. Some memory or I don't what issue to make code work properly? Maybe I had to post this on AGS 3.6 forums though!

Yes, bug reports (and suspicions) are better posted in the forum thread dedicated to the version that you are using.

We'd need to see a exact code that you think is not working, the description of the room (what is present there), and what exactly happens wrong. I won't be able to answer your questions without this information.

lapsking

Sorry, Crimson.  If it does worth having a look, shall I remove this post from here and write it with more details where it was supposed to be?

Crimson Wizard

Quote from: lapsking on Mon 18/03/2024 06:17:23Sorry, Crimson.  If it does worth having a look, shall I remove this post from here and write it with more details where it was supposed to be?

There's no need to remove anything, but surely post the description of this problem with more details.

Baguettator

Hi !

I'm sorry if I missed something, but are the jagged arrays available for custom structs too ? (I mean for structs I created myself).

Crimson Wizard

#52
Quote from: Baguettator on Fri 22/03/2024 05:38:18I'm sorry if I missed something, but are the jagged arrays available for custom structs too ? (I mean for structs I created myself).

There's no such thing as "custom struct" really, any struct acts the same.
The difference in behavior are only added by struct's modifiers, these are: "managed" and "builtin".

Jagged arrays only work with "managed" structs.
EDIT: I made a mistake, apparently they work with non-managed structs too. But I would need to test this to be certain.
EDIT2: Alright, I tested, and they work with anything: simple types (like "int"), normal structs and managed structs.

Baguettator

Good news thanks Crimson !

I tried to upgrade my game with 4.0, but when I run it, it crashes and says for all my rooms "if you have deleted roomX.asc, use the Exclude From Game option". What is it intended ?

Crimson Wizard

Quote from: Baguettator on Sat 23/03/2024 09:53:58I tried to upgrade my game with 4.0, but when I run it, it crashes and says for all my rooms "if you have deleted roomX.asc, use the Exclude From Game option". What is it intended ?

No, of course that's not intended. The "if you have deleted roomX.asc" is shown when the room script file is missing.
On a side note, that message is silly and should be changed.

Did you have any errors or messages during upgrade?
Is there a new "Rooms" subfolder in your project files, and what does it have inside?

Baguettator

I can't look at the project now, but during the upgrade, when I loaded my game into the editor 4.0, I saw a message saying "updating rooms in open format", and it seemed to work well !

Will look at the project asap.

Alan v.Drake

Depending on when it crashed, either the scripts didn't get copied over to the new room format folders, or the Editor is retrying to upgrade the old rooms to the new format and can't find the scripts because they were moved to the new folders.

- Alan

Baguettator

The game doesn't launch, so it crashes just after I click the "run" button.

Crimson Wizard

#58
Were you able to check the "Rooms" folder in your project?

Baguettator

Now, yes ! I hav a "Room" folder with all of my 17 rooms folders, and inside of each one there are "background", "walkable area", "hotspot", "regions", "walkbehind" and "data" files.

The scripts seem to be .crm files, but they are at the root of the game's folder (with othr scripts)

SMF spam blocked by CleanTalk