{"id":8,"date":"2019-11-04T03:00:42","date_gmt":"2019-11-04T03:00:42","guid":{"rendered":"http:\/\/hlyarab.people.ysu.edu\/?page_id=8"},"modified":"2019-11-04T03:00:42","modified_gmt":"2019-11-04T03:00:42","slug":"8-2","status":"publish","type":"page","link":"https:\/\/hlyarab.people.ysu.edu\/index.php\/8-2\/","title":{"rendered":"<em>Untitled<\/em>"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<!DOCTYPE html>\n<html>\n<head>\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"\/>\n<style>\ncanvas {\n    border:1px solid #d3d3d3;\n    background-color: #f1f1f1;\n}\n<\/style>\n<\/head>\n<body onload=\"startGame()\">\n<script>\n\nvar myGamePiece;\nvar myObstacles = [];\nvar myScore;\n\nfunction startGame() {\n    myGamePiece = new component(30, 30, \"red\", 10, 120);\n    myGamePiece.gravity = 0.05;\n    myScore = new component(\"30px\", \"Consolas\", \"black\", 280, 40, \"text\");\n    myGameArea.start();\n}\n\nvar myGameArea = {\n    canvas : document.createElement(\"canvas\"),\n    start : function() {\n        this.canvas.width = 480;\n        this.canvas.height = 270;\n        this.context = this.canvas.getContext(\"2d\");\n        document.body.insertBefore(this.canvas, document.body.childNodes[0]);\n        this.frameNo = 0;\n        this.interval = setInterval(updateGameArea, 20);\n        },\n    clear : function() {\n        this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);\n    }\n}\n\nfunction component(width, height, color, x, y, type) {\n    this.type = type;\n    this.score = 0;\n    this.width = width;\n    this.height = height;\n    this.speedX = 0;\n    this.speedY = 0;    \n    this.x = x;\n    this.y = y;\n    this.gravity = 0;\n    this.gravitySpeed = 0;\n    this.update = function() {\n        ctx = myGameArea.context;\n        if (this.type == \"text\") {\n            ctx.font = this.width + \" \" + this.height;\n            ctx.fillStyle = color;\n            ctx.fillText(this.text, this.x, this.y);\n        } else {\n            ctx.fillStyle = color;\n            ctx.fillRect(this.x, this.y, this.width, this.height);\n        }\n    }\n    this.newPos = function() {\n        this.gravitySpeed += this.gravity;\n        this.x += this.speedX;\n        this.y += this.speedY + this.gravitySpeed;\n        this.hitBottom();\n    }\n    this.hitBottom = function() {\n        var rockbottom = myGameArea.canvas.height - this.height;\n        if (this.y > rockbottom) {\n            this.y = rockbottom;\n            this.gravitySpeed = 0;\n        }\n    }\n    this.crashWith = function(otherobj) {\n        var myleft = this.x;\n        var myright = this.x + (this.width);\n        var mytop = this.y;\n        var mybottom = this.y + (this.height);\n        var otherleft = otherobj.x;\n        var otherright = otherobj.x + (otherobj.width);\n        var othertop = otherobj.y;\n        var otherbottom = otherobj.y + (otherobj.height);\n        var crash = true;\n        if ((mybottom < othertop) || (mytop > otherbottom) || (myright < otherleft) || (myleft > otherright)) {\n            crash = false;\n        }\n        return crash;\n    }\n}\n\nfunction updateGameArea() {\n    var x, height, gap, minHeight, maxHeight, minGap, maxGap;\n    for (i = 0; i < myObstacles.length; i += 1) {\n        if (myGamePiece.crashWith(myObstacles[i])) {\n            return;\n        } \n    }\n    myGameArea.clear();\n    myGameArea.frameNo += 1;\n    if (myGameArea.frameNo == 1 || everyinterval(150)) {\n        x = myGameArea.canvas.width;\n        minHeight = 20;\n        maxHeight = 200;\n        height = Math.floor(Math.random()*(maxHeight-minHeight+1)+minHeight);\n        minGap = 50;\n        maxGap = 200;\n        gap = Math.floor(Math.random()*(maxGap-minGap+1)+minGap);\n        myObstacles.push(new component(10, height, \"green\", x, 0));\n        myObstacles.push(new component(10, x - height - gap, \"green\", x, height + gap));\n    }\n    for (i = 0; i < myObstacles.length; i += 1) {\n        myObstacles[i].x += -1;\n        myObstacles[i].update();\n    }\n    myScore.text=\"SCORE: \" + myGameArea.frameNo;\n    myScore.update();\n    myGamePiece.newPos();\n    myGamePiece.update();\n}\n\nfunction everyinterval(n) {\n    if ((myGameArea.frameNo \/ n) % 1 == 0) {return true;}\n    return false;\n}\n\nfunction accelerate(n) {\n    myGamePiece.gravity = n;\n}\n<\/script>\n<br>\n<button onmousedown=\"accelerate(-0.2)\" onmouseup=\"accelerate(0.05)\">ACCELERATE<\/button>\n<p>Use the ACCELERATE button to stay in the air<\/p>\n<p>How long can you stay alive?<\/p>\n<\/body>\n<\/html>\n\n","protected":false},"excerpt":{"rendered":"<p>ACCELERATE Use the ACCELERATE button to stay in the air How long can you stay alive?<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-8","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>- Ight we bouta kill this project<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/hlyarab.people.ysu.edu\/index.php\/8-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"- Ight we bouta kill this project\" \/>\n<meta property=\"og:description\" content=\"ACCELERATE Use the ACCELERATE button to stay in the air How long can you stay alive?\" \/>\n<meta property=\"og:url\" content=\"https:\/\/hlyarab.people.ysu.edu\/index.php\/8-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Ight we bouta kill this project\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/hlyarab.people.ysu.edu\\\/index.php\\\/8-2\\\/\",\"url\":\"https:\\\/\\\/hlyarab.people.ysu.edu\\\/index.php\\\/8-2\\\/\",\"name\":\"- Ight we bouta kill this project\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/hlyarab.people.ysu.edu\\\/#website\"},\"datePublished\":\"2019-11-04T03:00:42+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/hlyarab.people.ysu.edu\\\/index.php\\\/8-2\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/hlyarab.people.ysu.edu\\\/index.php\\\/8-2\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/hlyarab.people.ysu.edu\\\/index.php\\\/8-2\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\\\/\\\/hlyarab.people.ysu.edu\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Untitled\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\\\/\\\/hlyarab.people.ysu.edu\\\/#website\",\"url\":\"http:\\\/\\\/hlyarab.people.ysu.edu\\\/\",\"name\":\"Ight we bouta kill this project\",\"description\":\"Dont @ me\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\\\/\\\/hlyarab.people.ysu.edu\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"- Ight we bouta kill this project","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/hlyarab.people.ysu.edu\/index.php\/8-2\/","og_locale":"en_US","og_type":"article","og_title":"- Ight we bouta kill this project","og_description":"ACCELERATE Use the ACCELERATE button to stay in the air How long can you stay alive?","og_url":"https:\/\/hlyarab.people.ysu.edu\/index.php\/8-2\/","og_site_name":"Ight we bouta kill this project","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/hlyarab.people.ysu.edu\/index.php\/8-2\/","url":"https:\/\/hlyarab.people.ysu.edu\/index.php\/8-2\/","name":"- Ight we bouta kill this project","isPartOf":{"@id":"http:\/\/hlyarab.people.ysu.edu\/#website"},"datePublished":"2019-11-04T03:00:42+00:00","breadcrumb":{"@id":"https:\/\/hlyarab.people.ysu.edu\/index.php\/8-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/hlyarab.people.ysu.edu\/index.php\/8-2\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/hlyarab.people.ysu.edu\/index.php\/8-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/hlyarab.people.ysu.edu\/"},{"@type":"ListItem","position":2,"name":"Untitled"}]},{"@type":"WebSite","@id":"http:\/\/hlyarab.people.ysu.edu\/#website","url":"http:\/\/hlyarab.people.ysu.edu\/","name":"Ight we bouta kill this project","description":"Dont @ me","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/hlyarab.people.ysu.edu\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/hlyarab.people.ysu.edu\/index.php\/wp-json\/wp\/v2\/pages\/8","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hlyarab.people.ysu.edu\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/hlyarab.people.ysu.edu\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/hlyarab.people.ysu.edu\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hlyarab.people.ysu.edu\/index.php\/wp-json\/wp\/v2\/comments?post=8"}],"version-history":[{"count":2,"href":"https:\/\/hlyarab.people.ysu.edu\/index.php\/wp-json\/wp\/v2\/pages\/8\/revisions"}],"predecessor-version":[{"id":14,"href":"https:\/\/hlyarab.people.ysu.edu\/index.php\/wp-json\/wp\/v2\/pages\/8\/revisions\/14"}],"wp:attachment":[{"href":"https:\/\/hlyarab.people.ysu.edu\/index.php\/wp-json\/wp\/v2\/media?parent=8"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}