Alpha issue

Blitz3D Forums/Blitz3D Programming/Alpha issue

Cubed Inc.(Posted 2013) [#1]
For some strange reason, whenever I insert this code into my game, the alpha function for the camera's fadescreen doesn't work.



I'm honestly stumped. Do you think it has anything to do with these two lines being within the same loop.




Yasha(Posted 2013) [#2]
Well for one thing, those two lines aren't within the same loop. They're defining two nested loops. That means that every camera will be iterated over for each player, which looks like it's a bit redundant if the player is being positioned in an absolute way based on the camera, because any cameras but the last one in the list are wasted effort and all players will depend on that last one only (perhaps players should keep track of which specific camera is relevant to them?).

Unless I'm being blind though there's nothing in that code that does anything to the camera, so...it shouldn't...

One thing I notice though. You haven't declared your loop variables as Local. As a result, if you have any global variables named 'p' or 'c', they will be used instead of locals for this function! That means they will be set to Null after the loop ends. That's the only way I can see this code affecting anything external related to cameras.

Tips:

1) Use long names for globals, e.g. MODULE_GlobalCamera.camera, MODULE2_private_HiddenCamera_.camera. That way there's no chance of hitting a name by accident.

2) Always declare Local variables instead of relying on automatic declaration! That way, even if you do have a global of the same name, a new local variable will be created and used safely anyway; the global will be "hidden" from the function. This prevents accidental mutation.

3) Get the editor IDEal. It will highlight local, global and undeclared variables in different colours, alerting you to any potential errors of this sort. It even handles type mismatches!


Cubed Inc.(Posted 2013) [#3]
Very helpful information! Thank you!