1"use strict";(globalThis.webpackChunksite=globalThis.webpackChunksite||[]).push([[1471],{11877(s,l,e){e.r(l),e.d(l,{assets:()=>a,contentTitle:()=>o,default:()=>h,frontMatter:()=>i,metadata:()=>n,toc:()=>t});const n=JSON.parse('{"id":"tutorials/Excalibird/step-flying-bird","title":"Step 4 - Flying the Bird","description":"We can take user input in Excalibur from keyboard, pointers (mouse, touch), and gamepads!","source":"@site/docs/00-tutorials/Excalibird/04-step-flying-bird.mdx","sourceDirName":"00-tutorials/Excalibird","slug":"/step-4-flying-bird","permalink":"/docs/step-4-flying-bird","draft":false,"unlisted":false,"editUrl":"https://github.com/excaliburjs/Excalibur/tree/main/site/docs/00-tutorials/Excalibird/04-step-flying-bird.mdx","tags":[],"version":"current","sidebarPosition":4,"frontMatter":{"title":"Step 4 - Flying the Bird","slug":"/step-4-flying-bird","section":"Tutorial"},"sidebar":"learnSidebar","previous":{"title":"Step 3 - The Bird and the Grounds","permalink":"/docs/step-3-bird-and-ground"},"next":{"title":"Step 5 - Plumbing the Pipes","permalink":"/docs/step-5-plumbing-pipes"}}');var r=e(74848),c=e(28453);const i={title:"Step 4 - Flying the Bird",slug:"/step-4-flying-bird",section:"Tutorial"},o="Step 4 - Flying the Bird",a={},t=[];function d(s){const l={admonition:"admonition",br:"br",code:"code",div:"div",em:"em",h1:"h1",header:"header",p:"p",pre:"pre",span:"span",strong:"strong",...(0,c.R)(),...s.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l.header,{children:(0,r.jsx)(l.h1,{id:"step-4---flying-the-bird",children:"Step 4 - Flying the Bird"})}),"\n",(0,r.jsx)(l.p,{children:"We can take user input in Excalibur from keyboard, pointers (mouse, touch), and gamepads!"}),"\n",(0,r.jsxs)(l.p,{children:["Let's setup an input handler to have the ",(0,r.jsx)(l.code,{children:"Bird"})," jump when ever we hit the keyboard space bar or tap the screen."]}),"\n",(0,r.jsxs)(l.p,{children:["For added flair, we can adjust the ",(0,r.jsx)(l.code,{children:"Bird"}),"'s rotation by the speed that the level will be moving past ",(0,r.jsx)(l.code,{children:"200"})," pixels per second."]}),"\n",(0,r.jsxs)(l.div,{className:"shiki-twoslash-fragment",children:[(0,r.jsxs)(l.pre,{className:"shiki github-light",style:{backgroundColor:"#ffffff",color:"#24292f"},children:[(0,r.jsx)(l.div,{className:"language-id",children:"typescript"}),(0,r.jsx)(l.div,{className:"code-container",children:(0,r.jsxs)(l.code,{children:[(0,r.jsx)(l.div,{className:"line",children:(0,r.jsx)(l.span,{style:{color:"#6E7781"},children:"// bird.ts"})}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:"import"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#0550AE"},children:"*"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:"as"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" ex "}),(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:"from"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#0A3069"},children:"'excalibur'"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:";"})]}),(0,r.jsx)(l.div,{className:"line"}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:"export"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:"class"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#953800"},children:"Bird"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:"extends"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#953800"},children:"ex"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:"."}),(0,r.jsx)(l.span,{style:{color:"#0550AE"},children:"Actor"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" {"})]}),(0,r.jsx)(l.div,{className:"line"}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:"..."})]}),(0,r.jsx)(l.div,{className:"line"}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}
1),(0,r.jsx)(l.span,{style:{color:"#953800"},children:"jumping"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:"="}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#0550AE"},children:"false"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:";"})]}),(0,r.jsx)(l.div,{className:"line"}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:"private"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#8250DF"},children:"isInputActive"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:"("}),(0,r.jsx)(l.span,{style:{color:"#953800"},children:"engine"}),(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:":"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#953800"},children:"ex"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:"."}),(0,r.jsx)(l.span,{style:{color:"#953800"},children:"Engine"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:") {"})]}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#6E7781"},children:"// if the space bar or the first pointer was down"})]}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:"return"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" (engine.input.keyboard."}),(0,r.jsx)(l.span,{style:{color:"#8250DF"},children:"isHeld"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:"(ex.Keys.Space) "}),(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:"||"})]}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" engine.input.pointers."}),(0,r.jsx)(l.span,{style:{color:"#8250DF"},children:"isDown"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:"("}),(0,r.jsx)(l.span,{style:{color:"#0550AE"},children:"0"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:"))"})]}),(0,r.jsx)(l.div,{className:"line",children:(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" }"})}),(0,r.jsx)(l.div,{className:"line"}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:"override"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#8250DF"},children:"onPostUpdate"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:"("}),(0,r.jsx)(l.span,{style:{color:"#953800"},children:"engine"}),(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:":"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#953800"},children:"ex"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:"."}),(0,r.jsx)(l.span,{style:{color:"#953800"},children:"Engine"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:")"}),(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:":"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#0550AE"},children:"void"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" {"})]}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:"if"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" ("}),(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:"!"}),(0,r.jsx)(l.span,{style:{color:"#0550AE"},children:"this"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:".jumping "}),(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:"&&"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#0550AE"},children:"this"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:"."}),(0,r.jsx)(l.span,{style:{color:"#8250DF"},children:"isInputActive"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:"(engine)) {"})]}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#0550AE"},children:"this"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:".vel.y "}),(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:"+="}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:"-"}),(0,r.jsx)(l.span,{style:{color:"#0550AE"},children:"800"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:"; "}),(0,r.jsx)(l.span,{style:{color:"#6E7781"},children:"// negative is UP"})]}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#0550AE"},children:"this"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:".jumping "}),(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:"="}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#0550AE"},children:"true"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:";"})]}),(0,r.jsx)(l.div,{className:"line",children:(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" }"})}),(0,r.jsx)(l.div,{className:"line"}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:"if"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" ("}),(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:"!"}),(0,r.jsx)(l.span,{style:{color:"#0550AE"},children:"this"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:"."}),(0,r.jsx)(l.span,{style:{color:"#8250DF"},children:"isInputActive"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:"(engine)) {"})]}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#0550AE"},children:"this"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:".jumping "}),(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:"="}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#0550AE"},children:"false"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:";"})]}),(0,r.jsx)(l.div,{className:"line",children:(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" }"})}),(0,r.jsx)(l.div,{className:"line"}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#6E7781"},children:"// keep velocity from getting too big"})]}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#0550AE"},children:"this"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:".vel.y "}),(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:"="}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" ex."}),(0,r.jsx)(l.span,{style:{color:"#8250DF"},children:"clamp"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:"("}),(0,r.jsx)(l.span,{style:{color:"#0550AE"},children:"this"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:".vel.y, "}),(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:"-"}),(0,r.jsx)(l.span,{style:{color:"#0550AE"},children:"500"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:", "}),(0,r.jsx)(l.span,{style:{color:"#0550AE"},children:"500"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:");"})]}),(0,r.jsx)(l.div,{className:"line"}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#6E7781"},children:'// The "speed" the bird will move relative to pipes'})]}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#0550AE"},children:"this"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:".rotation "}),(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:"="}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" ex."}),(0,r.jsx)(l.span,{style:{color:"#8250DF"},children:"vec"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:"("}),(0,r.jsx)(l.span,{style:{color:"#0550AE"},children:"200"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:", "}),(0,r.jsx)(l.span,{style:{color:"#0550AE"},children:"this"}),(0,r.jsx)(l.span,{style:{color:"#24292F"},children:".vel.y)."}),(0,r.jsx)(l.span,{style:{color:"#8250DF"},children:"toAngle"}),(0,r.jsx)(l.span,{style:{color:"#24292F"}
1,children:"();"})]}),(0,r.jsx)(l.div,{className:"line",children:(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" }"})}),(0,r.jsx)(l.div,{className:"line"}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#24292F"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#CF222E"},children:"..."})]}),(0,r.jsx)(l.div,{className:"line"}),(0,r.jsx)(l.div,{className:"line",children:(0,r.jsx)(l.span,{style:{color:"#24292F"},children:"}"})})]})})]}),"\n",(0,r.jsxs)(l.pre,{className:"shiki github-dark",style:{backgroundColor:"#0d1117",color:"#c9d1d9"},children:[(0,r.jsx)(l.div,{className:"language-id",children:"typescript"}),(0,r.jsx)(l.div,{className:"code-container",children:(0,r.jsxs)(l.code,{children:[(0,r.jsx)(l.div,{className:"line",children:(0,r.jsx)(l.span,{style:{color:"#8B949E"},children:"// bird.ts"})}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:"import"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#79C0FF"},children:"*"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:"as"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" ex "}),(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:"from"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#A5D6FF"},children:"'excalibur'"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:";"})]}),(0,r.jsx)(l.div,{className:"line"}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:"export"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:"class"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#FFA657"},children:"Bird"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:"extends"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#FFA657"},children:"ex"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:"."}),(0,r.jsx)(l.span,{style:{color:"#79C0FF"},children:"Actor"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" {"})]}),(0,r.jsx)(l.div,{className:"line"}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:"..."})]}),(0,r.jsx)(l.div,{className:"line"}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#FFA657"},children:"jumping"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:"="}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#79C0FF"},children:"false"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:";"})]}),(0,r.jsx)(l.div,{className:"line"}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:"private"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#D2A8FF"},children:"isInputActive"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:"("}),(0,r.jsx)(l.span,{style:{color:"#FFA657"},children:"engine"}),(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:":"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#FFA657"},children:"ex"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:"."}),(0,r.jsx)(l.span,{style:{color:"#FFA657"},children:"Engine"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:") {"})]}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#8B949E"},children:"// if the space bar or the first pointer was down"})]}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:"return"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"}
1,children:" (engine.input.keyboard."}),(0,r.jsx)(l.span,{style:{color:"#D2A8FF"},children:"isHeld"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:"(ex.Keys.Space) "}),(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:"||"})]}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" engine.input.pointers."}),(0,r.jsx)(l.span,{style:{color:"#D2A8FF"},children:"isDown"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:"("}),(0,r.jsx)(l.span,{style:{color:"#79C0FF"},children:"0"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:"))"})]}),(0,r.jsx)(l.div,{className:"line",children:(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" }"})}),(0,r.jsx)(l.div,{className:"line"}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:"override"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#D2A8FF"},children:"onPostUpdate"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:"("}),(0,r.jsx)(l.span,{style:{color:"#FFA657"},children:"engine"}),(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:":"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#FFA657"},children:"ex"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:"."}),(0,r.jsx)(l.span,{style:{color:"#FFA657"},children:"Engine"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:")"}),(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:":"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#79C0FF"},children:"void"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" {"})]}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:"if"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" ("}),(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:"!"}),(0,r.jsx)(l.span,{style:{color:"#79C0FF"},children:"this"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:".jumping "}),(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:"&&"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#79C0FF"},children:"this"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:"."}),(0,r.jsx)(l.span,{style:{color:"#D2A8FF"},children:"isInputActive"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:"(engine)) {"})]}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#79C0FF"},children:"this"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:".vel.y "}),(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:"+="}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:"-"}),(0,r.jsx)(l.span,{style:{color:"#79C0FF"},children:"800"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:"; "}),(0,r.jsx)(l.span,{style:{color:"#8B949E"},children:"// negative is UP"})]}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#79C0FF"},children:"this"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:".jumping "}),(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:"="}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#79C0FF"},children:"true"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:";"})]}),(0,r.jsx)(l.div,{className:"line",children:(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" }"})}),(0,r.jsx)(l.div,{className:"line"}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:"if"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" ("}),(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:"!"}),(0,r.jsx)(l.span,{style:{color:"#79C0FF"},children:"this"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:"."}),(0,r.jsx)(l.span,{style:{color:"#D2A8FF"},children:"isInputActive"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:"(engine)) {"})]}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#79C0FF"},children:"this"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:".jumping "}),(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:"="}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#79C0FF"},children:"false"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:";"})]}),(0,r.jsx)(l.div,{className:"line",children:(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" }"})}),(0,r.jsx)(l.div,{className:"line"}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#8B949E"},children:"// keep velocity from getting too big"})]}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#79C0FF"},children:"this"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:".vel.y "}),(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:"="}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" ex."}),(0,r.jsx)(l.span,{style:{color:"#D2A8FF"},children:"clamp"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:"("}),(0,r.jsx)(l.span,{style:{color:"#79C0FF"},children:"this"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:".vel.y, "}),(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:"-"}),(0,r.jsx)(l.span,{style:{color:"#79C0FF"},children:"500"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:", "}),(0,r.jsx)(l.span,{style:{color:"#79C0FF"},children:"500"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:");"})]}),(0,r.jsx)(l.div,{className:"line"}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#8B949E"},children:'// The "speed" the bird will move relative to pipes'})]}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#79C0FF"},children:"this"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:".rotation "}),(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:"="}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" ex."}),(0,r.jsx)(l.span,{style:{color:"#D2A8FF"},children:"vec"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:"("}),(0,r.jsx)(l.span,{style:{color:"#79C0FF"},children:"200"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:", "}),(0,r.jsx)(l.span,{style:{color:"#79C0FF"},children:"this"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:".vel.y)."}),(0,r.jsx)(l.span,{style:{color:"#D2A8FF"},children:"toAngle"}),(0,r.jsx)(l.span,{style:{color:"#C9D1D9"}
1,children:"();"})]}),(0,r.jsx)(l.div,{className:"line",children:(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" }"})}),(0,r.jsx)(l.div,{className:"line"}),(0,r.jsxs)(l.div,{className:"line",children:[(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:" "}),(0,r.jsx)(l.span,{style:{color:"#FF7B72"},children:"..."})]}),(0,r.jsx)(l.div,{className:"line"}),(0,r.jsx)(l.div,{className:"line",children:(0,r.jsx)(l.span,{style:{color:"#C9D1D9"},children:"}"})})]})})]})]}),"\n",(0,r.jsxs)(l.admonition,{type:"info",children:[(0,r.jsxs)(l.p,{children:[(0,r.jsx)(l.strong,{children:"Heads up!"}),(0,r.jsx)(l.br,{}),"\nAfter adding the flap/jump logic, you may notice a strange behavior:",(0,r.jsx)(l.br,{}),'\nif the Bird hits the ground and "dies," pressing the jump key ',(0,r.jsx)(l.strong,{children:"one more time"})," will cause the Bird to shoot upward infinitely."]}),(0,r.jsxs)(l.p,{children:["This happens because we haven't added any ",(0,r.jsx)(l.em,{children:"game-over"})," or ",(0,r.jsx)(l.em,{children:"collision-lockout"})," logic yet\u2014so the Bird is still allowed to receive input even after crashing."]}),(0,r.jsxs)(l.p,{children:["Don't worry! This is expected at this stage of the tutorial.",(0,r.jsx)(l.br,{}),"\nWe'll fix this behavior later once we introduce proper game-over handling."]})]})]})}function h(s={}){const{wrapper:l}={...(0,c.R)(),...s.components};return l?(0,r.jsx)(l,{...s,children:(0,r.jsx)(d,{...s})}):d(s)}},28453(s,l,e){e.d(l,{R:()=>i,x:()=>o});var n=e(96540);const r={},c=n.createContext(r);function i(s){const l=n.useContext(c);return n.useMemo(function(){return"function"==typeof s?s(l):{...l,...s}},[l,s])}function o(s){let l;return l=s.disableParentContext?"function"==typeof s.components?s.components(r):s.components||r:i(s.components),n.createElement(c.Provider,{value:l},s.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.