C
caesius6
Guest
Hi there!
I'm running into a issue when I attempt to pick up an instance of an object with my mouse cursor and move it someplace else.
To preface, I'm making a game of checkers. I've created my room, tiled it as a checker board, and have one object: a red checker ("obj_red"). I've placed multiple instances of it on the board in the appropriate spaces. My first order of business was to get the game running and allow the player to pick up the piece and drop it somewhere else, never minding the rules of moving on a checkerboard. I'm going to post my code, my thought process of the logic, and hopefully someone can assist me in understanding what's happening.
In a step event for the red checker (obj_red) I've written:
My thought process here is this:
To test and make sure there's a collision being detected, I changed the code to as follows:
Basically, instead of moving a checker, if there's a collision, pop up a dialogue box with "Hello World." This ended up proving true in that the intended effect happened to all but one of my red checker objects placed in the room. All but the top left one.
When pressing the LMB over the top left one, nothing would happen. Furthermore, nothing would happen afterwards if I was to click on any other checker that previously worked. My CPU temperature would also raise and the fan would get audibly louder. I found that selecting a different open window on my computer, then returning to the game would correct this. In addition to that happening when I pressed the LMB over that top left checker, the same would happen if I pressed LMB over anything that wasn't a red checker. I deleted the top left checker instance and added it back in only to find that the issue moved one checker over, to the second from the left on the top row. When I returned the code back to the "pick up and drop" the same thing would happen to the CPU temp and fan noise no matter which checker I tried to move, leading me to believe I can link the two outcomes. Though what that accomplishes... I'm not really sure.
So, with all that laid out, I'm curious as to why any of this is happening. I feel like the answer is right in front of me, but at the same time I'm a bit unsure of why that "freezing" issue is happening, and if it's a code issue why it only happens on that one instance of the red checker.
If it's any help I've attached a dxdiag export (well, images of it, I couldn't upload the text doc, but happy to copy and paste if that's necessary), and for reference I'm running the steam version of GMS2. The issue also persists on my Surface Pro if I attempt it there. As a precaution I've reinstalled GMS2 as well as trashed the project and started over, both not having any change in the outcome. Any help is appreciated!
I'm running into a issue when I attempt to pick up an instance of an object with my mouse cursor and move it someplace else.
To preface, I'm making a game of checkers. I've created my room, tiled it as a checker board, and have one object: a red checker ("obj_red"). I've placed multiple instances of it on the board in the appropriate spaces. My first order of business was to get the game running and allow the player to pick up the piece and drop it somewhere else, never minding the rules of moving on a checkerboard. I'm going to post my code, my thought process of the logic, and hopefully someone can assist me in understanding what's happening.
In a step event for the red checker (obj_red) I've written:
GML:
while mouse_check_button(mb_left) = true {
var checker = instance_position(mouse_x, mouse_y, obj_red);
if (checker != noone) {
checker.x = mouse_x;
checker.y = mouse_y;
}
}
- Is the left mouse button being held down?
- If so, create a temporary variable named "checker" and assign it to the instance_position function, which from my understanding should return the ID of the instance colliding with my mouse position. Elsewise it will return "noone."
- If it does not return "noone," set that instance's x and y to be my mouse x and y.
- If so, create a temporary variable named "checker" and assign it to the instance_position function, which from my understanding should return the ID of the instance colliding with my mouse position. Elsewise it will return "noone."
To test and make sure there's a collision being detected, I changed the code to as follows:
GML:
while mouse_check_button(mb_left) = true {
if place_meeting(mouse_x, mouse_y, obj_red)
{
show_message("Hello World.");
}
}
When pressing the LMB over the top left one, nothing would happen. Furthermore, nothing would happen afterwards if I was to click on any other checker that previously worked. My CPU temperature would also raise and the fan would get audibly louder. I found that selecting a different open window on my computer, then returning to the game would correct this. In addition to that happening when I pressed the LMB over that top left checker, the same would happen if I pressed LMB over anything that wasn't a red checker. I deleted the top left checker instance and added it back in only to find that the issue moved one checker over, to the second from the left on the top row. When I returned the code back to the "pick up and drop" the same thing would happen to the CPU temp and fan noise no matter which checker I tried to move, leading me to believe I can link the two outcomes. Though what that accomplishes... I'm not really sure.
So, with all that laid out, I'm curious as to why any of this is happening. I feel like the answer is right in front of me, but at the same time I'm a bit unsure of why that "freezing" issue is happening, and if it's a code issue why it only happens on that one instance of the red checker.
If it's any help I've attached a dxdiag export (well, images of it, I couldn't upload the text doc, but happy to copy and paste if that's necessary), and for reference I'm running the steam version of GMS2. The issue also persists on my Surface Pro if I attempt it there. As a precaution I've reinstalled GMS2 as well as trashed the project and started over, both not having any change in the outcome. Any help is appreciated!
Attachments
-
24 KB Views: 4
-
21.6 KB Views: 4