{"id":57,"date":"2021-11-11T21:57:05","date_gmt":"2021-11-11T21:57:05","guid":{"rendered":"https:\/\/blogs.oregonstate.edu\/selfisnotdefined\/?p=57"},"modified":"2021-11-11T21:57:05","modified_gmt":"2021-11-11T21:57:05","slug":"pop-click-whoosh","status":"publish","type":"post","link":"https:\/\/blogs.oregonstate.edu\/selfisnotdefined\/2021\/11\/11\/pop-click-whoosh\/","title":{"rendered":"Pop Click Whoosh"},"content":{"rendered":"\n<p>For me, this week was all about sound effects and making improvements to the UI.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"561\" src=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/4705\/files\/2021\/11\/Screenshot-2021-11-10-184627-1024x561.png\" alt=\"\" class=\"wp-image-59\" srcset=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/4705\/files\/2021\/11\/Screenshot-2021-11-10-184627-1024x561.png 1024w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/4705\/files\/2021\/11\/Screenshot-2021-11-10-184627-300x164.png 300w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/4705\/files\/2021\/11\/Screenshot-2021-11-10-184627-768x421.png 768w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/4705\/files\/2021\/11\/Screenshot-2021-11-10-184627-1536x842.png 1536w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/4705\/files\/2021\/11\/Screenshot-2021-11-10-184627-2048x1122.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Map 2 with an updated UI <\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">SFX<\/h2>\n\n\n\n<p>It seems like a good time to start adding sound to our game.\u00a0 I found some free, nicely organized <a rel=\"noreferrer noopener\" href=\"https:\/\/www.kenney.nl\/assets?q=audio\" target=\"_blank\">Kenney sound packs<\/a> .\u00a0 Unfortunately, there aren\u2019t many gunshot noises there, so I used a percussive footstep sound for the normal bullet type instead. Now whenever the player shoots a bullet from the base turret, the game plays a sound specific to the current ammo type.<\/p>\n\n\n\n<p>The flamethrower sound is still a work in progress. The <a href=\"https:\/\/opengameart.org\/content\/spell-4-fire\" target=\"_blank\" rel=\"noreferrer noopener\">current sound file<\/a> is a single whoosh, but because A) it plays with every bullet event and B) flamethrower ammo works by sending out a line of tightly-spaced bullets, the result is a weird \u201cw-w-w-w-w-w-w-w-whoosh\u201d.\u00a0 I might be able to fix this by writing some special code that will play the full file in a loop, starting with a mouse-down event and ending on the mouse up event, or whenever the flame bullets stop firing.<\/p>\n\n\n\n<p>Oh, also toggling between the two ammo types by pressing Q or W will now produce a switch-click sound.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">UI update (prepare for some boring details)<\/h2>\n\n\n\n<p>Each element in the UI needs an x and y coordinate (represented as an integer number of pixels), so that it shows up in the right spot on the screen.\u00a0 Note that the default origin of an element is in its top-left corner.\u00a0 Rather than hard-coding the coordinates as \u201cmagic numbers\u201d, I tried to create a better system with variables and equations.<\/p>\n\n\n\n<p>So for example, in order to find the coordinates for the bee turret icon (shown below as a beehive) I had to make the following calculations.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/4705\/files\/2021\/11\/Screenshot-2021-11-11-125907-373x1024.png\" alt=\"\" class=\"wp-image-58\" width=\"203\" height=\"558\" srcset=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/4705\/files\/2021\/11\/Screenshot-2021-11-11-125907-373x1024.png 373w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/4705\/files\/2021\/11\/Screenshot-2021-11-11-125907-109x300.png 109w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/4705\/files\/2021\/11\/Screenshot-2021-11-11-125907.png 506w\" sizes=\"auto, (max-width: 203px) 100vw, 203px\" \/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<ul class=\"wp-block-list\"><li>It should appear in the first column of icons. We\u2019ll make a variable <strong>col1X = 1148<\/strong> and set the bee icon x coordinate to <strong>col1X<\/strong>.<\/li><li>We need some more variables for the y coordinates. Let\u2019s make the top UI margin <strong>UIMargin = 32<\/strong>, the height of each icon <strong>iconSide = 64<\/strong>, and the margin between icons <strong>iconMargin = 8<\/strong>.<\/li><li>From the top we have to fit the tower health icon, the money icon, and the \u201cBuy &amp; Place Turrets\u201d header, which is about as tall as an icon.<\/li><li>Thus, we can express the y coordinate for the bee icon as <strong>UIMargin + ((iconSide + iconMargin) * 3)<\/strong><\/li><\/ul>\n<\/div>\n<\/div>\n\n\n\n<p>This system mostly works.\u00a0 I found that in the end I still had to add a few magic numbers to make everything look right.\u00a0 For some weird reason, I had to change the UIMargin to 64 even though it appears to be only 32 pixels from the top of the screen. It\u2019s not as elegant as I wanted but hopefully this system will make it easier to make changes in the future.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For me, this week was all about sound effects and making improvements to the UI. SFX It seems like a good time to start adding sound to our game.\u00a0 I found some free, nicely organized Kenney sound packs .\u00a0 Unfortunately, there aren\u2019t many gunshot noises there, so I used a percussive footstep sound for the &hellip; <a href=\"https:\/\/blogs.oregonstate.edu\/selfisnotdefined\/2021\/11\/11\/pop-click-whoosh\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Pop Click Whoosh<\/span><\/a><\/p>\n","protected":false},"author":11576,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-57","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.oregonstate.edu\/selfisnotdefined\/wp-json\/wp\/v2\/posts\/57","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.oregonstate.edu\/selfisnotdefined\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.oregonstate.edu\/selfisnotdefined\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/selfisnotdefined\/wp-json\/wp\/v2\/users\/11576"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/selfisnotdefined\/wp-json\/wp\/v2\/comments?post=57"}],"version-history":[{"count":1,"href":"https:\/\/blogs.oregonstate.edu\/selfisnotdefined\/wp-json\/wp\/v2\/posts\/57\/revisions"}],"predecessor-version":[{"id":60,"href":"https:\/\/blogs.oregonstate.edu\/selfisnotdefined\/wp-json\/wp\/v2\/posts\/57\/revisions\/60"}],"wp:attachment":[{"href":"https:\/\/blogs.oregonstate.edu\/selfisnotdefined\/wp-json\/wp\/v2\/media?parent=57"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/selfisnotdefined\/wp-json\/wp\/v2\/categories?post=57"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/selfisnotdefined\/wp-json\/wp\/v2\/tags?post=57"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}