Tractor Beam

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 :frowning: 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);
       //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() { &nbsp; &nbsp;int x_distance; &nbsp; &nbsp;int y_distance; &nbsp; &nbsp;int distance2d; &nbsp; &nbsp;x_distance = x_gun - x_pickup; &nbsp; &nbsp;y_distance = y_gun - y_pickup; &nbsp; &nbsp;2d_distance = Sqr((x_distance * x_distance) + (y_distance * y_distance)); &nbsp; &nbsp;if (distance2d < 10) &nbsp; &nbsp;{ &nbsp; &nbsp; &nbsp; &nbsp;If (charge = True) &nbsp; &nbsp; &nbsp; &nbsp;{ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;If (distance2d != 0) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;y_velocity = y_velocity - 0.05 * (y_distance / distance2d); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;x_velocity = x_velocity - 0.05 * (x_distance / distance2d); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} &nbsp; &nbsp; &nbsp; &nbsp;} &nbsp; &nbsp;} &nbsp; &nbsp;Else &nbsp; &nbsp;{ &nbsp; &nbsp; &nbsp; &nbsp;y_velocity = 0; &nbsp; &nbsp; &nbsp; &nbsp;x_velocity = 0; &nbsp; &nbsp;} &nbsp; &nbsp;y_pickup = y_pickup - y_velocity; &nbsp; &nbsp;x_pickup = x_pickup - x_velocity; }

The final product will be done in MetEngine, not Game Maker.

There was a tractor beam in previous demos, but it’s one of the minor features that hadn’t been added to the new engine in that last demo.

Also, seems to me that integers don’t have Top and Left members:

y_pickup = y_pickup.Top - y_velocity; x_pickup = x_pickup.Left - x_velocity; :stuck_out_tongue:
Also, there are some case issues here and there.

DestroyerF may have some work for you to do, but I don’t know if it could be done without much Game Maker experience.

:blush: Guess that’s what I get for hurriedly trying to transfer from my game to a simple subroutine.

What is the MetEngine going to be coded in?

Also I don’t have any problem with using gamemaker, it just isn’t the nicest thing to use.

I would love to help in any way that is possible.

MetEngine is being written in C++ by CoreFusionX.

You’ll want to contact DestroyerF about any programming work to do for the Frigate demo.

I was going to post a Visual Basic version of the tractor beam code, but I got bored with it.

I don’t think CFX would accept help–that’s the other thing I was going to post but didn’t 'til just now. :stuck_out_tongue:

Then I guess that I shall just go away. Thanks for the Information.

Whoa there, wait a sec.

Sure, the programming language is different, but that doesn’t mean I can’t use your code. It is quite usefull to me, I don’t have to do the thinking work anymore.

Maybe you could think out the grapple beam in c++? It would be a great help.

That’s just what I was thinking, even if I don’t like coding in GM I was hoping that I could help with the math and detection part of the system, since that isn’t really too hard to translate to another language. Also about the grapple beam code, I’ll see what I can come up with. Thank you.

Oh and how would you like the control of the grapple beam, because i have an idea for a targeting system, just like the one in metroid prime. But if you want it like super metroid then i will just do it like that.

The grapple beam should be like the one in prime, meaning that you can’t control the speed, and that the grapple beam auto-targets the nearest grapple point.

BTW the tractor beam is now included in the game :wink:

That was rather fast o.0

DF what do you need? I’ll try my hand at it I use gm6 and 7

Awesome, I’m almost done with it then. Just got to get the swinging motion going which shouldn’t be too hard. Thanks for the reply.

[Edit - 24 August 2007]
Sorry it’s taking me so long to get this done, I have been doing lots of getting ready for going back to college. I’m a math, physics, programming major so it’s lots of getting ready. But I should have the snippet done soon.