F
Flagolet
Guest
Hi everybody !
I'm a beginner and I'm currently making a brick-breaker to practice coding. I have one specific problem and a little consideration.
The specific problem
In my brick-breaker, I want a powerup to add a "sight line" in the direction of the ball, so the player can anticipate where the ball is gonna go. So far, here is what I have being able to do : https://vimeo.com/user130013288/review/494842250/c56be2336e
To do this, I created an object called "O_Trajectoire", drawed a sprite (an arrow) for it, and I used the chunk of code below in the "step event" of the "O_Trajectoire", so the object is always right in front of my ball.
But what I would like, is having many "O_Trajectoire" objects placed next to each other, like this :
I know I could use a "draw_line" function, or draw a very long sprite for one single object, which would surely be FAR LESS ressources consumming. But as simple curiosity, I would like to know how to code so I could create like 10 instances of the O_Trajectoire object when i get the PowerUp, and assign the coordinates of each of these instances so they form a lign in front of my ball ?
My little consideration.
I'm worring about peformances and space memory. I don't really realize how important it is to use local variables (which look a bit more difficult to handle) instead of normal instances variables, in terms of optimisation. Manual says that variables take space in memory, but how much ? I would like to take good habits as soon as possible, but should I focus more on learning functions and making things work first ?
I hope I have been clear, don't hesitate to ask more, if needed. Thanks in advance for taking time to respond.
I'm a beginner and I'm currently making a brick-breaker to practice coding. I have one specific problem and a little consideration.
The specific problem
In my brick-breaker, I want a powerup to add a "sight line" in the direction of the ball, so the player can anticipate where the ball is gonna go. So far, here is what I have being able to do : https://vimeo.com/user130013288/review/494842250/c56be2336e
To do this, I created an object called "O_Trajectoire", drawed a sprite (an arrow) for it, and I used the chunk of code below in the "step event" of the "O_Trajectoire", so the object is always right in front of my ball.
GML:
with (O_Balle) {
var _x,_y; //coordonnates of the line right in front of the ball
_x = x + lengthdir_x(32, direction);
_y = y + lengthdir_y(32, direction);
}
x = _x;
y = _y;
I know I could use a "draw_line" function, or draw a very long sprite for one single object, which would surely be FAR LESS ressources consumming. But as simple curiosity, I would like to know how to code so I could create like 10 instances of the O_Trajectoire object when i get the PowerUp, and assign the coordinates of each of these instances so they form a lign in front of my ball ?
My little consideration.
I'm worring about peformances and space memory. I don't really realize how important it is to use local variables (which look a bit more difficult to handle) instead of normal instances variables, in terms of optimisation. Manual says that variables take space in memory, but how much ? I would like to take good habits as soon as possible, but should I focus more on learning functions and making things work first ?
I hope I have been clear, don't hesitate to ask more, if needed. Thanks in advance for taking time to respond.