Looking for suggestions to make interface

Started by iamlowlikeyou, Thu 13/01/2011 18:02:32

Previous topic - Next topic

iamlowlikeyou

Instead of making several posts about all the different details, I thought it would be better to ask for suggestions for how to make the overall interface I want to create for my game.

I am using the KeyboardMovement module, so the main character is controlled with the cursor keys (pressing, not tapping). This works perfectly.
Now I want to make it so that the functions Interact, LookAt, TalkTo and UseInv are swapped by a key and the selected function is executed by another key, so basically all control is done with the cursor keys and two other keys.

The way that the character should interact in all ways with other characters, objects, etc. is that when he walks up to the "object" a label will display the name of that "object" (if he walks away the label disappears again of course) - so as long as that name is displayed, the player is able to interact by pressing the function key (which executes the selected function), and that function will then be carried out on the "object". The "object" should of course only be available as long as player faces it (which gives some trouble with using simply a hotspot, as player can still stand on the hotspot while facing away from the "object").

Earlier I created a post asking about the "faceobject" aspect, and I'm sorry for repeating this - but like I said, I thought it would be easier to help me, if you get the overall idea of what it is I want to make...
I think I got the needed details, but please ask if I forgot something.

I'm still pretty new to AGS and programming in general, so please bear with me if I'm a little dim :D

Khris

You need a general way of handling interactions, preferably with as less duplicate code as possible.

Like I said in the other thread, use regions.
I'd use custom properties to assign a region number and direction to every object, then re-check all as soon as the player moves or stops.
I.e. loop through all hotspots and objects, read region # and direction and compare them to region under player and player's direction. The first match is the currently looked at object/hotspot. Store that, print the name on a label.
On pressing the interaction button, call LookedAtObject.RunInteraction(mouse.Mode);

I'm at work, I might supply some code later, or somebody else will.

iamlowlikeyou

#2
Thank you for replying!
Like I said, I'm pretty new, so it all seems quite confusing at the moment.
If you (or someone else) could come up with suggestions for the coding it would be greatly appreciated!

But... if I simply check for player's direction, won't that mean that whenever player is facing in a specific direction while on the region, it prints the text? The trouble with this is for example that if I have an object that player can walk all the way around, the direction needed to actually face the object differs according to which side of the object player is.

EDIT: I was thinking if I could do something like:
If standing on region AND facing direction (check loop) AND player position is > or < than something.
In that way I could make the seperate facing directions "defunct" when walking beyond certain positions, and thus fix the problem I described above.

Khris

Here's another idea; it's a bit complicated to set up but should work well:
Every region has four properties, one for each direction. When the player steps on a region facing right, the "right" property is read. Say it's "o2", that means the player is currently facing object 2. "h5" is hotspot 5, etc.

Another idea:
Instead of using regions, you assign a foot coordinate to every hotspot and object, i.e. say a picture on the wall has its foot at the ground beneath it directly at the wall.
If the player is close enough and facing the foot coordinate, say with a tolerance of +/-10°, they are looking at the object/hotspot.

In general, since there's no mouse, you could in addition to the label indicate the currently looked at hotspot by using a marker that's displayed at their center. You wouldn't even need to specify all the coordinates for the marker manually, you can calculate/detect the center of an object/a hotspot easily.

iamlowlikeyou

But giving the region four properties, one for each direction, wouldn't that still have the problem I mentioned? That is that the "right" direction in one position may not necessarily be the right direction in another position...

Generally what I need is a way to check whether the player is FACING a certain spot or not - if he faces that spot while standing on the region, something happens - if is not facing the spot while standing on the region, nothing happens. Given the situation where what happens is the text printing on the label, it would of course need to "reset" the label if player is not facing the spot...

Your other idea I simply don't understand :D
But perhaps you can explain further, and even provide some code when you have the time?

Khris

The problem you mention only arises if you draw the regions "wrong".
Say there's a tree the player can walk around. Instead of a single region, you draw four of them, one at each side of the tree. Then you assign the tree as "right" object to the region to the left, and as "left" object to the region to the right.
I've just found out that you can't use more than 15 regions though, so that approach is bound to get overly complicated as you'd probably have to use regions more than once to overcome the limit and thus differentiate things further.

I'd say let's ditch the regions for now and use the second method I mentioned.
I'm going to create a small demo using AGS3.2 and put it up here as soon as it's ready.

iamlowlikeyou

Ah, I understand. But yeah, if the limit is 15 regions, that won't do.
I'm looking forward to that demo :D

Khris

Okay, "done" :)

I've implemented basic actions. Inventory, save/load doesn't work yet.

All the functionality is in the NoMouse module, with the exception of two GUIs. One is used as marker (gCursor), the other one for displaying the action (gActiontext). There's a third GUI for debugging purposes (gDebuggui) which you won't need in the actual game, you'd have to remove the debug stuff from the module though to make it work without the GUI.

Note that there's a big chance that you can't simply put the module and three GUIs in your game and everything works flawlessly. I've based this on the default game, so additional functionality you might have implemented might break.

Just try it.

http://db.tt/PDpagAo

iamlowlikeyou

#8
I tried the demo game, and it's looking really great. This is exactly what I was looking for :D

I will have time to take a look at the codes etc. later today or tomorrow - I can't wait.
Thanks a lot for helping me out with this!

I'll most probably get back to you with more questions about the code...

EDIT: Okay, my first question is where can I get the 3.2 version, so I can open the game?

Khris

In the technical thread there's only the installer; I've put a rar archive here: http://db.tt/92dNOg8

I tried to comment everything, but near the end I just wanted it to work and got a bit sloppy.

iamlowlikeyou

Nice, thank you!
I'll let you know when I've tried it out.

SMF spam blocked by CleanTalk