Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2024.4.1 hotfix #124

Merged
merged 2 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ <h2 id="h">Bounding Boxes</h2>
<p class="note"><span data-conref="../../../../assets/snippets/Tag_note.hts"> </span> Since the bounding box is inclusive (as explained above), it will always extend 1 pixel beyond its bottom-right corner compared to the sprite&#39;s bounding box. For example, a 16x16 square sprite&#39;s <a href="../../Asset_Management/Sprites/Sprite_Information/sprite_get_bbox_right.htm">right edge offset</a> will be <span class="inline2">15.0</span> (the 16th pixel when starting from 0), however an instance using this sprite will give you a <span class="inline2"><a data-xref="{title}" href="../../Asset_Management/Sprites/Sprite_Instance_Variables/bbox_right.htm">bbox_right</a></span> of 16 (+ its X position).</p>
<p>For two instances to be in collision, their bounding boxes have to overlap. At a pixel level, an overlap is counted when the centre of that pixel is covered.</p>
<p>For example, if you&#39;re trying to collide with a bounding box covering the area from <span class="inline2">(0.0, 0.0)</span> to <span class="inline2">(16.0, 16.0)</span>, the edge of your mask has to touch the area between  <span class="inline2">(0.5, 0.5)</span> and <span class="inline2">(15.5, 15.5)</span> for a collision to be counted.</p>
<p>The functions <span class="inline3_func"><a data-xref="{title}" href="collision_point.htm">collision_point</a></span> and <span class="inline3_func"><a data-xref="{title}" href="collision_line.htm">collision_line</a></span> are exceptions, where they don&#39;t have to cover the pixel centre but can be checked anywhere inside the pixel. In the above example, a point check at <span class="inline2">(15.99, 15.99)</span> would return <span class="inline2">true</span>, but <span class="inline2">(16.0, 16.0)</span> would not.</p>
<h2><label for="one">Simple Collision Checking</label></h2>
<p>The following functions deal with the various ways in which you can have an instance check for collisions with another instance:</p>
<ul class="colour">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<!--<div class="body-scroll" style="top: 150px;">-->
<h1>place_empty</h1>
<p>You can use this function to check and see if the calling instance would collide with <i>any other instance</i> of an object or all instances in your game. For this to collision to resolve correctly, the instance running the code must have a valid collision mask (either for the sprite itself, or through the <a href="../../Asset_Management/Sprites/Sprite_Instance_Variables/mask_index.htm"><span class="inline">mask_index</span></a>) and it will only register collisions with those instances that also have a valid mask.</p>
<p>The function is testing if there are no collisions should the calling instance be placed at a specific position, and you can supply an optional argument to refine the check to only check if a position is free of collisions with instances of the given type. Note that if no optional object ID is supplied, the check will be done against <i>all</i> instances within the room. The collision checking will be either precise or based on the bounding box of the instance, depending on what kind of collision mask has been selected, but for precise collisions to work correctly, all instances in the check should have precise collision masks.</p>
<p>The function is testing if there are no collisions should the calling instance be placed at a specific position, and you can supply an optional argument to refine the check to only check if a position is free of collisions with instances of the given type. Note that if no optional object ID is supplied, the check will be done against <i>all</i> instances within the room.</p>
<p>The collision checking will be either precise or based on the bounding box of the instance, depending on what kind of collision mask has been selected, but for precise collisions to work correctly, all instances in the check should have precise collision masks.</p>
<div data-conref="../../../../assets/snippets/Collisions_function_accepted_arguments.hts"> </div>
<p>Note that the given x/y coordinates will be floored to the nearest integer before the check is performed.</p>
<p> </p>
<h4>Syntax:</h4>
<p class="code">place_empty(x, y, [object_id]);</p>
Expand All @@ -32,27 +32,27 @@ <h4>Syntax:</h4>
</tr>
<tr>
<td>x</td>
<td><span data-keyref="Type_Real"><a href="GameMaker_Language/GML_Overview/Data_Types.htm" target="_blank">Real</a></span></td>
<td><span data-keyref="Type_Real"><a href="../../../GML_Overview/Data_Types.htm" target="_blank">Real</a></span></td>
<td>The x position to check.</td>
</tr>
<tr>
<td>y</td>
<td><span data-keyref="Type_Real"><a href="GameMaker_Language/GML_Overview/Data_Types.htm" target="_blank">Real</a></span></td>
<td><span data-keyref="Type_Real"><a href="../../../GML_Overview/Data_Types.htm" target="_blank">Real</a></span></td>
<td>The y position to check.</td>
</tr>
<tr>
<td>[object_id]</td>
<td><span data-keyref="Collision_obj_type"><span data-keyref="Type_Asset_Object"><a href="The_Asset_Editors/Objects.htm" target="_blank">Object Asset</a></span> or <span data-keyref="Type_ID_Instance"><a href="GameMaker_Language/GML_Reference/Asset_Management/Instances/Instance_Variables/id.htm" target="_blank">Object Instance</a></span> or <span data-keyref="Type_ID_Element_Tilemap"><a href="GameMaker_Language/GML_Reference/Asset_Management/Rooms/Tile_Map_Layers/layer_tilemap_get_id.htm" target="_blank">Tile Map Element ID</a></span> or <span data-keyref="Type_Array"><a href="GameMaker_Language/GML_Overview/Arrays.htm" target="_blank">Array</a></span></span></td>
<td><span data-keyref="Collision_obj_type"><span data-keyref="Type_Asset_Object"><a href="../../../../The_Asset_Editors/Objects.htm" target="_blank">Object Asset</a></span> or <span data-keyref="Type_ID_Instance"><a href="../../Asset_Management/Instances/Instance_Variables/id.htm" target="_blank">Object Instance</a></span> or <span data-keyref="Type_ID_Element_Tilemap"><a href="../../Asset_Management/Rooms/Tile_Map_Layers/layer_tilemap_get_id.htm" target="_blank">Tile Map Element ID</a></span> or <span data-keyref="Type_Array"><a href="../../../GML_Overview/Arrays.htm" target="_blank">Array</a></span></span></td>
<td><span class="optional">OPTIONAL</span> <span data-keyref="Collision_obj_description">An object, instance, tile map ID, keywords all/other, or array containing these items</span></td>
</tr>
</tbody>
</table>
<p> </p>
<h4>Returns:</h4>
<p class="code"><span data-keyref="Type_Bool"><a href="GameMaker_Language/GML_Overview/Data_Types.htm" target="_blank">Boolean</a></span></p>
<p class="code"><span data-keyref="Type_Bool"><a href="../../../GML_Overview/Data_Types.htm" target="_blank">Boolean</a></span></p>
<p> </p>
<h4>Example:</h4>
<p class="code">if (place_empty(mouse_x, mouse_y, obj_Enemy)) <br />
<p class="code">if (place_empty(mouse_x, mouse_y, obj_Enemy))<br />
{<br />
    x = mouse_x;<br />
    y = mouse_y;<br />
Expand All @@ -68,7 +68,7 @@ <h4>Example:</h4>
<div style="float:right">Next: <a href="place_free.htm">place_free</a></div>
</div>
</div>
<h5><span data-keyref="Copyright Notice">© Copyright YoYo Games Ltd. 2023 All Rights Reserved</span></h5>
<h5><span data-keyref="Copyright Notice">© Copyright YoYo Games Ltd. 2024 All Rights Reserved</span></h5>
</div>
<!-- KEYWORDS
place_empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>place_free</title>
<meta name="generator" content="Adobe RoboHelp 2020" />
<meta name="generator" content="Adobe RoboHelp 2022" />
<link rel="stylesheet" href="../../../../assets/css/default.css" type="text/css" />
<script src="../../../../assets/scripts/main_script.js" type="module"></script>
<meta name="rh-authors" content="Mark Alexander" />
Expand All @@ -18,32 +18,34 @@
<h1>place_free</h1>
<p>You can use this function to check and see if the calling instance would collide with any instance <i>flagged as <b>solid</b></i> in your game. Now, it should be noted that for this to work, the instance running the code must have a valid collision mask (either for the sprite itself, or through the <a href="../../Asset_Management/Sprites/Sprite_Instance_Variables/mask_index.htm"><span class="inline">mask_index</span></a>) and it will only register collisions with those solid flagged instances that also have a valid mask.</p>
<p>The function itself basically works by taking the instance and testing for collisions with only solid flagged instances when placed at the position specified by the x/y arguments. The collision checking can be either precise or based on the bounding box of the instance, depending on what kind of collision mask has been selected.</p>
<p>Note that the given x/y coordinates will be floored to the nearest integer before the check is performed.</p>
<p> </p>
<h4>Syntax:</h4>
<p class="code">place_free(x, y);</p>
<table>
<tbody>
<tr>
<th>Argument</th><th>Type</th>
<th>Argument</th>
<th>Type</th>
<th>Description</th>
</tr>
</tr>
<tr>
<td>x</td><td><span data-keyref="Type_Real"></span></td>
<td>x</td>
<td><span data-keyref="Type_Real"><a href="../../../GML_Overview/Data_Types.htm" target="_blank">Real</a></span></td>
<td>The x position to check.</td>
</tr>
</tr>
<tr>
<td>y</td><td><span data-keyref="Type_Real"></span></td>
<td>y</td>
<td><span data-keyref="Type_Real"><a href="../../../GML_Overview/Data_Types.htm" target="_blank">Real</a></span></td>
<td>The y position to check.</td>
</tr>
</tr>
</tbody>
</table>
<p> </p>
<h4>Returns:</h4>
<p class="code"><span data-keyref="Type_Bool"></span></p>
<p class="code"><span data-keyref="Type_Bool"><a href="../../../GML_Overview/Data_Types.htm" target="_blank">Boolean</a></span></p>
<p> </p>
<h4>Example:</h4>
<p class="code">if (place_free(mouse_x, mouse_y)) <br />
<p class="code">if (place_free(mouse_x, mouse_y))<br />
{<br />
    x = mouse_x;<br />
    y = mouse_y;<br />
Expand All @@ -59,7 +61,7 @@ <h4>Example:</h4>
<div style="float:right">Next: <a href="place_meeting.htm">place_meeting</a></div>
</div>
</div>
<h5><span data-keyref="Copyright Notice">© Copyright YoYo Games Ltd. 2021 All Rights Reserved</span></h5>
<h5><span data-keyref="Copyright Notice">© Copyright YoYo Games Ltd. 2024 All Rights Reserved</span></h5>
</div>
<!-- KEYWORDS
place_free
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
<body>
<!--<div class="body-scroll" style="top: 150px;">-->
<h1>place_meeting</h1>
<p>With this function you can check a position for a collision with another instance or all instances of an object using the collision mask of the instance that runs the code for the check. When you use this you are effectively asking <span data-keyref="GameMaker Name">GameMaker</span> to move the instance to the new position, check for a collision, move back and tell you if a collision was found or not.</p>
<p>With this function you can check a position for a collision with another instance, or all instances of an object, using the collision mask of the instance that runs the code. When you use this you are effectively asking <span data-keyref="GameMaker Name">GameMaker</span> to move the instance to the new position, check for a collision, move back and tell you if a collision was found or not.</p>
<p>This will work for precise collisions, but only if both the instance and the object being checked for have precise collision masks selected. Otherwise, only bounding box collisions are applied.</p>
<div data-conref="../../../../assets/snippets/Collisions_function_accepted_arguments.hts"> </div>
<p>If you need to get the unique instance <b>id</b> of the object being collided with, you should use <a href="../../Asset_Management/Instances/instance_place.htm"><span class="inline">instance_place()</span></a>.</p>
<p><img alt="Place meeting example" class="center" src="../../../../assets/Images/Scripting_Reference/GML/Reference/Movement_Collisions/place_meeting.png" />Note that the given x/y coordinates will be floored to the nearest integer before the check is performed.</p>
<p>See: <a href="Collisions.htm">Collisions</a></p>
<p><img alt="Place meeting example" class="center" src="../../../../assets/Images/Scripting_Reference/GML/Reference/Movement_Collisions/place_meeting.png" />See: <a href="Collisions.htm">Collisions</a></p>
<p> </p>
<h4>Syntax:</h4>
<p class="code">place_meeting(x, y, obj);</p>
Expand All @@ -34,29 +33,29 @@ <h4>Syntax:</h4>
</tr>
<tr>
<td>x</td>
<td><span data-keyref="Type_Real"><a href="GameMaker_Language/GML_Overview/Data_Types.htm" target="_blank">Real</a></span></td>
<td><span data-keyref="Type_Real"><a href="../../../GML_Overview/Data_Types.htm" target="_blank">Real</a></span></td>
<td>The x position to check.</td>
</tr>
<tr>
<td>y</td>
<td><span data-keyref="Type_Real"><a href="GameMaker_Language/GML_Overview/Data_Types.htm" target="_blank">Real</a></span></td>
<td><span data-keyref="Type_Real"><a href="../../../GML_Overview/Data_Types.htm" target="_blank">Real</a></span></td>
<td>The y position to check.</td>
</tr>
<tr>
<td>obj</td>
<td><span data-keyref="Collision_obj_type"><span data-keyref="Type_Asset_Object"><a href="The_Asset_Editors/Objects.htm" target="_blank">Object Asset</a></span> or <span data-keyref="Type_ID_Instance"><a href="GameMaker_Language/GML_Reference/Asset_Management/Instances/Instance_Variables/id.htm" target="_blank">Object Instance</a></span> or <span data-keyref="Type_ID_Element_Tilemap"><a href="GameMaker_Language/GML_Reference/Asset_Management/Rooms/Tile_Map_Layers/layer_tilemap_get_id.htm" target="_blank">Tile Map Element ID</a></span> or <span data-keyref="Type_Array"><a href="GameMaker_Language/GML_Overview/Arrays.htm" target="_blank">Array</a></span></span></td>
<td><span data-keyref="Collision_obj_type"><span data-keyref="Type_Asset_Object"><a href="../../../../The_Asset_Editors/Objects.htm" target="_blank">Object Asset</a></span> or <span data-keyref="Type_ID_Instance"><a href="../../Asset_Management/Instances/Instance_Variables/id.htm" target="_blank">Object Instance</a></span> or <span data-keyref="Type_ID_Element_Tilemap"><a href="../../Asset_Management/Rooms/Tile_Map_Layers/layer_tilemap_get_id.htm" target="_blank">Tile Map Element ID</a></span> or <span data-keyref="Type_Array"><a href="../../../GML_Overview/Arrays.htm" target="_blank">Array</a></span></span></td>
<td><span data-keyref="Collision_obj_description">An object, instance, tile map ID, keywords all/other, or array containing these items</span></td>
</tr>
</tbody>
</table>
<p> </p>
<h4>Returns:</h4>
<p class="code"><span data-keyref="Type_Bool"><a href="GameMaker_Language/GML_Overview/Data_Types.htm" target="_blank">Boolean</a></span></p>
<p class="code"><span data-keyref="Type_Bool"><a href="../../../GML_Overview/Data_Types.htm" target="_blank">Boolean</a></span></p>
<p> </p>
<h4>Example 1:</h4>
<p class="code">if (keyboard_check(vk_left)) <br />
<p class="code">if (keyboard_check(vk_left))<br />
{<br />
    if (!place_meeting(x - 5, y, obj_wall)) <br />
    if (!place_meeting(x - 5, y, obj_wall))<br />
    {<br />
        x -= 5;<br />
    }<br />
Expand All @@ -65,7 +64,7 @@ <h4>Example 1:</h4>
<h4>Example 2:</h4>
<p class="code">var _tilemap = layer_tilemap_get_id(&quot;Tiles_1&quot;);<br />
<br />
if (keyboard_check(vk_left)) <br />
if (keyboard_check(vk_left))<br />
{<br />
    if !place_meeting(x - 5, y, [obj_wall, obj_bush, _tilemap])<br />
    {<br />
Expand All @@ -84,7 +83,7 @@ <h4>Example 2:</h4>
<div style="float:right">Next: <a href="position_empty.htm">position_empty</a></div>
</div>
</div>
<h5><span data-keyref="Copyright Notice">© Copyright YoYo Games Ltd. 2023 All Rights Reserved</span></h5>
<h5><span data-keyref="Copyright Notice">© Copyright YoYo Games Ltd. 2024 All Rights Reserved</span></h5>
</div>
<!-- KEYWORDS
place_meeting
Expand Down
Loading