Hey I’m a c++ programmer and I was wondering if I could help with this project. I have years of experience and have created a number of games using DirectX9. I noticed that you use gamemaker although I have this program I don’t like it that much. However I still can help because the language isn’t extremely different, just quite different.
So I wrote up this Snippet after playing your game and I noticed that your game doesn’t have the tractor beam effect for those hard-to-reach pickups. Thus I wrote this to do exactly that and to show an example of my programming style.
The program that I wrote up has some other code such as game loop, key control, and sprite rendering but this is all you?ll need to see.
[code]//the pickup 's location on the horizontal axis
int x_pickup;
//" " vertical axis
int y_pickup;
//same as for pickup but for the gun
int x_gun;
int y_gun;
//The velocity in the horizontal axis
int x_velocity;
//The velocity in the vertical axis
int y_velocity;
//The boolean that is true if samus is charging and is false if she is not
bool charge;
void tractor_beam_effect(){
//The distance between the gun and the pickup on the horizontal axis
int x_distance;
//" " on the vertical axis
int y_distance;
//the combined distance or 2dimensional distance
int distance2d;
//finds the x_distance
x_distance = x_gun - x_pickup;
//finds the y_distance
y_distance = y_gun - y_pickup;
//finds the 2dimensional distance
2d_distance = Sqr((x_distance * x_distance) + (y_distance * y_distance));
//This is to check if the pickup is close enough for the tractor beam to grab hold of the object
if (distance2d < 10/this number is just an example put what ever you want here/)
{
//I think that this explains it’s self
If (charge = True)
{
//don’t want to divide by zero!
If (distance2d != 0)
{
//change the pickup velocity so that the pickup is pulled toward samus
y_velocity = y_velocity - 0.05 * (y_distance / distance2d);
x_velocity = x_velocity - 0.05 * (x_distance / distance2d);
}
}
}
Else
{
//if you are not pulling the pickup then pickup stops moving
y_velocity = 0;
x_velocity = 0;
}
//refreshes the pickups location.
y_pickup = y_pickup - y_velocity;
x_pickup = x_pickup - x_velocity;
}[/code]sorry about the length, about half of it is comments and a quarter is white space though.
here it is uncommented
//without comments
int x_pickup;
int y_pickup;
int x_gun;
int y_gun;
int x_velocity;
int y_velocity;
bool charge;
void tractor_beam_effect()
{
int x_distance;
int y_distance;
int distance2d;
x_distance = x_gun - x_pickup;
y_distance = y_gun - y_pickup;
2d_distance = Sqr((x_distance * x_distance) + (y_distance * y_distance));
if (distance2d < 10)
{
If (charge = True)
{
If (distance2d != 0)
{
y_velocity = y_velocity - 0.05 * (y_distance / distance2d);
x_velocity = x_velocity - 0.05 * (x_distance / distance2d);
}
}
}
Else
{
y_velocity = 0;
x_velocity = 0;
}
y_pickup = y_pickup - y_velocity;
x_pickup = x_pickup - x_velocity;
}