{"id":1043,"date":"2023-03-20T17:26:42","date_gmt":"2023-03-20T22:26:42","guid":{"rendered":"https:\/\/chronocrash.com\/obor\/wiki\/?p=1043"},"modified":"2023-12-27T20:14:05","modified_gmt":"2023-12-28T01:14:05","slug":"shadows","status":"publish","type":"post","link":"https:\/\/chronocrash.com\/obor\/wiki\/shadows\/","title":{"rendered":"Shadows"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Shadows help give your game depth where applicable and are a vital aid for platforming in a three dimensional world. OpenBOR supports static shadows shadows created from a template shadow sprite and realistic shadows matching the entity&#8217;s profile. You may also configure light sources angles to make shadows that dynamically respond to the scenery around them. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Model<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Header<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">Shadow Configuration<\/h4>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nshadow_config &amp;lt;arguments&gt;\n\n# Default\nshadow_config static_ground static_air\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Basic shadow behaviors for an entity. Accepts one or more of the following flags:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>base_platform<\/code> &#8211; Shadows move to platform like 2D platform style games.<\/li>\n\n\n\n<li><code>base_static<\/code> &#8211; Shadows do not change with platforms.<\/li>\n\n\n\n<li><code>default<\/code> &#8211; Shortcut for default flags.<\/li>\n\n\n\n<li><code>disabled<\/code> &#8211; Shadows are disabled regardless of other flags.<\/li>\n\n\n\n<li><code>replica_air<\/code> &#8211; Project a realistic shadow based on current frame sprite when entity is in the air.<\/li>\n\n\n\n<li><code>replica_ground<\/code> &#8211; Project a realistic shadow based on current frame sprite when entity is on the ground.<\/li>\n\n\n\n<li><code>static_air<\/code> &#8211; Project a static shadow using an indexed sprite when entity is in the air.<\/li>\n\n\n\n<li><code>static_ground<\/code> &#8211; Project a static shadow using an indexed sprite when entity is on the ground.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">This example configures the entity to display a realistic shadow on the ground, and a static shadow in the air.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nshadow_config replica_ground static_air\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"320\" height=\"240\" data-id=\"1050\" src=\"https:\/\/i0.wp.com\/chronocrash.com\/obor\/wiki\/wp-content\/uploads\/2023\/03\/My-Mod-0004.png?resize=320%2C240&#038;ssl=1\" alt=\"\" class=\"wp-image-1050\" srcset=\"https:\/\/i0.wp.com\/chronocrash.com\/obor\/wiki\/wp-content\/uploads\/2023\/03\/My-Mod-0004.png?w=320&amp;ssl=1 320w, https:\/\/i0.wp.com\/chronocrash.com\/obor\/wiki\/wp-content\/uploads\/2023\/03\/My-Mod-0004.png?resize=300%2C225&amp;ssl=1 300w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"320\" height=\"240\" data-id=\"1051\" src=\"https:\/\/i0.wp.com\/chronocrash.com\/obor\/wiki\/wp-content\/uploads\/2023\/03\/My-Mod-0005.png?resize=320%2C240&#038;ssl=1\" alt=\"\" class=\"wp-image-1051\" srcset=\"https:\/\/i0.wp.com\/chronocrash.com\/obor\/wiki\/wp-content\/uploads\/2023\/03\/My-Mod-0005.png?w=320&amp;ssl=1 320w, https:\/\/i0.wp.com\/chronocrash.com\/obor\/wiki\/wp-content\/uploads\/2023\/03\/My-Mod-0005.png?resize=300%2C225&amp;ssl=1 300w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><\/figure>\n<\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Script<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Shadow is an integer using the following bitmasks:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>openborconstant(\"SHADOW_CONFIG_NONE\")<\/code><\/li>\n\n\n\n<li><code>openborconstant(\"SHADOW_CONFIG_DEFAULT\")<\/code><\/li>\n\n\n\n<li><code>openborconstant(\"SHADOW_CONFIG_BASE_STATIC\")<\/code><\/li>\n\n\n\n<li><code>openborconstant(\"SHADOW_CONFIG_BASE_ALL\")<\/code> &#8211; All base bits. Useful for logic checks.<\/li>\n\n\n\n<li><code>openborconstant(\"SHADOW_CONFIG_BASE_PLATFORM\")<\/code><\/li>\n\n\n\n<li><code>openborconstant(\"SHADOW_CONFIG_BASE_PLATFORM\")<\/code><\/li>\n\n\n\n<li><code>openborconstant(\"SHADOW_CONFIG_DISABLE\")<\/code><\/li>\n\n\n\n<li><code>openborconstant(\"SHADOW_CONFIG_GRAPHIC_REPLICA_AIR\")<\/code><\/li>\n\n\n\n<li><code>openborconstant(\"SHADOW_CONFIG_GRAPHIC_REPLICA_GROUND\")<\/code><\/li>\n\n\n\n<li><code>openborconstant(\"SHADOW_CONFIG_GRAPHIC_STATIC_AIR\")<\/code><\/li>\n\n\n\n<li><code>openborconstant(\"SHADOW_CONFIG_GRAPHIC_STATIC_GROUND\")<\/code><\/li>\n\n\n\n<li><code>openborconstant(\"SHADOW_CONFIG_GRAPHIC_ALL\")<\/code> &#8211; All graphic bits. Useful for logic checks.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">This example gets the entity shadow configuration, sets the flag <code>openborconstant(\"SHADOW_CONFIG_DISABLE\")<\/code> and then applies it to entity.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\nint shadow_config = get_entity_property(self, openborconstant(&quot;ENTITY_PROPERTY_SHADOW_CONFIG_FLAGS&quot;));\n \nshadow_config |= openborconstant(&quot;SHADOW_CONFIG_DISABLE&quot;);\n\nset_entity_property(self, openborconstant(&quot;ENTITY_PROPERTY_SHADOW_CONFIG_FLAGS&quot;), shadow_config);\n<\/pre><\/div>\n\n\n<h4 class=\"wp-block-heading\">Shadow Index<\/h4>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nshadow &amp;lt;index&gt;\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Default shadow template index when using static shadows. Place shadow templates in the sprites folder with the filename <code>shadow&lt;index&gt;.png<\/code>. For example, <code>shadow1.png<\/code> is shadow 1, <code>shadow2.png<\/code> is shadow 2 and so on. 0 = No static shadow.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Script<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Shadow index is accessible to script as a <a href=\"https:\/\/chronocrash.com\/obor\/wiki\/model-property\/\" data-type=\"post\" data-id=\"497\">model property<\/a>. This example sets the shadow index to shadow 2.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\nset_model_property(model, openborconstant(&quot;MODEL_PROPERTY_SHADOW_INDEX&quot;), 2);\n<\/pre><\/div>\n\n\n<h4 class=\"wp-block-heading\">Alpha Blending<\/h4>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nalpha &amp;lt;index&gt;\n\n# Default\nalpha 1\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Sets type of blending applied to shadows. identical to model alpha.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Animation<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">Frame Shadow<\/h4>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nfshadow {int} or &quot;none&quot;\n\n# Default\nfshadow none\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Frame command. Enables setting the shadow index on a per frame basis. Identical to <a href=\"#Shadow Index\" data-type=\"internal\" data-id=\"#Shadow Index\">Shadow Index<\/a> other than the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>none<\/code> = Use the model level <code>Shadow Index<\/code>.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Levels<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Light<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nlight &amp;lt;int x&gt; &amp;lt;int z&gt;\n\n# Default\nlight 128 64\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Controls light source angle in a level for generating replicate shadows. Use in conjunction with <strong>at<\/strong> to create levels with dynamic lighting as the player moves about.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>x &#8211; Shadows &#8220;lean&#8221;. 256 is ~45 degrees.<\/li>\n\n\n\n<li>z &#8211; Shadow length. 256 is equal to the original sprite length. Negative values flip the shadow toward player&#8217;s viewpoint.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Shadow and reflection effects.<\/p>\n","protected":false},"author":1,"featured_media":1050,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[17,328],"tags":[403,404,321,322],"class_list":["post-1043","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-graphics","category-openbor","tag-fshadow","tag-light","tag-shadow","tag-shadow_config"],"revision_note":"","jetpack_featured_media_url":"https:\/\/i0.wp.com\/chronocrash.com\/obor\/wiki\/wp-content\/uploads\/2023\/03\/My-Mod-0004.png?fit=320%2C240&ssl=1&wsr","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/chronocrash.com\/obor\/wiki\/wp-json\/wp\/v2\/posts\/1043","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chronocrash.com\/obor\/wiki\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chronocrash.com\/obor\/wiki\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chronocrash.com\/obor\/wiki\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chronocrash.com\/obor\/wiki\/wp-json\/wp\/v2\/comments?post=1043"}],"version-history":[{"count":5,"href":"https:\/\/chronocrash.com\/obor\/wiki\/wp-json\/wp\/v2\/posts\/1043\/revisions"}],"predecessor-version":[{"id":1149,"href":"https:\/\/chronocrash.com\/obor\/wiki\/wp-json\/wp\/v2\/posts\/1043\/revisions\/1149"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/chronocrash.com\/obor\/wiki\/wp-json\/wp\/v2\/media\/1050"}],"wp:attachment":[{"href":"https:\/\/chronocrash.com\/obor\/wiki\/wp-json\/wp\/v2\/media?parent=1043"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chronocrash.com\/obor\/wiki\/wp-json\/wp\/v2\/categories?post=1043"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chronocrash.com\/obor\/wiki\/wp-json\/wp\/v2\/tags?post=1043"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}