# Legacy GMHow to recreate this effect/method/object?

W

#### Whirlpoolio

##### Guest
Hey!
So I'm making a mini side project and havent started as I dont know how to do the basis of my game.
Your a block of pixels who flies around in a world (top down) and can thrust 360°. You collide with the sides of the screen but you can move up and down the screen. I am trying to start with the thrusting/moving system.

Here is what I'm trying to 'recreate':

I DONT want to use the built in physics either.

Sorry if it's a lot to ask for

#### RichHopefulComposer

##### Member
For basic ice/space movement:
Code:
``````xAcceleration = .1;
yAcceleration = xAcceleration;
xSpeed = 0;
ySpeed = 0;

if(pressLeft)
{
xSpeed -= xAcceleration;
}
if(pressRight)
{
xSpeed += xAcceleration;
}
//etc etc repeat for y. Then, add xSpeed and ySpeed to x and y.
x += xSpeed;
y += ySpeed;``````
For the screen collisions, just check to see whether or not your object is touching the edge of the screen on the x axis. If it is, set x to xprevious, or whatever the built in variable is called. Repeat for the y axis.

W

#### Whirlpoolio

##### Guest
Code:
``````xAcceleration = .1;
yAcceleration = xAcceleration;
xSpeed = 0;
ySpeed = 0;

if(pressLeft)
{
xSpeed -= xAcceleration;
}
if(pressRight)
{
xSpeed += xAcceleration;
}
//etc etc``````
What's etc etc?
Also how do I make it so you actually move? Would it be X= xspeed?

Last edited by a moderator:

#### RichHopefulComposer

##### Member
What's etc etc?
Also what does this achieve?
Edited to be clearer. =)

W

#### Whirlpoolio

##### Guest
Edited to be clearer. =)
Thanks! Could you read MY edited question though

W

#### Whirlpoolio

##### Guest
Edited to be clearer. =)
How would I make it so you press space to activate thrust and use mouse to position where your going to go?

W

#### RichHopefulComposer

##### Member
How would I make it so you press space to activate thrust and use mouse to position where your going to go?
No, but close. Think about it in real life terms. We're in a race at a track that starts at 0 meters and goes to a thousand meters. Our starting position is 0, and our speed is ten. What would happen if every second, we said "okay, our position = our speed!"?

One second into the race: "Our speed is ten! Our position is ten!"
Two seconds into the race: "Our speed is ten! Our position is ten!"
Twenty seconds into the race: "Our speed is ten! Our position is ten!"

How do we use our position and our speed to actually change our position? Think about it!

Also, I put the answer right in the edited code that you're apparently looking over.

If you want to make games, you're going to have to do a lot of thinking and work for yourself. This is a simple problem to solve if you give it some thought. I've given you everything you need to know to get your movement working. Please try the code in your project and see what happens, and then try to actually understand why it's happening. Code executes line by line, every step event. Think about things slowly and logically, and you'll be able to figure out almost anything yourself. Good luck!

W

#### Whirlpoolio

##### Guest
No, but close. Think about it in real life terms. We're in a race at a track that starts at 0 meters and goes to a thousand meters. Our starting position is 0, and our speed is ten. What would happen if every second, we said "okay, our position = our speed!"?

One second into the race: "Our speed is ten! Our position is ten!"
Two seconds into the race: "Our speed is ten! Our position is ten!"
Twenty seconds into the race: "Our speed is ten! Our position is ten!"

How do we use our position and our speed to actually change our position? Think about it!

Also, I put the answer right in the edited code that you're apparently looking over.
I changed the question. to another one as I saw the answer xD

W

#### Whirlpoolio

##### Guest
No, but close. Think about it in real life terms. We're in a race at a track that starts at 0 meters and goes to a thousand meters. Our starting position is 0, and our speed is ten. What would happen if every second, we said "okay, our position = our speed!"?

One second into the race: "Our speed is ten! Our position is ten!"
Two seconds into the race: "Our speed is ten! Our position is ten!"
Twenty seconds into the race: "Our speed is ten! Our position is ten!"

How do we use our position and our speed to actually change our position? Think about it!

Also, I put the answer right in the edited code that you're apparently looking over.

If you want to make games, you're going to have to do a lot of thinking and work for yourself. This is a simple problem to solve if you give it some thought. I've given you everything you need to know to get your movement working. Please try the code in your project and see what happens, and then try to actually understand why it's happening. Code executes line by line, every step event. Think about things slowly and logically, and you'll be able to figure out almost anything yourself. Good luck!
Ah that's ms for the edits! I know what you're saying. The thing is I don't know whether to use point_directon to change the image angle and where to thrust but I don't know how to implement it.

#### RichHopefulComposer

##### Member
For your new question: That isn't what your video is showing, and the gameplay probably won't be as satisfying doing it that way. That said, if you want to try it, these functions will help:

I would try my code first though. It's simpler and you should try understanding that first before moving on to this more confusing stuff....
point_direction can be used to get the direction from your character to your mouse cursor. The lengthdir fucntions can be used with this direction and your acceleration variable to add thrust in the direction of your mouse cursor. Read through the manual entries and my posts really carefully, and see if you can work this out. It's a little confusing, but being a programmer is all about getting headaches while expanding your mind. Good luck!

W

#### Whirlpoolio

##### Guest
For your new question: That isn't what your video is showing, and the gameplay probably won't be as satisfying doing it that way. That said, if you want to try it, these functions will help: