My name is Jelle and I'm working on an AGI-game. Until now everything went just fine, but I want my code to be well-structured. I wanted some birds to fly around in allmost every room, so I put the birds in one logic file (no=110) and I put a logic call in every other room ( call(110); ). This is my code:
When I play my game, everything goes wrong! The rooms are ALL GREEN AND IT'S JUST ONE MESS!!! Nothing works (I can't even quit my game.) But when I put the code from logic 110 in every room, there's no problem at all...
- I looked at the code of Space Quest II (logics: 13,14 & 15 for the rooms and logics 107 & 108 for the 'animal-animation-code'). -
Does anybody know what I am doing wrong?
(sorry for my bad English)
|Joey||I had the same problem. When you cant even quit, I believe it is a memory issue. I had the same thing happen, and I still havent fixed it. You may want to fix the wander code. That will make them go all over the place, even on the ground and stuff. (Unless you put a priority line up in the sky and positioned the birds up there.) I dont know what would be wrong. If you cant quit, you may have too many things loaded.|
|jelleghys||I don't think it's a memory issue, I rather think it's one of those non-ending-loops or something... The wander-around-stuff works fine, no problem with that... When I put all of this junk into one Logic it works just fine, but it may be easyer to put the birds in a different logic. Then I just have to put a 'call(no);' in all the logics of the rooms I want those birds in.|
You say the rooms are all green.. is this before or after you put call(110) in your code? are you saying the background is green but the birds look ok?|
have you tried with just one bird?
|Rainer||Not sure if this is the problem, but try putting call(110) after the line show.pic().|
I thought it might be that.. but all it does it just make the picture buffer visible.. the views should still be added to the picture buffer even if it's not visible.|
If you show the picture after, you prevent all the sprites "popping up"
I've found the error: before I call logic 110, I need to load every view used in logic 110... Something like this:|
BTW: How does the attach-stuff work on this board? Is there a hidden upload-button or something? The only button I see is Browse.
ohh.. of course.. that makes sense. I should have noticed it.|
|jelleghys||Could you explain me why it makes sense? Because I found that out by mistake... Why should I load the views in the rooms, why can't I load them in logic 110?|
ah.. it gets complicated. Basically, everything gets loaded onto a stack, and when you discard something, everything on top get's discarded as well.|
ie, the memory would be something like this:
LOGIC0 -> EGO -> LOGICX -> LOGIC110 -> VIEW44
this is in your old code, just after you load view44. LogicX is the other logic code.
when you return back to logicX, it just discards logic110.. but this means view44 is also discarded.. but it still hangs around in memory.
LOGIC0 -> EGO -> LOGICX -> <gap> VIEW44
this actually works since it's still in memory UNTIL you load something else in logicX, then it will overwrite view44 and your view will get corrupted.
so say you had:
the memory would be:
LOGIC0 -> EGO -> LOGICX -> VIEW10 -> SOUND50
but your animated objects will still think view44 is in memory and trying to point to it. however view44 has been overwritten.
so anyway.. if you load view44 beforehand, when you discard logic110, view44 will still be in memory
LOGIC0 -> EGO -> LOGICX -> VIEW44
I hope that makes sense.
Another solution, so you can load your views in a separate logic, is to manually load the logic before you call it. That way the logic still hangs around in memory afterwards.|
The default with call() is to load and discard the logic if it isn't in memory already.
Thanks a lot! I know the stack-stuff, but I hadn't thought of it at all. When I look at the real sierra games, they actualy do load the logics before calling them,... like you said.|
The only problem I'm dealing with at the moment, is that the fix.loop doesn't seem to work in the sub-routines (like my 110), but there's probably a minor bug that ruins everything. I'll look for it myself.
THANKS FOR YOUR HELP