Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Joacim Andersson

#1
20 years ago I made 3 games using the AGS engine, this trilogy was about a magician named Melrin.

I also had plans for a 4th game that took place before the original trilogy, but work got in the way and I never finished that game.

Until now!

Well, it's not finished yet but it's in development, and it's called Betrayal of the Crown.

The Story
There has been an assassination attempt on the King, and the main suspect is the King's brother Prince Eevail, however, the King himself doesn't want to believe that his own brother would try to do something like this.

So the Magician Council of the land decides to send out one of their prominent wizards, Alfrin, to investigate the crime. However, during the planning, someone broke into Alfrin's house and ripped out all the pages of his book of spells, without them he can't perform his magic. This act of thievery reveals that there is a spy within the Magician Council.

So Alfrin asks his disciple to follow him along on his journey, their task is to find the missing pages of Alfrin's book, find out who the spy within the council is, and find evidence that the Prince is responsible so they can convince the King.

Playing the game
So this game has two playable characters and you can freely switch between them. The left mouse button, except for walking around, does all the main interactions, Talk to/Open/Pick-up, and so on, while the right mouse button means "Look At".

Progress
* Graphics ~85%
* Puzzles ~50-60%
* Scripting ~60%
* Music 0%
* Sound Effects ~75%

I have a demo available, it contains parts 1 and 2 of one of the characters and part 1 of the other in this 3-part game. The Demo is fully playable and you will be told when you've reached the end of it.

A Web and Windows version is available:
https://brixoft.itch.io/betrayal
Password: Pnc4dvBoC

Screen shots




#2
Quote from: eri0o on Sun 26/01/2025 20:41:10There is a way to use SetPosition of sorts, in the web, the website has to be fullscreen and then you have to set relative mode in the mouse
I rewrote the code so it doesn't use SetPosition, which I should have done, to begin with, I was just lazy. Anyway, now it works, kind of, it still acts a little bit strange on the web, but it's a tiny thing that I don't care about.
#3
Yes, I'm using mouse.SetPosition to move the mouse to the same X and Y position of the button you've started to drag. This was done for pure laziness on my part so I didn't have to calculate the new position of the button as you start to drag it.

Now that you point it out I see that this is obviously what causes this erroneous behavior.

Now comes the tedious part which requires a recompile just to test the slightest change.

Thank you both so much.
#4
Well, the game doesn't work. You drag blocks around but on the web they can jump on top of each other. A block that only should be possible to drag and drop in the horizontal direction can jump down or up in the vertical direction. None of that happens when I run it in the editor, or as a compiled EXE file.
#5
I have a mini puzzle game within my game that works perfectly in the editor or compiled for Windows but acts very weirdly when compiled for the Web.

I can't explain why, I have created a minimum version that only has the mini puzzle game and uploaded the source to:
https://brixoft.itch.io/unblockme

Password: UnblockMe

Can any of you AGS experts help me understand why this code doesn't work on the web?
#6
Quote from: eri0o on Thu 23/01/2025 15:18:34You can use multiple variables and a type or an int for ID and the type.

In my ArrowSelect module I did something similar with interactives

https://github.com/ericoporto/arrowselect/blob/32625e45aea809e9e9e8acbefed37225c8c01465/arrowselect_demo/arrowselect.ash#L72
Yes, using a custom enum to remember the type is what I'm now doing (or started to do after the first reply in this thread). Thank you.
#7
Quote from: Danvzare on Thu 23/01/2025 12:38:48But if you really wanted to keep to the same idea. The way I'd try and tackle it, would be to store the necessary variables just before showing the GUI and then essentially ending the interaction. Then when you press to close that GUI, it takes those variables and sends them to a function that essentially finishes off the interaction that had started.
Yes doing something similar to this was my first attempt, however, to do this I have to keep track of what the player clicked on and since AGS doesn't have a generic type (like in C# or Java or anything like C++ Template),  I  can't, in one variable, store a hotspot, object, or character. So I dropped that approach.

If AGS at least had something like System.Object or a Variant data type, this would have been easier.
#8
That it doesn't process any input on a GUI during wait, is the first thing I noticed, since I tried something like this:
Code: ags
gMyGui.Visible = true;
while (gMyGui.Visible)
  Wait(1); 
But then I, unfortunately, couldn't use the GUI. So I guess I have to rethink my approach and develop another solution. But thank you anyway for your reply.
#9
I want under certain conditions to show a GUI when an inventory item is used on a hotspot, character, or object in the scene. In most cases this inventory item can't be used on that hotspot (object or character) but in any case, I want a GUI to be shown, but then my function code should pause until the GUI is closed.

So my question is: Does AGS have something like coroutines or something else I can use to yield the execution of a function?

I'm using version 3.6.1
#10
Quote from: Mininthebox on Tue 07/01/2025 18:19:03I want all speech to be displayed in a specific area
If it's the speech itself you want to appear in a specific area, you can use the SayAt() method of a character.
Code: ags
player.SayAt(someXvalue, someYvalue, widthOfText, "What am I saying?");
But maybe I've misunderstood you.
#11
Quote from: Crimson Wizard on Thu 09/01/2025 10:35:24Looking at your examples, I cannot tell which kind of functionality exactly are you referring to.
I just wondered if AGS scripts allow an unspecified number of arguments, in my (stupid) example above you could in C# pass any number of int arguments to the AddUp() method. The AGS API has that in for example in the String.Format() method and in the AbortGame() function.

In the String.Format() method (which is also supported by the Display() function), the first string you pass in tells the type of the arguments that follow. However I was looking for something like my example above where you say that all arguments will be of the type int, you just don't specify how many the function accepts.

But, OK. Your reply answered the question that AGS scripts don't support that functionality, so thank you for that.
#12
Some of the built-in API functions in AGS allows for a variable number of arguments to be passed to them. Does the script language also support that?

For example in Java you can write:
Code: ags
private int addUp(int ... nums) {
  int sum = 0;
  for (int num : nums)
    sum += num;
  return sum;
}
Or in C#:
Code: ags
private int AddUp(params int[] nums)
{
  // Before anyone tells me, yes I'm aware that you can use 
  // the Sum extension method from System.Linq:
  // return nums.Sum();
  int sum = 0;
  foreach(int num in nums)
    sum += num;
  return sum;
}
#13
Quote from: Crimson Wizard on Mon 06/01/2025 12:36:07AGS already sort of can have "layered backgrounds with transparency", which is if you use objects and room overlays.
Did you also mean to have layered masks along with these backgrounds maybe? Or anything else?
That's pretty much what I'm asking for. Today if the background is larger than the viewport, AGS will automatically scroll the background when the player walks around, but I can't have different layers of the background to scroll at different speeds without using overlays or objects, but that doesn't stop the actual background from scrolling, and it requires a lot of extra code. It would be great if you could have 3-5 layers of background images stacked on top and give them some Z layer (even though we're talking 2D games), of course, I understand that then hotspots have to be layered as well.

Since I don't want to use Beta or Alpha versions of the software, I'm not really aware of all the plans you guys have for AGS 4, so that's why I asked.
#14
Quote from: Postmodern Adventures on Mon 06/01/2025 09:19:30The easiest way to make a parallax effect without modules is this:
Code: ags
 oparallax.X=-(0)-(GetViewportX()/6);
I fully understand that you can create parallax effects using different objects today. However, my question was if there were any plans to implement different layered backgrounds (that could have transparency) in AGS 4. What I got from the various replies in this thread is that there currently are no such plans.
#15
As Crimson Wizard already said, you might need to create your own variable and toggle its value to see if a character is following another. Even if you download the beta version of 3.6.2 it might be good to remember this since you might need to do completely other things that you must remember the state of.

Another thing for this particular case is depending on the design of your game, Will the character that will follow you even be in this room if it doesn't follow you? If not, then just check the room they're in:
Code: ags
if (otherCharacter.Room == player.Room)

To make a character invisible you can simply set the Transparency property of the character.
Code: ags
someCharacter.Transparency = 100; // Set to 0 to make it visible
Or you can have the character in a different room (or -1 for no room) and simply set it to be in this room when it needs to appear.
#16
How is the list box filled when you call Debug(3. 0) (or press Ctrl+X)?
#17
Today, you can add several backgrounds to create an animated background, but what about different layered backgrounds to create a parallax effect?
#18
Thank you, but I think I'll keep my approach.
#19
In a game I want the character to look into a telescope and I then switch room, where the player isn't visible, instead it only sees part of the room, like a circle and everything else is black. However, this circle should be controlled by the mouse so you can see different parts of the room.

I similar effect is done in King's Quest II: Romancing the Stones, when Graham enters a dark area near the Sharkees, only the area around the player is lit up and the rest is dark.

I know about SetAmbientLight and Region.LightLevel but that doesn't affect the background.

Is there any way I can do this?

EDIT: I solved this by using an object that has a black sprite with a transparent "hole" in the middle. The sprite is twice the size of the room, and I move the object relative to the mouse position. However is there a smarter way of doing this?
#20
I spoke too early, it seems like nested structs are also not supported in v. 3.6.x. If AGS treats a struct as a type why can't I use that type in another struct?
SMF spam blocked by CleanTalk