• 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!

Legacy GM How Do We Draw A Physics "Fixture"?

J

JeZxLee

Guest
Hi,

We are trying to get a some small colored balls to fall.
We are using physics "Fixtures" and "Objects" and trying to do physics in script code.

Here is our current code which runs and does not show any errors:
________________________________________________________________
// Initialize code:
global.NumberOfColoredBalls = 0;
for (var index = 0; index < 99; index+=1)
{
global.ColoredBallFixtureIndex[index] = physics_fixture_create();
global.ColoredBallMyFixtureIndex[index] = -1;
global.ColoredBallSpriteIndex[index] = 0;
global.ColoredBallScreenX[index] = 0;
global.ColoredBallScreenY[index] = 0;
global.ColoredBallDirectAngle[index] = 0;
global.ColoredBallSpeed[index] = 0;
}

________________________________________________________________
// Game logic code:
else if (global.PlayerStatus == End)
{
for (var indexY = 0; indexY < 3; indexY+=1)
{
for (var indexX = 0; indexX < 4; indexX+=1)
{
if (global.PlayfieldScale[indexX, indexY] > 0) global.PlayfieldScale[indexX, indexY]-=.1;
else global.PlayfieldScale[indexX, indexY] = 0;
}
}

global.ColoredBallSpriteIndex[global.NumberOfColoredBalls] = global.ColorToChoose;
global.ColoredBallScreenX[global.NumberOfColoredBalls] = global.BigColorToChooseScreenX;
global.ColoredBallScreenY[global.NumberOfColoredBalls] = global.BigColorToChooseScreenY+100;

var inst;
physics_fixture_set_circle_shape(global.ColoredBallFixtureIndex[global.NumberOfColoredBalls], 16);
physics_fixture_set_density(global.ColoredBallFixtureIndex[global.NumberOfColoredBalls], 1.0);
if (global.ColoredBallSpriteIndex[global.NumberOfColoredBalls] == 1) inst = instance_create(global.ColoredBallScreenX[global.NumberOfColoredBalls], global.ColoredBallScreenY[global.NumberOfColoredBalls], SelectRedObject);
else if (global.ColoredBallSpriteIndex[global.NumberOfColoredBalls] == 2) inst = instance_create(global.ColoredBallScreenX[global.NumberOfColoredBalls], global.ColoredBallScreenY[global.NumberOfColoredBalls], SelectOrangeObject);
else if (global.ColoredBallSpriteIndex[global.NumberOfColoredBalls] == 3) inst = instance_create(global.ColoredBallScreenX[global.NumberOfColoredBalls], global.ColoredBallScreenY[global.NumberOfColoredBalls], SelectYellowObject);
else if (global.ColoredBallSpriteIndex[global.NumberOfColoredBalls] == 4) inst = instance_create(global.ColoredBallScreenX[global.NumberOfColoredBalls], global.ColoredBallScreenY[global.NumberOfColoredBalls], SelectGreenObject);
else if (global.ColoredBallSpriteIndex[global.NumberOfColoredBalls] == 5) inst = instance_create(global.ColoredBallScreenX[global.NumberOfColoredBalls], global.ColoredBallScreenY[global.NumberOfColoredBalls], SelectBlueObject);
else if (global.ColoredBallSpriteIndex[global.NumberOfColoredBalls] == 6) inst = instance_create(global.ColoredBallScreenX[global.NumberOfColoredBalls], global.ColoredBallScreenY[global.NumberOfColoredBalls], SelectPurpleObject);
global.ColoredBallMyFixtureIndex[global.NumberOfColoredBalls] = physics_fixture_bind(global.ColoredBallFixtureIndex[global.NumberOfColoredBalls], inst);

global.PlayerStatus = Begin;
SetupColorToChooseAndPlayfield();
}
________________________________________________________________


Our problem now is the newly created Fixtures are not being drawn on the game screen?
How can we draw the Fixtures?

Thanks!
 
J

JeZxLee

Guest
Hi Again!

We need help, the code looks good and builds and runs, but the new physics "Fixtures" are not being drawn on the screen.
How do we draw the new physics "Fixtures"?
Do we draw fixtures or do we draw objects?
I don't see drawing functions in help for fixtures or objects.
Thanks!

 

chance

predictably random
Forum Staff
Moderator
Generally, what's drawn automatically is the sprite assigned to the instance -- not the fixture that's bound to it. Alternatively, you can draw something different by putting code in the DRAW event.

Either way, fixtures are not automatically drawn, other than in the "debug" mode.
 
J

JeZxLee

Guest
Generally, what's drawn automatically is the sprite assigned to the instance -- not the fixture that's bound to it. Alternatively, you can draw something different by putting code in the DRAW event.

Either way, fixtures are not automatically drawn, other than in the "debug" mode.
Hi!

Ok, so we tried to run the game in DEBUG mode - the physics fixtures are still not being drawn?
Can someone look at above code to see if we do something wrong?
Thanks!
 
Top