-1

Me and my friends are making in which object come towards the player and the player moves out of the way. We have an object that increases the speed at which the objects come towards you, so we have to increase the rate of speed the image scales. The problem we are running into as that after two of the power ups the image size stops increasing, staying the same size.

The code we currently have is

if global.collision = 0 ///global.collision is raised when you hit a power up
{
    image_xscale = image_xscale +0.01;
    image_yscale = image_yscale +0.01;
}

this code is repeated with global.collision raised by one each time.

rcpinto
  • 4,166
  • 2
  • 24
  • 25
jon
  • 1
  • 1

1 Answers1

0

For starters, you're not checking anything against global.collision. You're setting it to zero. To check against it, you would use one of the following comparison operators (only you'd replace x with the value you want to check against):

//Greater Than
if (global.collision > x)
{
    //image_xscale += 0.01 does the same thing as saying image_xscale = image_xscale + 1
    image_xscale += 0.01;
    image_yscale += 0.01;
}

//Less Than
if (global.collision < x)
{
    image_xscale += 0.01;
    image_yscale += 0.01;
}

//Greater Than or Equal To
if (global.collision >= x)
{
    image_xscale += 0.01;
    image_yscale += 0.01;
}

//Less Than or Equal To
if (global.collision <= x)
{
    image_xscale += 0.01;
    image_yscale += 0.01;
}

//Is Equal To
if (global.collision == x)
{
    image_xscale += 0.01;
    image_yscale += 0.01;
}

//Is NOT Equal To
if (global.collision != x)
{
    image_xscale += 0.01;
    image_yscale += 0.01;
}

If you're trying to what I think you are (make objects grow faster based on global.collision) you would probably want to do one of the two following (they do the same thing):

image_xscale += 0.01 * global.collision;
image_yscale += 0.01 * global.collision;

or

image_yscale = image_xscale = (image_xscale + 0.01 * global.collision);
Duphus
  • 191
  • 1
  • 10