Community

SCI Programming => SCI Syntax Help => Topic started by: NilG on March 12, 2019, 06:34:24 PM

Title: White Control Line Only Applies When Coming from One Direction
Post by: NilG on March 12, 2019, 06:34:24 PM
Hi again,

This may not quite be a syntax question, but I'm encountering a problem with the white control line in one of my rooms.  Previously, I'd had just a very rough mock up of the rooms, and all control lines seemed to work fine.

The past couple of weeks, I've buckled down and started working on actual backgrounds.  All's been great here until working on one outside scene today.  After coming up with an improved-but-still-rough start where I could place the entries (player can go west, south, or in a building on the screen), I went ahead and created control lines to cage the ego in and open passage where desired.

Testing it out, I've found that the south white control line only seems to apply when the player is coming from the south room; that is, if I come from the east or out of the building, the user can skip right over the white line and end up in the south room through any point on the lower end of the screen.  If, on the other hand, the player has just come from the south room, the white line applies and properly keeps the user confined to the room unless the entry area is used.  All of the other lines in this room seem to work as expected regardless of the entry point; it's just this one wall that fails anytime the user comes from one of the other two rooms.

The entry code is identical for all entry points other than positions and loops:

Code: [Select]
(switch gPreviousRoomNumber
            (north
  (gEgo posn: 230 142 loop: 2)
  )
            (west
  (gEgo posn: 25 148 loop: 0)
  )
            (south
  (gEgo posn: 198 185 loop: 3)
 
(else
(gEgo posn: 150 130 loop: 1)
)
)

and the exit code is similarly plain:

Code: [Select]
(method (doit)
(super doit:)
(if (& ctlCYAN (gEgo onControl:))
(gRoom newRoom: 7)
)
(if (& ctlFUCHSIA (gEgo onControl:))
(gRoom newRoom: 5)
)
(if (& ctlYELLOW (gEgo onControl:))
(gRoom newRoom: 6)
)
)


I'm pretty puzzled what the issue could be.  I've redrawn the control lines a few times in a few different positions, but I'm finding the same behavior regardless.  Any ideas what I could be doing wrong here?
Title: Re: White Control Line Only Applies When Coming from One Direction
Post by: NilG on March 12, 2019, 07:27:15 PM
Just to note, ran all through my other rooms and found there is another room with similar behavior on the south wall only; however, with this room, it happens regardless of which entry I use.  The south wall/control is just ignored, even if I do come in from the south.

The only other two rooms I currently have with south entries work as expected, though both of those only have the south entrance (and the first is the opening room).

Still haven't figured out the reason for this yet, though.
Title: Re: White Control Line Only Applies When Coming from One Direction
Post by: lskovlun on March 13, 2019, 02:06:47 AM
It sounds (and looks) like you're taking the term 'control line' a bit too literally. Actors have an xStep and yStep property which decides how far an actor moves per game loop. If you use control areas smaller than xStep times yStep, then the actor can step right over them. So either make your control lines thicker, or jiggle your actor positioning until the math works out (you can of course also adjust the step counts with the setStep method, but the right step values really depend on your actor's animation, so you may need to redraw him too if you choose to do that).
Title: Re: White Control Line Only Applies When Coming from One Direction
Post by: NilG on March 13, 2019, 07:18:15 AM
Thanks lskovlun, it looks like that's true; reinforcing the lines a couple thicker did the trick for both rooms.  Do you know if it might have anything to do with being at the edge of the screen?  I've seen my guy never crosses the north line in this room despite it being only a pixel thick.  The south walls for both rooms are now 5 and it works, but maybe there's something about the way the ego interacts with the edges of the pics/rooms?  The southern edges are the only ones right up against the edge of the window, so that's my best guess.

Anyway, everything seems happy now, so thank you again.
Title: Re: White Control Line Only Applies When Coming from One Direction
Post by: Kawa on March 13, 2019, 08:54:05 AM
Instead of thickening the lines, why not flood-fill the exterior?
Title: Re: White Control Line Only Applies When Coming from One Direction
Post by: troflip on March 13, 2019, 11:23:10 PM
Hmm, I thought onControl: worked with the base rect of the actor, whose height is sized based on the yStep? So a single line should definitely trigger. Unless somehow they've gotten out of sync? (You can also pass TRUE to onControl: so that it works on a point and not a rect, but you're not doing that here).
Title: Re: White Control Line Only Applies When Coming from One Direction
Post by: NilG on March 15, 2019, 08:32:51 AM
True, a fill's more efficient, I was just going nuts with lines trying to figure out where they'd need to be in order to function.  It doesn't seem coincidental to me that both cases of lines being ignored were on the south-side, but really, if it works, I'm happy with it.
Title: Re: White Control Line Only Applies When Coming from One Direction
Post by: lskovlun on March 26, 2019, 04:16:30 AM
Hmm, I thought onControl: worked with the base rect of the actor, whose height is sized based on the yStep?
Call it a hunch. We had a bunch of bugs like this in the FreeSCI days.