{"id":183,"date":"2023-10-30T22:12:56","date_gmt":"2023-10-30T22:12:56","guid":{"rendered":"https:\/\/retrorendezvous.org\/?p=183"},"modified":"2023-11-10T17:01:27","modified_gmt":"2023-11-10T17:01:27","slug":"programming-project-space-probe","status":"publish","type":"post","link":"https:\/\/retrorendezvous.org\/index.php\/2023\/10\/30\/programming-project-space-probe\/","title":{"rendered":"Programming Project : Space Probe"},"content":{"rendered":"\n<p>Back in 1986 I coded a game for the ZX Spectrum that was published in Popular Computing Weekly. Remember that magazine, where you could type in Basic programs and perhaps get them to work?<\/p>\n\n\n\n<p>In this thread I&#8217;ll be working on&nbsp;<strong>converting this to BBC Basic&nbsp;<\/strong>as part of my relearning of this language.<\/p>\n\n\n\n<p>For anyone else that may have published their BASIC programs during that time, there&#8217;s two useful archives here:-<\/p>\n\n\n\n<p>1. Index for Spectrum\/QL typed in scripts :&nbsp;<a href=\"http:\/\/www.users.globalnet.co.uk\/~jg27paw4\/type-ins\/popcomwk\/pw_names.htm\">http:\/\/www.users.globalnet.co.uk\/~jg27p &#8230; _names.htm<\/a><br>2. This archive is from the &#8220;World of Spectrum&#8221; but the mag covers all scripts from different machines of the time.&nbsp;<a href=\"https:\/\/worldofspectrum.org\/archive\/magazines\/popular-computing-weekly\">https:\/\/worldofspectrum.org\/archive\/mag &#8230; ing-weekly<\/a><\/p>\n\n\n\n<p>Here&#8217;s the original mag and published page:-<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/retrorendezvous.org\/wp-content\/uploads\/2023\/10\/PCW-CoverMarch1986.jpg\" alt=\"Image\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/retrorendezvous.org\/wp-content\/uploads\/2023\/10\/PCW-SpaceProbe.jpg\" alt=\"Image\"\/><\/figure>\n\n\n\n<p>I&#8217;ve been using the excellent Owlet editor on my Mac (I can type faster on a modern keyboard) and my first question is on the use of RND, which is very much prevalent in the code above which I&#8217;ll need in the BBC script.<\/p>\n\n\n\n<p>I&#8217;ve noticed in Owlet that when using RND(X) it ends up giving you the\u00a0<strong>same number each time<\/strong>, unless you have some code asking for input at the beginning (providing a random time spanned event at the start).<\/p>\n\n\n\n<p>Here&#8217;s my finished script which ends up being better than the 1986 version.<\/p>\n\n\n\n<p>Use this <a href=\"https:\/\/bbcmic.ro\/#%7B%22v%22%3A1%2C%22program%22%3A%22REM%20Space%20probe%20by%20Paul%20Bussey%20%28C%292023%5Cnkeep%24%3D%5C%22N%5C%22%20%3A%20REM%20Controls%20if%20planet%20position%20and%20size%20is%20kept%20between%20games%5CnG%25%20%3D%2010%20%3A%20REM%20gravitational%20constant%5Cnexitspace%25%20%3D%200%20%3A%20REM%20if%20-2%20the%20spacecraft%20is%20out%20of%20bounds%20without%20success%20and%20-1%20if%20it%20has%20reached%20the%20goal%20area%5CnIF%20keep%24%20%3D%20%5C%22N%5C%22%20THEN%20saturnX%25%20%3D%20RND%28800%29%2B200%20%3A%20saturnY%25%20%3D%20RND%28800%29%2B200%20%3A%20saturnRadius%25%20%3D%20RND%28200%29%2B50%20%3A%20saturnMass%25%20%3D%20saturnRadius%25%20*%2050%5Cn%5CnG%25%3DsaturnMass%25*G%25%5Cn%5CnspacecraftX%20%3D%2020%5Cn%5CnMODE%201%5CnCLS%5Cn%5CnCOLOUR%202%5CnREPEAT%5CnvalidationMessage%24%20%3D%20%5C%22%5C%22%5CnCOLOUR%203%20%3A%20PRINT%20%5C%22%20%20%20%20%20%20%20%20Welcome%20to%20SPACE%20PROBE%5C%22%5CnPRINT%5CnCOLOUR%202%20%3A%20PRINT%20%5C%22Your%20mission%20is%20to%20guide%20a%20space%20probe%20%20past%20a%20randomly%20generated%20planet%20towards%20a%20goal%20exit%20area%5C%22%5CnPRINT%20%5CnINPUT%20%20%5C%22The%20Y%20axis%20start%20position%20%280-1000%29%3A%5C%22%20%2C%20spacecraftY%5CnPRINT%20%5CnINPUT%20%20%5C%22Initial%20angle%20of%20flight%20%280%20%3D%20east%2C%20positive%20values%20upwards%20up%20to%2090%20DEG%2C%20negative%20values%20downwards%20down%20to%20-90%20DEG%29%3A%5C%22%2C%20a%5CnPRINT%20%5CnINPUT%20%20%5C%22Velocity%20%285-30%29%5C%22%2C%20v%5Cn%5CnIF%20spacecraftY%20%3C0%20OR%20spacecraftY%3E1000%20THEN%20validationMessage%24%20%3D%20%5C%22Spacecraft%20Y%20axis%20position%20out%20of%20range%5C%22%5CnIF%20a%20%3C-90%20OR%20a%3E90%20THEN%20validationMessage%24%20%3D%20%5C%22Initial%20angle%20of%20flight%20out%20of%20range%5C%22%5CnIF%20v%20%3C5%20OR%20v%3E30%20THEN%20validationMessage%24%20%3D%20%5C%22Velocity%20out%20of%20range%5C%22%5Cn%5CnIF%20validationMessage%24%20%3C%3E%20%5C%22%5C%22%20THEN%20PRINT%20%3A%20COLOUR%201%20%3A%20PRINT%20validationMessage%24%5CnPRINT%20%5C%22Press%20any%20key%20to%20continue%5C%22%5CnKey%25%20%3D%20GET%5CnCLS%5CnUNTIL%20validationMessage%24%20%3D%20%5C%22%5C%22%5Cn%5CnVDU%2023%2C1%2C0%3B0%3B0%3B0%3B%5Cn%5CnCOLOUR%201%5CnREM%20Set%20up%20the%20target%20line%5Cn%5CnIF%20keep%24%20%3D%20%5C%22N%5C%22%20THEN%20LET%20targetlinelen%25%20%3D200%20%3A%20LET%20axis%25%20%3D%20RND%282%29%20%3A%20LET%20targetlinestart%25%20%3D%20RND%28256-targetlinelen%25%29%5Cn%5CnREM%20Draw%20target%20line%20-%20either%20X%20or%20Y%20axis%20on%20the%20far%20side.%20axis%3C0.5%20is%20Y%20axis.%5Cn%5CnIF%20axis%25%20%3D1%20THEN%20MOVE%20%201200%2Ctargetlinestart%25%20%3A%20DRAW%201200%2Ctargetlinestart%25%2Btargetlinelen%25%20ELSE%20MOVE%20%20targetlinestart%25%2C0%20%3A%20DRAW%20targetlinestart%25%2Btargetlinelen%25%2C0%5Cn%5CnREM%20Set%20up%20marked%20X%20axis%20and%20draw%20some%20stars%20for%20effect!%5Cn%5CnMOVE%200%2C0%20%3A%20DRAW%200%2C%201000%5CnFOR%20n%20%3D%201000%20TO%200%20STEP%20-100%5CnMOVE%200%2Cn%20%3A%20DRAW%2020%2Cn%5CnPLOT%2069%2CRND%281000%29%2CRND%281000%29%5CnNEXT%20n%5Cn%5Cn%3AREM%20Draw%20the%20planet%5CnPROC_DrawPlanet%28saturnX%25%2C%20saturnY%25%2C%20saturnRadius%25%29%5Cn%5Cn%3AREM%20Drawing%20Rings%20using%20ellipses%5CnGCOL%200%2C%203%5CnFOR%20ringNum%25%20%3D%201%20TO%203%5Cn%5CnringWidth%25%20%3D%20saturnRadius%25%20%2B%20ringNum%25%20*%2040%5CnringHeight%25%20%3D%2020%20%2B%20ringNum%25%20*%2012%5Cn%5CnPROC_DrawEllipse%28saturnX%25%2C%20saturnY%25%2C%20ringWidth%25%2C%20ringHeight%25%29%5Cn%5CnNEXT%5Cn%5CnREM%20Print%20stats%20at%20the%20top%5Cn%5CnCOLOUR%203%5Cn%5CnPRINT%20%5C%22Planet%20mass%3A%5C%22%3B%20saturnMass%25%20%5C%22%20Velocity%3A%20%5C%22%3B%20v%20%5C%22%20at%20%5C%22%3B%20a%20%5C%22%20DEG%5C%22%5CnPRINT%20%5C%22Space%20probe%20Y%20axis%20start%20position%3A%20%5C%22%3B%20spacecraftY%5Cn%5CnREM%20Start%20calculating%20-%20initial%20velocity%20of%20space%20probe%5Cn%5Cna%3Da*%28PI%2F180%29%5Cn%5Cnvx%20%3D%20v*COS%28a%29%5Cnvy%20%3D%20v*SIN%28a%29%5Cn%5CnREM%20Simulate%20and%20draw%20spacecraft's%20path%5Cn%5CnMOVE%20spacecraftX%2CspacecraftY%5Cn%5CnGCOL%200%2C%202%20%20%3AREM%20Color%20for%20spacecraft%5Cn%5Cnexitspace%20%3D0%5Cn%5CnREPEAT%5Cn%5CnREM%20Compute%20gravitational%20force%5Cndx%20%3D%20saturnX%25%20-%20spacecraftX%5Cndy%20%3D%20saturnY%25%20-%20spacecraftY%5Cndistance%20%3D%20dx*dx%20%2B%20dy*dy%5Cn%5Cnforce%20%3D%20G%25%20%2F%20distance%20%5Cn%5Cnsd%3DSQR%28distance%29%5Cn%5Cnax%3Dforce*dx%2Fsd%5Cnay%3Dforce*dy%2Fsd%5Cn%5Cnvx%3Dvx%2Bax%20%5Cn%5Cnvy%3Dvy%2Bay%5Cn%5CnREM%20Update%20spacecraft's%20position%5CnspacecraftX%20%3D%20spacecraftX%20%2B%20vx-ax*0.5%5CnspacecraftY%20%3D%20spacecraftY%20%2B%20vy-ay*0.5%5Cn%5CnDRAW%20spacecraftX%2CspacecraftY%5Cn%5CnREM%20Check%20for%20success%5CnREM%20PROC_CheckSuccess%28axis%25%2CspacecraftX%2CspacecraftY%29%5CnREM%20Check%20if%20out%20of%20bounds%5Cn%5CnIF%20exitspace%20%3D%200%20AND%20%28spacecraftX%20%3E%201200%20OR%20spacecraftY%20%20%3C%200%20OR%20spacecraftY%20%20%3E%201024%20OR%20spacecraftX%20%20%3C%200%29%20THEN%20exitspace%20%3D%20-2%5Cn%5CnUNTIL%20exitspace%3D-2%5Cn%5CnIF%20axis%25%3D1%20THEN%20startcheck%25%20%3D%20targetlinestart%25%20%3A%20endcheck%25%20%3D%20targetlinestart%25%2Btargetlinelen%25%20ELSE%20startcheck%25%20%3D%201200%20%2B%20targetlinestart%25%20%3A%20endcheck%25%20%3D%201200%20%2B%20targetlinestart%25%20%2B%20targetlinelen%25%5Cn%5CnIF%20axis%25%3D1%20AND%20spacecraftX%3E1200%20AND%20spacecraftY%3E%3Dstartcheck%25%20AND%20spacecraftY%3C%3Dendcheck%25%20THEN%20exitspace%3D-1%20%5CnIF%20axis%25%3D2%20AND%20spacecraftY%3C0%20AND%20spacecraftX%3E%3Dstartcheck%25%20AND%20spacecraftX%3C%3Dendcheck%25%20THEN%20exitspace%3D-1%20%5Cn%5CnIF%20exitspace%20%3D%20-1%20THEN%20COLOUR%202%3A%20PRINT%20%3A%20PRINT%20%5C%22%20%20%20%20%20%20%20%20%20%20MISSION%20SUCCESS!%5C%22%5CnIF%20exitspace%20%3D%20-2%20THEN%20COLOUR%201%20%3A%20PRINT%20%3A%20PRINT%20%5C%22%20%20%20%20%20%20%20%20%20%20MISSION%20FAILED!%5C%22%5Cn%5CnREPEAT%20%5CnPRINT%5CnINPUT%20%5C%22Keep%20current%20planet%20position%20and%20size%20and%20goal%20exit%20position%3F%20%28Y%2FN%29%5C%22%2Ckeep%24%5CnUNTIL%20keep%24%20%3D%20%5C%22Y%5C%22%20OR%20keep%24%3D%5C%22N%5C%22%5Cn%5CnPRINT%20%3A%20PRINT%20%5C%22Press%20any%20key%20to%20continue%5C%22%5CnKey%25%20%3D%20GET%5CnCLS%5Cn%5CnGOTO%2030%5Cn%5CnDEF%20PROC_DrawPlanet%28h%25%2C%20k%25%2C%20r%25%29%5CnGCOL%200%2C%205%5CnMOVE%20h%25%2C%20k%25%5CnPLOT%20145%2C%20r%25%2C%200%5CnENDPROC%5Cn%5CnDEF%20PROC_DrawEllipse%28h%25%2C%20k%25%2C%20hr%25%2C%20vr%25%29%5CnMOVE%20h%25%2C%20k%25%5CnPLOT%200%2C%20hr%25%2C%200%5CnPLOT%20193%2C%200%2C%20vr%25%5CnENDPROC%22%7D\">link<\/a> to see and run the BBC Basic script.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Back in 1986 I coded a game for the ZX Spectrum that was published in Popular Computing Weekly. Remember that magazine, where you could type in Basic programs and perhaps [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":179,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","_price":"","_stock":"","_tribe_ticket_header":"","_tribe_default_ticket_provider":"","_tribe_ticket_capacity":"0","_ticket_start_date":"","_ticket_end_date":"","_tribe_ticket_show_description":"","_tribe_ticket_show_not_going":false,"_tribe_ticket_use_global_stock":"","_tribe_ticket_global_stock_level":"","_global_stock_mode":"","_global_stock_cap":"","_tribe_rsvp_for_event":"","_tribe_ticket_going_count":"","_tribe_ticket_not_going_count":"","_tribe_tickets_list":"[]","_tribe_ticket_has_attendee_info_fields":false,"footnotes":""},"categories":[27,19],"tags":[],"class_list":["post-183","post","type-post","status-publish","format-standard","has-post-thumbnail","category-basic-programming","category-bbc-micro-b","entry"],"featured_image_src":"https:\/\/retrorendezvous.org\/wp-content\/uploads\/2023\/10\/PCW-SpaceProbe-600x400.jpg","featured_image_src_square":"https:\/\/retrorendezvous.org\/wp-content\/uploads\/2023\/10\/PCW-SpaceProbe-600x600.jpg","author_info":{"display_name":"Paul Bussey","author_link":"https:\/\/retrorendezvous.org\/index.php\/author\/paul-admin\/"},"_links":{"self":[{"href":"https:\/\/retrorendezvous.org\/index.php\/wp-json\/wp\/v2\/posts\/183","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/retrorendezvous.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/retrorendezvous.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/retrorendezvous.org\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/retrorendezvous.org\/index.php\/wp-json\/wp\/v2\/comments?post=183"}],"version-history":[{"count":4,"href":"https:\/\/retrorendezvous.org\/index.php\/wp-json\/wp\/v2\/posts\/183\/revisions"}],"predecessor-version":[{"id":206,"href":"https:\/\/retrorendezvous.org\/index.php\/wp-json\/wp\/v2\/posts\/183\/revisions\/206"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/retrorendezvous.org\/index.php\/wp-json\/wp\/v2\/media\/179"}],"wp:attachment":[{"href":"https:\/\/retrorendezvous.org\/index.php\/wp-json\/wp\/v2\/media?parent=183"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/retrorendezvous.org\/index.php\/wp-json\/wp\/v2\/categories?post=183"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/retrorendezvous.org\/index.php\/wp-json\/wp\/v2\/tags?post=183"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}