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 - jumpjack

#41
(double post)
#42
Quote from: Crimson Wizard on Tue 03/01/2023 19:00:19
Quote from: jumpjack on Tue 03/01/2023 18:48:15The code snippet I pasted above is taken as-is from my script: all rows are one after the other, all inside the same function; moving the declaration out of the function as first line of the script does not help. The sprite IS drawn and it DOES remain there after function ends... but it's the wrong sprite!

This does not sound normal, I expected Khris's code to work.
If the wrong sprite is one with ID = 0, that's a placeholder, which might mean the dynamic sprite was deleted.
Can you post a code that you tried according to the Khris's advice (and which still did not work)?


It's exactly the code I posted in first message; to be sure, I did split first line in declaration part and assignment part, and moved declaration to first line of script, out from any function, so  I have:

Code: ags
DynamicSprite* flipped;
...
...
other things
...
...
function room_Load(){
...
...
      flipped = DynamicSprite.CreateFromExistingSprite(tileIdNorm,  true); 
      flipped.Flip(eFlipLeftToRight); 
      roomOverlay[overlayIndex] = Overlay.CreateRoomGraphical(screenx - tilewidth/2, screeny - 2*tileheight -3,  flipped.Graphic);
      roomOverlay[overlayIndex].ZOrder = isoX + isoY;
      background.DrawImage(screenx - tilewidth/2, screeny - 2*tileheight -3,  flipped.Graphic);
...
...
}

What is really weird is that flipped.Graphic does contain the right value (65), and slot 65 does exist, because it works fine AFTER overlay.CreateRoomGraphical, in DrawImage.
#43
Quote from: Crimson Wizard on Tue 03/01/2023 17:28:57When you assign DynamicSprite to an object, it normally is not copied, but referenced by the sprite ID (this is their Graphic property). Like Khris mentioned above, in AGS script dynamic sprites, like overlays, are deleted when the last pointer to them is removed, which happens when the function ends in your case. This is similar to Overlays. As soon as dynamic sprite is destroyed, the game object looses it and switches to sprite 0, which is historically used as a "placeholder".
Can a warning message be added in the editor console? This is an "autonomous behaviour", I would expect a "null pointer error" rather than automatically changing to default pointer, but if the "autonomous behaviour" is designed to prevent game crash, maybe a warning to developer would be enough.

Quote from: Crimson Wizard on Tue 03/01/2023 17:28:57
Code: ags
Overlay.CreateRoomGraphical(screenx - tilewidth/2, screeny - 2*tileheight -3,  flipped.Graphic, 0 /*transparency*/, true /*clone*/);
Thanks, it works.

#44
Quote from: Khris on Tue 03/01/2023 17:28:42If the first line is inside the function then flipped ceases to exist when the function finishes.
It's news to me that AGS keeps a reference to the original sprite and falls back to it but maybe that's how it works internally.

Anyway, the solution is to add
Code: ags
DynamicSprite* flipped;
above the function, then do
Code: ags
  flipped = DynamicSprite.CreateFromExistingSprite(tileIdNorm,  true);
inside.
The code snippet I pasted above is taken as-is from my script: all rows are one after the other, all inside the same function; moving the declaration out of the function as first line of the script does not help. The sprite IS drawn and it DOES remain there after function ends... but it's the wrong sprite!


#45
What's wrong with this code?

Code: ags
      DynamicSprite* flipped = DynamicSprite.CreateFromExistingSprite(tileIdNorm,  true); 
      flipped.Flip(eFlipLeftToRight); 
      roomOverlay[overlayIndex] = Overlay.CreateRoomGraphical(screenx - tilewidth/2, screeny - 2*tileheight -3,  flipped.Graphic);
      roomOverlay[overlayIndex].ZOrder = isoX + isoY;
      background.DrawImage(screenx - tilewidth/2, screeny - 2*tileheight -3,  flipped.Graphic);

drawImage properly draws the flipped sprite, but CreateRoomGraphical draws sprite slot n.0, although flipped.Graphic is = 65 , and I have static sprites numbered from 0 to 64.

Documentation:
Code: ags

static Overlay* Overlay.CreateRoomGraphical(int x, int y, int slot, optional bool transparent, optional bool clone)

DrawingSurface.DrawImage(int x, int y, int slot, optional int transparency,
                            optional int width, optional int height,
                            optional int cut_x, optional  int cut_y, 
                            optional int cut_width, optional int cut_height)
#46
Quote from: Crimson Wizard on Wed 28/12/2022 19:39:05I honestly still do not understand why cannot you make the non-walking area further from their tiles to compensate for character's sprite width? I think that would be the first thing I'd try, if I were experimenting with such setup. Would not the result look approximately as if the character's "blocking area" was working the way you implied? Is there anything that prevents using this method?
Available walking areas are already quite small, anyway I'll give it a try.

Quote
Quote from: jumpjack on Wed 28/12/2022 19:35:43Anyway I'll disable mouse and use only keyboard control to override this behaviour.

I might mention that mouse or keyboard (as an input method) do not enforce walking behavior. It's all in the script, how the script reacts to the player's input, which functions it uses. It's possible to call same functions in both cases.
Isn't pathfinder algorithm hardcoded?
#47
Quote from: Crimson Wizard on Wed 28/12/2022 19:28:53I tried to explain above, that this "hole" is used only to prevent other characters from walking too close to the "solid" character.
Yes, this is why it looks like a bug: because the character nonwalkable area behaves differently depending on what touches it: a solid body can't cross it, a solid wall can cross it.
Anyway I'll disable mouse and use only keyboard control to override this behaviour.
#48
Quote from: Crimson Wizard on Wed 28/12/2022 12:18:41
Quote from: jumpjack on Wed 28/12/2022 06:46:34I can't find any example or explanation about sprites collisions management, any suggestion? I see I can monitor collision of objects and characters, but nothing specific about sprites (more specifically: dynamic sprites).

The collisions in AGS may be misleading if not confusing at first; primarily because they were meant to emulate some old adventure games and also assume a side-view game.

1. Characters and Objects have Solid property. If this property is set, they actually paint "holes" inside walkable area mask, and update these "holes" as they move. These are rectangular holes positioned around their "feet", and this is what you may see on a walkable debug overlay. These extra holes prevent other character from walking over, so it looks like a collision test. The sizes of these "holes" are determined by BlockingWidth and BlockingHeight properties.
Painting over a walkable mask yourself (as you already do) would give precisely same result.[...]

Quote from: Snarky on Wed 28/12/2022 17:44:50I suppose the pathfinder might be relevant for NPCs, but it's still not clear why you would need to customize it.



Looking at how character move with debug mode enabled to show walkable area, apparently it seems that check is performed on single pixel on foot of the character versus edges of nonwalkable area. In other words, the "nonwalkable hole" around character's feet can overlap the nonwalkable area, as long as the single pixel at (playerwidth/2 , playerheight) is out of the area.

Can this be considered a bug? (I opened an issue, if it's not a bug it will be closed, but it will remain as useful information for posterity).
#49
I see these 3 functions in the editor 3.6.0RC3:

  • AreCharactersColliding
  • AreCharObjColliding
  • AreThingsOverlapping

But only one is documented both in offline and online help, "AreThingsOverlapping". Maybe the others have been deprecated in 3.6.0? I see that there are Character.IsCollidingWithChar , Character.IsCollidingWithObject, Object.IsCollidingWithObject  , maybe they replace the missing global functions?

But I don't understand if I can create objects and characters at runtime.

#50
I can't find any example or explanation about sprites collisions management, any suggestion? I see I can monitor collision of objects and characters, but nothing specific about sprites (more specifically: dynamic sprites).

Are dynamic sprites the only AGS items I can programmatically create? no objects neither characters?

And, as I already asked above: can I access/customize the pathfinder algorithm from a script?
#51
Player can move freely inside its tile, but can't go to adiacent tile if it contains something.

Click on "start emulator with demo game" to see the game I am trying to implement:
https://jumpjack.github.io/oricutronJS/oricutron.html
#52
I found that the demo game included in AGS has a keyboard management script which I can edit at wish.

What about the pathfinder algorithm? I need to check not just the final destination, but also the path: the embedded nonwalkable area method is not enough, I need to manually monitor character positions not just by one pixel on his feet, but by an area around his feet, which shall not overlap nonwalkable areas.

In other words, the non walkable area surrounding player's feet, currently used to avoid collisions with other characters, should be used also to avoid collisions with nonwalkable areas.

I wonder if I can build my 10x10 tiles room by "pasting" 100 invisible characters above the 100 tiles I already pasted to build the room, so I can "cheat" and let the engine make the player avoid the forbidden tiles...
#53
Can I "intercept" character position before it's actually updated, to prevent its updating upon my own conditions?
I see that DestinationX/Y only contain final destination for mouse control, not for keyboard control.
#54
My character apparently has .z and .Baseline values constantly = 0 while it moves around the room (I put their values into a label in global script, together with x and y). Should I enable anything to get them updated?

Additionally, "z" looks more like a "real world" value rather than an "engine value", as if I manually increment .z, the character raises, but if I increment .Baseline, character does not move, but it gets drawn behind some objects with different baslines...

#55
Thanks, now it works.

What about the other questions? My player is currently walking over everything...
#56
Documentation on overlays say that this line:

Code: ags
Overlay* myOverlay = Overlay.CreateGraphical(100, 100, 300);

Should show sprite slot 400 at position 100,100 of the screnen... but I don't see anything.

To see something, I have to add:

Code: ags
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground();
surface.DrawImage(roomX - tilewidth/2, roomY-tileheight*4/2, myOverlay.Graphic);

Same happens for everything else: Overlay.CreateRoomGraphical, Overlay.CreateRoomTextual, Overlay.CreateTextual,...

I can't find any other example on overlays, can anybody help?

But actually I don't know if I need overlays for my purposes: I want to build a room tile by tile, and some tiles have transparent pixels, so the player should be visible when it pass behind such tiles.

Maybe I should use objects instead? Or something else?

Or should I create my own walkbehind image programmatically? I have available two versions for each tile image: one single PNG with some transparent pixels, or a BMP couple (image + transparency mask).

SMF spam blocked by CleanTalk