• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

YoYo Compiler Tips / Best Practices

obscene

Member
So I'm taking on the daunting task of making my game run under YYC. It's bad. There are so many random and crazy things happening. Shooting a laser against a wall spawn the game credits. My player will do the moonwalk at seemingly random times. The wrong graphics appear in some cases. Obviously I'm doing a bad job.

I know a few things I'm doing wrong. I never use parentheses and I often forget semicolons. I also use INT variables as boolean switches.

For instance I often use timers to controls states. For instance when I push up on a ladder the player enters a climbing animation and I might set ladder_climbing=30 . As it ticks down to 0 the player moves and an animation plays and when it hits 0 we're no longer in that state.

I do this...
Code:
if ladder_climbing
should be...
Code:
if (ladder_climbing)
or should it even be...
Code:
if (ladder_climbing > 0)
Also is this OK?

Code:
if (ladder_climbing) ladder_climbing--;
else do something here;
Or are brackets a must under YYC?

Do I need to change these things? For the most part it all seems to be working. Mostly.

I'd like to spend a few days (weeks) just going over all my code and correcting all these things. Is there a good list anywhere of things I should watch out for?
 
R

renex

Guest
I *think* argument order starts mattering as statements are iterated in reverse.

I also see no problems using numbers as boolean switches, I do that all the time exactly for counters lol.

if (!--c) trigger()

but I get problems using booleans as numbers.

array[0]='a'
array[1]='a'
v=1
array[!v] = 'b'
// array = {'a','a'}
array[(!v)*1] = 'b'
// array = {'b','a'}

Multiplying a boolean by 1 makes it into a valid number, though.

Other than that, I don't really remember having severe problems like that, that's a whole different level of wrong.

Do make sure you're using the correct version of visual studio, I remember having my game go completely unplayable on half the test machines before I updated it to update 4.
 
H

Harrison Vanderbyl

Guest
ive never had to change any of my code for yyc... is there something im missing?
i know sometimes ill get compiler errors due to conflicts in variable names that occur when gm translates to c++ but thats easily cleared with the clean build button
 

obscene

Member
My game runs 99% but like I said just weird things happening that I can't explain. For instance my damage script will spawn the object obj_damage_text which is little text that floats up with the amount of the hit. Under YYC this was spawning the game credits (obj_credits) which of course is not even mentioned in the script anywhere. Just going through the script and adding parentheses and a couple of missing semicolons fixed it. I can't explain it but it's working.

I've already fixed 3 problems just by doing this so onward I go!

Thanks Lone for the advice so far it's working.
 
S

Sam (Deleted User)

Guest
What it really sounds like is that you are running into bugs with GM:S itself, aka not your GML. I could be wrong, but from the sound of what you're encountering, it seems GM:S is somehow mixing up the XML source when reading it and translating its code and settings into C++.

Edit: also, things like this may be because you tried up/downgrating between versions of studio without backing up your project like frequently suggested in the release notes.

Edit2: looks like I was wrong. After reading further you are making progress I wasn't aware of.
 

NazGhuL

NazTaiL
What I do now to have less errors using the YYC:

-Run the YYC more than once a month . . .
-Always use brackets, parentheses and semi-colon
-Round/floor/ceil every value that need to be.
ie:
Code:
var x1= 3/2;
var y1 = player.x/11;
scr_use_weapon(grid_index[# x1, y1]);
should be
Code:
var x1= round(3/2);
var y1 = round(player.x/11);

scr_use_weapons(grid_index[# x1, y1]);

And I'm now abusing the WITH when calling something from another instance:
Code:
with(obj_player)
{
x += 32;
}
instead of
Code:
obj_player.x += 32;
 

Hyomoto

Member
NazGhul, in your case it would probably be better to get the id of the obj_player instance at creation and store that so you can call it directly. Ie:

Code:
player = instance_create( 0, 0, obj_player );
Then it should be no problem to call it directly as you did before, because you've removed the ambiguity around the object you are calling. Remember that calling an object in that way runs it for ALL objects of that type, which means your game will also have to perform a search for each object that matches that object type. Calling the id directly should fix an troubles you have with that syntax. Otherwise it may be a compiler error.

Code:
player.x += 32
Of course, I admit from your example you could already be doing this, it just doesn't appear that way due to the obj_ prefix.
 
Top