I’ve been thinking about this quite a lot of the last few days, and I think these gotos are still a good thing, but there are some questions about how to control what they do and have access to that I’m still trying to figure out.
Let me start with some of the problems I’m trying to solve:
Looping animations
Currently, looping animations are made by making a tall image, which is kind of silly. Why should a looping animation have a different format than a non-looping one? Why should you use different tools to make them?
Having a goto at the end of the file seems like a better way to make a looping animation.
How long to show an image or animation
So, currently we have different rules for looping and non-looping animations. Non-looping animations are played until the end, unless interrupted by something else, while looping animations have a time limit, and if that time limit is -1, we use the length of the corresponding sound effect. The time limit is stored in a separate config file, but cannot be specified on a per-file basis.
For now, I have not figure out a better way to do this, still pondering.
Customizing battery meters
Today, the battery meter is rendered by code. It’s made up of a repeating series of glpys. The glyph itself is easy to switch out, but you can’t do anything cool with it. It would be much better if battery meters was a set of images, or an animation, and we would then choose the right image (or animation) based on the current battery level to show.
Some version of these if statements can make that possible. It’s also possible to do some animations and transitions and stuff.
Bullet Counters
So, we have a way to do bullet counts using custom controllers. It is however not particularly user friendly. In addition, It’s simple glyph rendering, so if you wanted to do something like a bar graph or something you would need to re-code it.
My thinking is that bullet counters should ALSO be animations, just like the battery meter. That way they are fully customizable. However, it may get a little silly if the bullet counts are high.
Now, I was thinking that if you have a phaser, you could want to take a battery meter animation and use that as your “bullet counter”. I can think of at least two ways to accomplish this:
- I can write a tool that “disassembles” a PQV file into a script and a bunch of images. Then you can modify the script and re-assmble it to do what you want.
- I’m thinking that the animation code could call
prop.getVariable(variableName)
to evaluate the conditions. This way the prop could have total control over the values returned. So the prop would just have to do something like:
int getVariable(uint32_t variableName) {
if (varaibleName == PO_fourcc("BATT")) {
return bulletCount * 100 / MAX_BULLETS;
}
return PropBase::getVariable(variableName)
}
Of course, this would make it impossible to have the display actually show the battery level, so it might not be that great of a solution…
Transitions
This one is tricky. Today, when an event occur, we generally immediately switch to the animation for that event. The fact that the resolution is very low helps hide the weirdness this sometimes causes in animations. It would be nice if we could somehow have better transitions between effects on the display.
Unfortunately, I don’t actually have solution for this yet. One potential option would be to use the gotos and let them handle the transition from one loop to another inside the file itself. However, this quickly gets complicated. Also, it makes it hard to customize things by just moving files around. Also, we may need to know if the file is handling it or if the controller is supposed to switch to a new file.
Animations AND Bullet Counts / Battery Meters
In some cases, it would be super cool to have a counter, or a bar, then have an animation running in the background. While it’s theoretically possible to do that with just gotos, we would need N x M frames to do it, where N is the number of frames in the animation, and M is the number of frames in the bar or bullet counter. While that might work in some cases, it will quickly become impossible if N or M is not a fairly small number.
Now, the only solution I can come up with for doing this is to have layers for our animations, just like we have for styles. The base layer would be the animation, and the second layer would be the counter, or the bar. Sounds simple, but implementing it is another matter. The biggest problem is that alpha blending is a semi-expensive operation, and the CPU we have is not very fast… But then there is also the weirdness of having two different layers to control. When an event happens, do we swap out the top animation, the bottom animation or both? Who or what decides? Not sure…
I think for now I’m going to leave this as a future thing, even if it would be cool.
Fulll-on GUI systems
Up until now I’ve been thinking that menu systems would have to be coded into the prop, and that a special controller would have to be made to support it. However, after thinking more about it, it occured to me that these conditions could easily be made into a menu system. All we would need is a way to make conditions for button presses, AND a way report actions back to the prop.
The prop would need to translate button presses into events, this could either look like:
SaberBase::DoEvent(GUI_BUTTON_PRESS, 1);
or maybe it would be done through getvariable, something like:
int getVariable(uint32_t variableName) {
if (varaibleName == last_button_) {
last_button_ = 0;
return 1;
}
return PropBase::getVariable(variableName)
}
Now, in addition to the GOTOs, there would have to be something similar to TrDoEffect
, or maybe something that runs a command so that the menu system can tell the prop to DO something when a menu entry is selected. A menu script could end up looking something like this:
m1s1:
import "menu1_selection1.png"
if SELE goto select_m1s1
if DOWN goto m1s2:
goto m1s1
m1s2:
import "menu1_selection2.[ng"
if SELE goto select_m1s2
if UP goto m1s1
goto m1s2
select_m1s1:
run "toggle setting1"
import "menu1_selection1_selected.mp4"
goto m1s1
select_m1s2:
run "toggle setting2"
import "menu1_selection2_selected.mp4"
goto m1s2
This would then get compiled into one PQV file.
The menues could also have little animations in them, but the scripts for that would be complicated.
Again, having multiple layers would make menu systems like this very very cool, just like it would be for bullet counts and the like. But even without that, it would allow for some fairly nice and customizable stuff.
Anyways, I’m sure there is a ton of stuff I’m forgetting, but it’s getting late and my brain wants to stop thinking now.