not always, it's valid if there is only 1 line after it without braces
@Yero008
try either have sw static:
or make it global, i.e. define it outside functions in global scope, for example:
bool sw = true;
void DarkGDK ( void )
{
...
}
because, your code seems to be inside a loop, and sw is initialized to true everytime the loop is executed, meaning it's always true unless object Y is 400, when that happens, the code below it will move down, and Y will be 399, then the loop goes again, sw is true, and we're at 399, thus, will stay true and go up, and so on..
one more possible solution, is to declare the bool sw = true right before the loop, in the scope right above it,this is messy, making it global is also messy, static looks better and cleaner, though, you should be careful when using it in OOP, doesn't seem to be your case
also:
if (dbObjectPositionY(naveta)==0)
sw=true;
if (dbObjectPositionY(naveta)==400)
sw=false;
that could sometimes cause errors, not in your case, but if you want to move object at speeds different than 1, this is safer:
if (dbObjectPositionY(naveta)<=0)
sw=true;
if (dbObjectPositionY(naveta)>=400)
sw=false;