GM Version: GameMaker:Studio v1.4.1690 Target Platform: ALL Download: Starter Project Links: YouTube Video Summary:
Learn how to add the basics of a pool game using the built in physics capabilities of GMStudio.
I did this tutorial to see how the gameplay of pool work for an idea I have for a game but I can't make to change direction once it has begun to move the cue. I'd appreciate any help in this regard because I'm just starting and I'm a complete noob.
I did this tutorial to see how the gameplay of pool work for an idea I have for a game but I can't make to change direction once it has begun to move the cue. I'd appreciate any help in this regard because I'm just starting and I'm a complete noob.
You should be able to remove the if(pulling) else part such that you can always orbit around the queue. You will also need to change a couple other areas.
You should be able to remove the if(pulling) else part such that you can always orbit around the queue. You will also need to change a couple other areas.
Woaaa the real GMWolf I'm subscribed 2 you for some time now ! Btw I see you use a lot of local vars I never do that I always use instance variables is there a big difference in performance?
Woaaa the real GMWolf I'm subscribed 2 you for some time now ! Btw I see you use a lot of local vars I never do that I always use instance variables is there a big difference in performance?
Treating the instance-scope-only habit as a performance problem is a myopic yet unfortunately common diagnosis. The lack of correctness is the main problem of the habit, and the bomb starts ticking once you start independent work.
The most common unwanted interaction is between looping variables inside and outside a script. Compare this correct implementation of capturing the values of 50 rolls of two dice:
Code:
for (var i = 0; i < 50; i++) {
rolls[i] = d6(2);
}
Code:
///d6(n)
{
var total = 0;
for (var i = 0; i < argument0; i++) {
total += irandom_range(1, 6);
}
return total;
}
With this incorrect implementation that just crashes flat-out, for no reason other than failing to use local variables:
Code:
for (i = 0; i < 50; i++) {
rolls[i] = d6(2);
}
Code:
///d6(n)
{
total = 0;
for (i = 0; i < argument0; i++) {
total += irandom_range(1, 6);
}
return total;
}
Another problem with the instance-scope-only habit is its interaction with recursion. Here's an easy example:
Correct:
Code:
///factorial(n)
// A correct recursive implementation of n!
{
var n = argument0;
if (n == 1) return 1;
return factorial(n-1) * n;
}
Incorrect:
Code:
///factorial(n)
// An incorrect recursive implementation of n! that always returns 1
{
n = argument0;
if (n == 1) return 1;
return factorial(n-1) * n;
}
And in case you think I'm creating these examples synthetically to prove a point, I'm telling you right now that they are based on actual posts I've responded to (loop counter conflict / recursion conflict). Real people have been bitten by the instance-scope-only bug, and it's not an old wives' tale. And thanks to this trend of incessant focus on performance, there is nearly zero awareness of it among rookies and intermediates.
So please stop looking at local variables in terms of performance, and stop treating it as optional or a matter of taste. It is a matter of keeping code correct and conflict-free, which often matters more than performance.
So please stop looking at local variables in terms of performance, and stop treating it as optional or a matter of taste. It is a matter of keeping code correct and conflict-free, which often matters more than performance.
This. Very much this.
People often dismiss "correctness". But it's really important. Performance is something you can worry about when you have good software engineering covered.
@GMWolf Awesome tutorial. I was understanding everything until 22 minutes then...
Dot product!!! I've heard of a dot product in matrices, but not in vectors. I'll have to pause here and take some time to understand the "what" and the "why".
A quick google search should helpp you understand.
But in essence, the dot product will find how much of a vector lies along the other vector. So if they are parallel, you get a high value, and when perpendicular, you get 0.