Community
SCI Programming => SCI Syntax Help => Topic started by: MusicallyInspired on April 02, 2016, 12:40:35 PM
-
How does one go about changing the scale of an object while it's standing in place? I've tried manipulating the scaleX and scaleY properties of my Actor, but it does nothing. Do those properties even do what I'm expecting them to do? Do I have to use the horizon scaler instead and change the near and far distance variables dynamically to do what I want? I don't see why I'd have to if I can just manipulate that property manually. Is this even right? I threw this in my doit method:
(if (== scaleAnimate TRUE)
(actorShrink
scaleX: (- (actorShrink scaleX?) 1)
scaleY: (- (actorShrink scaleY?) 1)
)
)
I'm assuming the '?' there requests the value of that property, correct? Still getting the hang of Sierra SCI syntax.
-
How does one go about changing the scale of an object while it's standing in place? I've tried manipulating the scaleX and scaleY properties of my Actor, but it does nothing. Do those properties even do what I'm expecting them to do? Do I have to use the horizon scaler instead and change the near and far distance variables dynamically to do what I want? I don't see why I'd have to if I can just manipulate that property manually. Is this even right? I threw this in my doit method:
(if (== scaleAnimate TRUE)
(actorShrink
scaleX: (- (actorShrink scaleX?) 1)
scaleY: (- (actorShrink scaleY?) 1)
)
)
I'm assuming the '?' there requests the value of that property, correct? Still getting the hang of Sierra SCI syntax.
Have you tried (actorShrink forceUpd:) ?
-
All ScummVM-patched timing issues aside, here's what Freddy Pharkas does to zoom in its logo:
(1
(= local6 0)
(yellSound number: 2918 flags: 1 loop: 1 play:)
(titleView1
setScale: 10 ;<-- start small
setScale: ;<-- interesting!
setPri: 15
setLoop: 0
setStep: 5 5
)
(= local2 10)
(while (< local2 129)
(Animate (gCast elements?) 1)
(titleView1 scaleX: local2 scaleY: local2 show:) ;<-- the show call is also quite interesting.
(= local2 (+ local2 6))
)
(= cycles 1)
)
-
Also, I can't seem to use the increment or decrement operators:
--vVariable
...doesn't work, even though the Companion help file says it should.
-
In the Freddy example, what does this do?
(Animate (gCast elements?) 1)
-
In the Freddy example, what does this do?
(Animate (gCast elements?) 1)
That's the kernel call that updates the graphics on screen. Easily the most complicated thing in SCI16. Without it, you'd just have a tight loop doing nothing.
EDIT: But since your code runs in the context of the main game loop, calling it would solve nothing (and perhaps even cause glitching). It is already being called by the template game.
-
Also, I can't seem to use the increment or decrement operators:
--vVariable
...doesn't work, even though the Companion help file says it should.
Use (-- vVariable), with a space.In the Freddy example, what does this do?
(Animate (gCast elements?) 1)
It renders the changes, is all I understand of it.
-
Well, if the Animate command is not used then no animation occurs on screen. In fact, it doesn't even "show:". But when it's there it works. So, it works with the Freddy code (forceUpd: does not work). I don't even need the doit method in this case. I think the "show:" is only there to make the thing appear for the first time, it's just called redundantly each time the loop repeats. The "setScale: ;" is also necessary, if it's not there there is no animation either. Though, "setScale: 10;" (or in my case 100) doesn't need to be there at all, I suppose seeing as I'm shrinking from 100% scaling instead of enlarging.
-
rm141 in my "Explore SCI 1.1" game does this. It's a simple matter of using ScaleTo:
(portal setScale: ScaleTo portalSize)
It animates over time to the new scale though - maybe that's not what you want. You can probably change that by using an instance of ScaleTo, and then specifying a step or changing the waitCount or something (just giving the ScaleTo code a quick look over, not sure what will work).
-
Also, I can't seem to use the increment or decrement operators:
--vVariable
...doesn't work, even though the Companion help file says it should.
kawa got you pointed in the right direction, but would you be able to point me to where in the help file it still uses that syntax? I thought I changed everything to the new syntax.
-
"Help/StudioCompiler/arithmetic.html?highlight=decrement"
It also incorrectly shows how else statements work with if. In the help file it shows "else" with its own brackets, but it's supposed to just sit inside "if" without any brackets.
Also, it seems the caveat of doing the scaling animation this way with the Freddy code is that it does not accept any user interface input at all until the animation is finished, and then it triggers everything you pressed while you were waiting. Probably why the Animate command is needed as it must put the entire game loop on hold to do its own thing. This is what I'm using right now. In order to get it to scale at an acceptable speed I had to throw in Wait commands in nested if statements. I'm sure there's a better way to do this. I'm also trying to begin fading it to black after it reaches a certain scale threshold.
(1
(Palette
palSET_INTENSITY
0
254
100
)
(actorShrink
setScale:
setPri: 15
setLoop: 0
setStep: 5 5
)
(= actorScale 128)
(= actorIntensity 100)
(while (> actorScale 0)
(Animate (gCast elements?) 1)
(actorShrink scaleX: actorScale scaleY: actorScale)
(-- actorScale)
(if (< actorScale 100)
(-- actorIntensity)
(Palette
palSET_INTENSITY
0
63
actorIntensity
)
)
(if (> actorScale 64)
(Wait 4)
else
(if (> actorScale 32)
(Wait 3)
else
(Wait 2)
)
)
)
(self cue:)
)
-
"Help/StudioCompiler/arithmetic.html?highlight=decrement"
It also incorrectly shows how else statements work with if. In the help file it shows "else" with its own brackets, but it's supposed to just sit inside "if" without any brackets.
Umm... that's the documentation for the SCI Studio compiler.
SCI Studio syntax:
http://scicompanion.com/Documentation/StudioCompiler/arithmetic.html
Sierra syntax:
http://scicompanion.com/Documentation/Compiler/arithmetic.html
For the scaling issue, have you tried using ScaleTo yet?
-
*shrug* I clicked on SCI Companion Help and that's where it took me.
Giving ScaleTo a shot now. At a glance it looks like exactly what I need.
-
Ok, it's not working. It's being called but it doesn't actually animate. It just sits there.
-
Ok, it's not working. It's being called but it doesn't actually animate. It just sits there.
Can you post your code? Again, I do this thing exactly in the "explore SCI 1.1 game", and it works fine.
*shrug* I clicked on SCI Companion Help and that's where it took me.
It should take you to the help index page.
-
Ah, I was calling it incorrectly. I wasn't invoking ScaleTo in setScale.
And yeah, I did a search through help so it probably took me to Studio SCI syntax entries.
EDIT: Really screwing up. It shrinks horizontally and maxes the height scale to the size of the screen and shrinks smaller than the target size I entered. Then it suddenly blows up to larger than the screen size and freezes there. It also locks up the whole game. Something wrong with ScaleTo's code maybe? I'm just running this as a test which should scale it down 50% 1 step at a time with 1 wait count and then cue the next state:
(actorShrink setScale: ScaleTo 50 1 1 self)
-
That code works just fine with me.
You're sure you're just calling this once? And it's being called from a cue-able object? (e.g. a method in a Script instance).
-
Never mind any of that nonsense. I had the Actor setting its scale to 100 in the init method of the room. Removing that makes it work properly. Strange behaviour, though. Will do more experimenting and let you know if I got it working the way I want without problems.
EDIT: Eureka! Now I just need to get the palette intensity to fade out with it after it reaches a certain threshhold. What's a good way to do this and sync it up with ScaleTo? How I had it before was once the scale reached level 100 (of 128) the intensity (0 - 100) would decrease with it until both reached 0 at the same time. Would I need to utilize the doit method for this?
-
Never mind any of that nonsense. I had the Actor setting its scale to 100 in the init method of the room. Removing that makes it work properly. Strange behaviour, though. Will do more experimenting and let you know if I got it working the way I want without problems.
There's more than just scaleX and scaleY properties. There's also scaleSignal and maxScale, and I suspect if you manipulate some of these without also changing the others, then things get wonky. Hence why they made the setScale method and the ScaleTo scaler.
EDIT: Eureka! Now I just need to get the palette intensity to fade out with it after it reaches a certain threshhold. What's a good way to do this and sync it up with ScaleTo? How I had it before was once the scale reached level 100 (of 128) the intensity (0 - 100) would decrease with it until both reached 0 at the same time. Would I need to utilize the doit method for this?
I can think of a few ways:
- Make an instance of ScaleTo in your room file and override its doit method (being sure to call (super doit:)), and then do whatever you want in the doit to change the palette. Then use this instance in the setScale call instead of the ScaleTo class.
- Given that you know the scale step and the start/target scales, you should be able to figure out how many cycles the scaling operation will take. So have a Script whose doit changes the palette intensity over this many cycles.
-
This is what I ended up doing in doIt. I couldn't figure out what to match the palette manipulation with so I made it condition on actorShrink's scaleX property, which would be the same as scaleY. However, it was far too fast so I made it only decrease after every 5 decrements of the scaling value. This slowed it down enough and also matched properly with the scaling rate, since I change the rate to shrink faster the smaller it gets.
(if (and (== actorFading TRUE) (> actorIntensity 0))
(if (== (mod (actorShrink scaleX:) 5) 0)
(-- actorIntensity)
(Palette
palSET_INTENSITY
0
63
actorIntensity
)
)
)