mirror of
https://github.com/sotrh/learn-wgpu.git
synced 2024-11-08 07:10:33 +00:00
1 line
80 KiB
JavaScript
1 line
80 KiB
JavaScript
(window.webpackJsonp=window.webpackJsonp||[]).push([[20],{244:function(A,t){A.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAB4AAAAQ4CAIAAABnsVYUAAAAA3NCSVQICAjb4U/gAAAAGXRFWHRTb2Z0d2FyZQBnbm9tZS1zY3JlZW5zaG907wO/PgAAGrRJREFUeJzs3ctqQkEQQEE7+P+/PFkEgoKGED0ZH1Wri4j0QqQ5DOPhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAI9pdg8AwN+ttS6+PuPnHQAADofrO/Mp+zNA52P3AAAAAAAAvCYBGgAAAACAhAANAAAAAEDCJUcAT8YddgAA8LPTnfnabuz/VAD+hxPQAAAAAAAkBGgAAAAAABICNAAAAAAACRcbATwx99YBAMCXW3ZjezVAxwloAAAAAAASAjQAAAAAAAkBGgAAAACAhAANAAAAAEBCgAYAAAAAICFAAwAAAACQEKABAAAAAEgI0AAAAAAAJARoAAAAAAASAjQAAAAAAAkBGgAAAACAxHH3AAAAAAC3mpnv57XWxefT9/zmcwC4nRPQAAAAAAAkBGgAAAAAABICNAAAAAAACRcbATyB03vrbuE+OwAA3s1vdml7MkDHCWgAAAAAABICNAAAAAAACQEaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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lotsDistributor",{attrs:{"slot-key":A.$parent.slotKey}},[a("h1",{attrs:{id:"pong"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#pong"}},[A._v("#")]),A._v(" Pong")]),A._v(" "),a("p",[a("img",{attrs:{src:s(244),alt:""}})]),A._v(" "),a("p",[A._v('Practically the "Hello World!" of games. Pong has been remade thousands of times. I know Pong. You know Pong. We all know Pong. That being said, this time I wanted to put a little more effort than most people do. This showcase has a basic menu system, sounds, and different game states.')]),A._v(" "),a("p",[A._v("The architecture is not the best as I prescribed to the \"get things done\" mentality. If I were to redo this project, I'd change a lot of things. Regardless, let's get into the postmortem.")]),A._v(" "),a("h2",{attrs:{id:"the-architecture"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#the-architecture"}},[A._v("#")]),A._v(" The Architecture")]),A._v(" "),a("p",[A._v("I was messing around with separating state from the render code. It ended up similar to an entity component system.")]),A._v(" "),a("p",[A._v("I had a "),a("code",[A._v("State")]),A._v(" class with all of the objects in the scene. This included the ball and the paddles, as well as the text for the scores and even the menu. "),a("code",[A._v("State")]),A._v(" also included a "),a("code",[A._v("game_state")]),A._v(" field of type "),a("code",[A._v("GameState")]),A._v(".")]),A._v(" "),a("div",{staticClass:"language-rust extra-class"},[a("pre",{pre:!0,attrs:{class:"language-rust"}},[a("code",[a("span",{pre:!0,attrs:{class:"token attribute attr-name"}},[A._v("#[derive(Debug, Copy, Clone, Eq, PartialEq)]")]),A._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("pub")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("enum")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token type-definition class-name"}},[A._v("GameState")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("MainMenu")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Serving")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Playing")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("GameOver")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Quiting")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n")])])]),a("p",[A._v("The "),a("code",[A._v("State")]),A._v(" class didn't have any methods on it as I was taking a more data oriented approach. Instead I created a "),a("code",[A._v("System")]),A._v(" trait, and created multiple structs that implemented it.")]),A._v(" "),a("div",{staticClass:"language-rust extra-class"},[a("pre",{pre:!0,attrs:{class:"language-rust"}},[a("code",[a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("pub")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("trait")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("System")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token attribute attr-name"}},[A._v("#[allow(unused_variables)]")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("fn")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token function-definition function"}},[A._v("start")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("mut")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("mut")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token namespace"}},[A._v("state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")])]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("State")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("fn")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token function-definition function"}},[A._v("update_state")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" \n input"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token namespace"}},[A._v("input"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")])]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Input")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" \n state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("mut")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token namespace"}},[A._v("state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")])]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("State")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" \n events"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("mut")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Vec")]),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("<")]),a("span",{pre:!0,attrs:{class:"token namespace"}},[A._v("state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")])]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Event")]),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v(">")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(";")]),A._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n")])])]),a("p",[A._v("The systems would be in charge of controlling updating the different objects state (position, visibility, etc), as well as updating the "),a("code",[A._v("game_state")]),A._v(" field. I created all the systems on startup, and used a "),a("code",[A._v("match")]),A._v(" on "),a("code",[A._v("game_state")]),A._v(" to determine which ones should be allow to run (the "),a("code",[A._v("visiblity_system")]),A._v(" always runs as it is always needed).")]),A._v(" "),a("div",{staticClass:"language-rust extra-class"},[a("pre",{pre:!0,attrs:{class:"language-rust"}},[a("code",[A._v("visiblity_system"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[A._v("update_state")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),A._v("input"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("mut")]),A._v(" state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("mut")]),A._v(" events"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(";")]),A._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("match")]),A._v(" state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("game_state "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token namespace"}},[A._v("state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")])]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("GameState")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("MainMenu")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("=>")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n menu_system"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[A._v("update_state")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),A._v("input"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("mut")]),A._v(" state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("mut")]),A._v(" events"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(";")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("if")]),A._v(" state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("game_state "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("==")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token namespace"}},[A._v("state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")])]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("GameState")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Serving")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n serving_system"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[A._v("start")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("mut")]),A._v(" state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(";")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token namespace"}},[A._v("state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")])]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("GameState")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Serving")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("=>")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n serving_system"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[A._v("update_state")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),A._v("input"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("mut")]),A._v(" state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("mut")]),A._v(" events"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(";")]),A._v("\n play_system"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[A._v("update_state")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),A._v("input"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("mut")]),A._v(" state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("mut")]),A._v(" events"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(";")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("if")]),A._v(" state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("game_state "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("==")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token namespace"}},[A._v("state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")])]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("GameState")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Playing")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n play_system"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[A._v("start")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("mut")]),A._v(" state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(";")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token namespace"}},[A._v("state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")])]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("GameState")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Playing")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("=>")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n ball_system"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[A._v("update_state")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),A._v("input"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("mut")]),A._v(" state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("mut")]),A._v(" events"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(";")]),A._v("\n play_system"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[A._v("update_state")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),A._v("input"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("mut")]),A._v(" state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("mut")]),A._v(" events"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(";")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("if")]),A._v(" state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("game_state "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("==")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token namespace"}},[A._v("state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")])]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("GameState")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Serving")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n serving_system"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[A._v("start")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("mut")]),A._v(" state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(";")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("else")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("if")]),A._v(" state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("game_state "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("==")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token namespace"}},[A._v("state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")])]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("GameState")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("GameOver")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n game_over_system"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[A._v("start")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("mut")]),A._v(" state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(";")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token namespace"}},[A._v("state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")])]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("GameState")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("GameOver")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("=>")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n game_over_system"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[A._v("update_state")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),A._v("input"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("mut")]),A._v(" state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("mut")]),A._v(" events"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(";")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("if")]),A._v(" state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("game_state "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("==")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token namespace"}},[A._v("state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")])]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("GameState")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("MainMenu")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n menu_system"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[A._v("start")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("mut")]),A._v(" state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(";")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token namespace"}},[A._v("state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")])]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("GameState")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Quiting")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("=>")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n")])])]),a("p",[A._v("It's definitely not the cleanest code, but it works.")]),A._v(" "),a("p",[A._v("I ended up having 6 systems in total.")]),A._v(" "),a("ol",[a("li",[a("p",[A._v("I added the "),a("code",[A._v("VisibilitySystem")]),A._v(" near the end of development. Up to that point, all the systems had to set the "),a("code",[A._v("visible")]),A._v(" field of the objects. That was a pain, and cluttered the logic. Instead I decided to create the "),a("code",[A._v("VisiblitySystem")]),A._v(" to handle that.")])]),A._v(" "),a("li",[a("p",[A._v("The "),a("code",[A._v("MenuSystem")]),A._v(" handled controlling what text was focused, and what would happen when the user pressed the enter key. If the "),a("code",[A._v("Play")]),A._v(" button was focused, pressing enter would change "),a("code",[A._v("game_state")]),A._v(" to "),a("code",[A._v("GameState::Serving")]),A._v(" which would start the game. The "),a("code",[A._v("Quit")]),A._v(" button would shift to "),a("code",[A._v("GameState::Quiting")]),A._v(".")])]),A._v(" "),a("li",[a("p",[A._v("The "),a("code",[A._v("ServingSystem")]),A._v(" sets the balls position to "),a("code",[A._v("(0.0, 0.0)")]),A._v(", updates the score texts, and shifts into "),a("code",[A._v("GameState::Playing")]),A._v(" after a timer.")])]),A._v(" "),a("li",[a("p",[A._v("The "),a("code",[A._v("PlaySystem")]),A._v(" controls the players. It allows them to move, and keeps them from leaving the play space. This system runs on both "),a("code",[A._v("GameState::Playing")]),A._v(" as well as "),a("code",[A._v("GameState::Serving")]),A._v(". I did this to allow the players to reposition themselves before the serve. The "),a("code",[A._v("PlaySystem")]),A._v(" also will shift into "),a("code",[A._v("GameState::GameOver")]),A._v(" when on of the players scores is greater than 2.")])]),A._v(" "),a("li",[a("p",[A._v("The "),a("code",[A._v("BallSystem")]),A._v(" system controls the balls movement as well as its bouncing of walls/players. It also updates the score and shifts to "),a("code",[A._v("GameState::Serving")]),A._v(" when the ball goes off the side of the screen.")])]),A._v(" "),a("li",[a("p",[A._v("The "),a("code",[A._v("GameOver")]),A._v(" system updates the "),a("code",[A._v("win_text")]),A._v(" and shifts to "),a("code",[A._v("GameState::MainMenu")]),A._v(" after a delay.")])])]),A._v(" "),a("p",[A._v("I found the system approach to quite nice to work with. My implementation wasn't the best, but I would like working with it again. I might even implement my own ECS.")]),A._v(" "),a("h2",{attrs:{id:"input"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#input"}},[A._v("#")]),A._v(" Input")]),A._v(" "),a("p",[A._v("The "),a("code",[A._v("System")]),A._v(" trait, originally had a "),a("code",[A._v("process_input")]),A._v(" method. This became a problem when I was implementing allowing players to move between serves. The players would get stuck when the "),a("code",[A._v("game_state")]),A._v(" switched from "),a("code",[A._v("Serving")]),A._v(" to "),a("code",[A._v("Playing")]),A._v(" as the inputs were getting stuck. I only called "),a("code",[A._v("process_input")]),A._v(" on systems that were currently in use. Changing that would be finicky, so I decided to move all the input code into its own struct.")]),A._v(" "),a("div",{staticClass:"language-rust extra-class"},[a("pre",{pre:!0,attrs:{class:"language-rust"}},[a("code",[a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("use")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token namespace"}},[A._v("winit"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")]),A._v("event"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")])]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("VirtualKeyCode")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("ElementState")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(";")]),A._v("\n\n"),a("span",{pre:!0,attrs:{class:"token attribute attr-name"}},[A._v("#[derive(Debug, Default)]")]),A._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("pub")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("struct")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token type-definition class-name"}},[A._v("Input")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("pub")]),A._v(" p1_up_pressed"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("bool")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("pub")]),A._v(" p1_down_pressed"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("bool")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("pub")]),A._v(" p2_up_pressed"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("bool")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("pub")]),A._v(" p2_down_pressed"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("bool")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("pub")]),A._v(" enter_pressed"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("bool")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("impl")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Input")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("pub")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("fn")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token function-definition function"}},[A._v("new")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("->")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("Self")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Default")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")]),a("span",{pre:!0,attrs:{class:"token function"}},[A._v("default")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("pub")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("fn")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token function-definition function"}},[A._v("update")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("mut")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" key"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("VirtualKeyCode")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("ElementState")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("->")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("bool")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("let")]),A._v(" pressed "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("=")]),A._v(" state "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("==")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("ElementState")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Pressed")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(";")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("match")]),A._v(" key "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("VirtualKeyCode")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Up")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("=>")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("p2_up_pressed "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("=")]),A._v(" pressed"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(";")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token boolean"}},[A._v("true")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("VirtualKeyCode")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Down")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("=>")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("p2_down_pressed "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("=")]),A._v(" pressed"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(";")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token boolean"}},[A._v("true")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("VirtualKeyCode")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("W")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("=>")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("p1_up_pressed "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("=")]),A._v(" pressed"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(";")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token boolean"}},[A._v("true")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("VirtualKeyCode")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("S")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("=>")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("p1_down_pressed "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("=")]),A._v(" pressed"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(";")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token boolean"}},[A._v("true")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("VirtualKeyCode")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Return")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("=>")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("enter_pressed "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("=")]),A._v(" pressed"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(";")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token boolean"}},[A._v("true")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n _ "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("=>")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token boolean"}},[A._v("false")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("pub")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("fn")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token function-definition function"}},[A._v("ui_up_pressed")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("->")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("bool")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("p1_up_pressed "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("||")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("p2_up_pressed\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("pub")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("fn")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token function-definition function"}},[A._v("ui_down_pressed")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("->")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("bool")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("p1_down_pressed "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("||")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("p2_down_pressed\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n")])])]),a("p",[A._v("This works really well. I simply pass this struct into the "),a("code",[A._v("update_state")]),A._v(" method.")]),A._v(" "),a("h2",{attrs:{id:"render"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#render"}},[A._v("#")]),A._v(" Render")]),A._v(" "),a("p",[A._v("I used "),a("a",{attrs:{href:"https://docs.rs/wgpu_glyph",target:"_blank",rel:"noopener noreferrer"}},[A._v("wgpu_glyph"),a("OutboundLink")],1),A._v(" for the text, and white quads for the ball and paddles. There's not much to say here, it's Pong after all.")]),A._v(" "),a("p",[A._v("I did mess around with batching however. It was totally overkill for this project, but it was a good learning experience. Here's the code if you're interested.")]),A._v(" "),a("div",{staticClass:"language-rust extra-class"},[a("pre",{pre:!0,attrs:{class:"language-rust"}},[a("code",[a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("pub")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("struct")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token type-definition class-name"}},[A._v("QuadBufferBuilder")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n vertex_data"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Vec")]),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("<")]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Vertex")]),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v(">")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n index_data"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Vec")]),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("<")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("u32")]),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v(">")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n current_quad"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("u32")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("impl")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("QuadBufferBuilder")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("pub")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("fn")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token function-definition function"}},[A._v("new")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("->")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("Self")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("Self")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n vertex_data"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Vec")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")]),a("span",{pre:!0,attrs:{class:"token function"}},[A._v("new")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n index_data"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Vec")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")]),a("span",{pre:!0,attrs:{class:"token function"}},[A._v("new")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n current_quad"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[A._v("0")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("pub")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("fn")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token function-definition function"}},[A._v("push_ball")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" ball"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token namespace"}},[A._v("state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")])]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Ball")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("->")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("Self")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("if")]),A._v(" ball"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("visible "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("let")]),A._v(" min_x "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("=")]),A._v(" ball"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("position"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("x "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("-")]),A._v(" ball"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("radius"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(";")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("let")]),A._v(" min_y "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("=")]),A._v(" ball"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("position"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("y "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("-")]),A._v(" ball"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("radius"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(";")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("let")]),A._v(" max_x "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("=")]),A._v(" ball"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("position"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("x "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("+")]),A._v(" ball"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("radius"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(";")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("let")]),A._v(" max_y "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("=")]),A._v(" ball"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("position"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("y "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("+")]),A._v(" ball"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("radius"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(";")]),A._v("\n \n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[A._v("push_quad")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),A._v("min_x"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" min_y"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" max_x"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" max_y"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("else")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("pub")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("fn")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token function-definition function"}},[A._v("push_player")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" player"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token namespace"}},[A._v("state"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")])]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Player")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("->")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("Self")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("if")]),A._v(" player"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("visible "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[A._v("push_quad")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),A._v("\n player"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("position"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("x "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("-")]),A._v(" player"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("size"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("x "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("*")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[A._v("0.5")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" \n player"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("position"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("y "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("-")]),A._v(" player"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("size"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("y "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("*")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[A._v("0.5")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" \n player"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("position"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("x "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("+")]),A._v(" player"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("size"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("x "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("*")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[A._v("0.5")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n player"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("position"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("y "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("+")]),A._v(" player"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("size"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("y "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("*")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[A._v("0.5")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" \n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("else")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("pub")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("fn")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token function-definition function"}},[A._v("push_quad")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("mut")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" min_x"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("f32")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" min_y"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("f32")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" max_x"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("f32")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" max_y"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("f32")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("->")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("Self")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("vertex_data"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[A._v("extend")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("[")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Vertex")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n position"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),A._v("min_x"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" min_y"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[A._v("into")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Vertex")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n position"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),A._v("max_x"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" min_y"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[A._v("into")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Vertex")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n position"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),A._v("max_x"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" max_y"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[A._v("into")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Vertex")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n position"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),A._v("min_x"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" max_y"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[A._v("into")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("]")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(";")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("index_data"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[A._v("extend")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("[")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("current_quad "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("*")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[A._v("4")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("+")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[A._v("0")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("current_quad "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("*")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[A._v("4")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("+")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[A._v("1")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("current_quad "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("*")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[A._v("4")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("+")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[A._v("2")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("current_quad "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("*")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[A._v("4")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("+")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[A._v("0")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("current_quad "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("*")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[A._v("4")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("+")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[A._v("2")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("current_quad "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("*")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[A._v("4")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("+")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[A._v("3")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("]")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(";")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("current_quad "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("+=")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[A._v("1")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(";")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("pub")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("fn")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token function-definition function"}},[A._v("build")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" device"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(":")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token namespace"}},[A._v("wgpu"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")])]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Device")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("->")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("StagingBuffer")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("StagingBuffer")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("u32")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("StagingBuffer")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")]),a("span",{pre:!0,attrs:{class:"token function"}},[A._v("new")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),A._v("device"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("vertex_data"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("StagingBuffer")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")]),a("span",{pre:!0,attrs:{class:"token function"}},[A._v("new")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),A._v("device"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("&")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("index_data"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("self")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),A._v("index_data"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[A._v("len")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("as")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("u32")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n")])])]),a("h2",{attrs:{id:"sound"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#sound"}},[A._v("#")]),A._v(" Sound")]),A._v(" "),a("p",[A._v("I used "),a("a",{attrs:{href:"https://docs.rs/rodio",target:"_blank",rel:"noopener noreferrer"}},[A._v("rodio"),a("OutboundLink")],1),A._v(" for sound. I created a "),a("code",[A._v("SoundPack")]),A._v(" class to store the sounds. Deciding how to get the sounds to play took some thinking. I chose to pass in a "),a("code",[A._v("Vec<state::Event>")]),A._v(" into the "),a("code",[A._v("update_state")]),A._v(" method. The system would then push an event to the "),a("code",[A._v("Vec")]),A._v(". The "),a("code",[A._v("Event")]),A._v(" enum is listed below.")]),A._v(" "),a("div",{staticClass:"language-rust extra-class"},[a("pre",{pre:!0,attrs:{class:"language-rust"}},[a("code",[a("span",{pre:!0,attrs:{class:"token attribute attr-name"}},[A._v("#[derive(Debug, Copy, Clone)]")]),A._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("pub")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("enum")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token type-definition class-name"}},[A._v("Event")]),A._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("{")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("ButtonPressed")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("FocusChanged")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("BallBounce")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token namespace"}},[A._v("cgmath"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("::")])]),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Vector2")]),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v("<")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("f32")]),a("span",{pre:!0,attrs:{class:"token operator"}},[A._v(">")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n "),a("span",{pre:!0,attrs:{class:"token class-name"}},[A._v("Score")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("(")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[A._v("u32")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v(",")]),A._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[A._v("}")]),A._v("\n")])])]),a("p",[A._v("I was going to have "),a("code",[A._v("BallBounce")]),A._v(" play a positioned sound using a "),a("code",[A._v("SpatialSink")]),A._v(", but I was getting clipping issues, and I wanted to be done with the project. Aside from that, the events system worked nicely.")]),A._v(" "),a("h2",{attrs:{id:"summary"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#summary"}},[A._v("#")]),A._v(" Summary")]),A._v(" "),a("p",[A._v("A fun project to work on. It was overly architected, and kinda hard to make changes, but a good experience none the less.")])])}),[],!1,null,null,null);t.default=n.exports}}]); |