M
mcglubski
Guest
Can someone help me simplify this into an array or something else? Even with years of experience with GMS I still struggle to understand simple arrays, especially after coming back to it since buying GMS2. I feel like this should be easy but everything I try doesn't work. If someone could give me a simple solution it might help me figure it out in the future. I have watched almost every YT video about arrays and for loops but still can't seem to make it work. I am not a smart man apparently. lol
This is the code I am using, it works but is very messy and I am certain that I should not be having this many && statements together.
I tried making them into the same array and calling each like this:
collision = [ob_cocol, ob_unitcol, ob_thincol]
and then using:
&& !place_meeting(x - xMove, y, collision[0, 1, 2]
but it only gets the collision of the first variable so obviously it cannot function written this way right?
This is the code I am using, it works but is very messy and I am certain that I should not be having this many && statements together.
Code:
//Move Left
if keyboard_check_pressed(vk_left) || keyboard_check_pressed(ord("A"))
&& !place_meeting(x - xMove, y, ob_cocol)
&& !place_meeting(x - xMove, y, ob_unitcol)
&& !place_meeting(x - xMove, y, ob_thincol)
{
keyLeft = true;
}
else keyLeft = false;
collision = [ob_cocol, ob_unitcol, ob_thincol]
and then using:
&& !place_meeting(x - xMove, y, collision[0, 1, 2]
but it only gets the collision of the first variable so obviously it cannot function written this way right?