{"id":5127,"date":"2024-08-11T16:43:44","date_gmt":"2024-08-11T16:43:44","guid":{"rendered":"https:\/\/castle-engine.io\/wp\/?p=5127"},"modified":"2024-08-11T16:43:44","modified_gmt":"2024-08-11T16:43:44","slug":"new-example-space_shooter-space-ship-shooting-rockets-destroying-rocks-flying-on-a-tiling-background","status":"publish","type":"post","link":"https:\/\/castle-engine.io\/wp\/2024\/08\/11\/new-example-space_shooter-space-ship-shooting-rockets-destroying-rocks-flying-on-a-tiling-background\/","title":{"rendered":"New example space_shooter: space ship shooting rockets, destroying rocks, flying on a tiling background"},"content":{"rendered":"<table class=\"thumbnails thumbnails-align-right\"><tr><td>\n          <a href=\"https:\/\/castle-engine.io\/wp\/wp-content\/uploads\/2024\/08\/screenshot.png\"\n             class=\"screenshot\"\n             title=\"Space shooter example\"><img loading=\"lazy\" decoding=\"async\"\n            style=\"float: right\"\n            src=\"https:\/\/castle-engine.io\/wp\/wp-content\/uploads\/2024\/08\/screenshot-200x119.png\"\n             width=\"200\" height=\"119\" \n            alt=\"Space shooter example\"\n          ><\/a><\/td><\/tr><\/table>\n<p>Enjoy a new example in our engine: <a href=\"https:\/\/github.com\/castle-engine\/castle-engine\/tree\/master\/examples\/space_shooter\">examples\/space_shooter<\/a>. Features:<\/p>\n<ul>\n<li>\n    Space ship (click anywhere on the screen, or use arrows, to move it).<\/p>\n<li>\n<p>Background (drawn efficiently as one quad, with texture repeating to infinity).<\/p>\n<li>\n<p>Rockets (fired by the player&#8217;s cannons). Each rocker has a collider and can detect when it hit an enemy. Rocket can be &#8220;armed&#8221; (destroys enemies) or &#8220;not&#8221; (just a ball that bounces off enemies).<\/p>\n<li>\n<p>Enemies, played by the <em>Mighty Rotating Rocks<\/em>! They just move slowly towards the player. You can shoot them to destroy.\n<\/ul>\n<p>Technically:<\/p>\n<ul>\n<li>\n<p>The player is just a <code><a href=\"https:\/\/castle-engine.io\/apidoc\/html\/CastleScene.TCastleScene.html\">TCastleScene<\/a><\/code> inside a <code><a href=\"https:\/\/castle-engine.io\/apidoc\/html\/CastleViewport.TCastleViewport.html\">TCastleViewport<\/a><\/code>, with input events handled in <code>TViewMain<\/code>.<\/p>\n<li>\n<p>Using <code><a href=\"https:\/\/castle-engine.io\/apidoc\/html\/CastleComponentSerialize.TCastleComponentFactory.html\">TCastleComponentFactory<\/a><\/code> to create rockets and rocks. Each of them is defined by a <a href=\"https:\/\/castle-engine.io\/reuse_design\">reusable design<\/a>.<\/p>\n<li>\n<p>Using <a href=\"https:\/\/castle-engine.io\/behaviors\">behaviors<\/a> to define various behaviors of rocks and rockets.<\/p>\n<li>\n<p>Using <a href=\"https:\/\/castle-engine.io\/physics\">physics<\/a> to handle collisions between rockets and rocks.<\/p>\n<li>\n<p>Special component <a href=\"https:\/\/github.com\/castle-engine\/castle-engine\/blob\/master\/examples\/space_shooter\/code\/gametilingbackground.pas\">TTilingBackground<\/a> to draw a background that (seems to) repeat to infinity. This is a reworked version of an old example <code>background_tiling<\/code>.\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Enjoy a new example in our engine: examples\/space_shooter. Features: Space ship (click anywhere on the screen, or use arrows, to move it). Background (drawn efficiently as one quad, with texture repeating to infinity). Rockets (fired by the player&#8217;s cannons). Each rocker has a collider and can detect when it hit an enemy. Rocket can be &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/castle-engine.io\/wp\/2024\/08\/11\/new-example-space_shooter-space-ship-shooting-rockets-destroying-rocks-flying-on-a-tiling-background\/\" class=\"more-link\">Continue reading  \u27a4<span class=\"screen-reader-text\"> &#8220;New example space_shooter: space ship shooting rockets, destroying rocks, flying on a tiling background&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":5128,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"publish_to_discourse":"1","publish_post_category":"9","wpdc_auto_publish_overridden":"","wpdc_topic_tags":"","wpdc_pin_topic":"","wpdc_pin_until":"","discourse_post_id":"5021","discourse_permalink":"https:\/\/forum.castle-engine.io\/t\/new-example-space-shooter-space-ship-shooting-rockets-destroying-rocks-flying-on-a-tiling-background\/1301","wpdc_publishing_response":"","wpdc_publishing_error":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-5127","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/castle-engine.io\/wp\/wp-content\/uploads\/2024\/08\/screenshot.png","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9IgYW-1kH","jetpack_likes_enabled":false,"_links":{"self":[{"href":"https:\/\/castle-engine.io\/wp\/wp-json\/wp\/v2\/posts\/5127","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/castle-engine.io\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/castle-engine.io\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/castle-engine.io\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/castle-engine.io\/wp\/wp-json\/wp\/v2\/comments?post=5127"}],"version-history":[{"count":1,"href":"https:\/\/castle-engine.io\/wp\/wp-json\/wp\/v2\/posts\/5127\/revisions"}],"predecessor-version":[{"id":5129,"href":"https:\/\/castle-engine.io\/wp\/wp-json\/wp\/v2\/posts\/5127\/revisions\/5129"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/castle-engine.io\/wp\/wp-json\/wp\/v2\/media\/5128"}],"wp:attachment":[{"href":"https:\/\/castle-engine.io\/wp\/wp-json\/wp\/v2\/media?parent=5127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/castle-engine.io\/wp\/wp-json\/wp\/v2\/categories?post=5127"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/castle-engine.io\/wp\/wp-json\/wp\/v2\/tags?post=5127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}