-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
made a simplified verson of the endCredits
- Loading branch information
1 parent
a3c3e26
commit a2852f2
Showing
3 changed files
with
67 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
comments: False | ||
layout: post | ||
title: Ending Credits (Simpilified) | ||
description: For the end of the game | ||
type: tangibles | ||
courses: {'compsci': {'week': 6}} | ||
categories: ['C4.1'] | ||
--- | ||
|
||
<style> | ||
.container { | ||
display: block; | ||
background-color: black; | ||
|
||
} | ||
</style> | ||
<canvas id="credits" class="container" width="500px" height="400px"></canvas> | ||
<button id="startButton">Start</button> | ||
<audio id="audio" src="/Group/audio/2023-10-27-endingCredits.mp3" preload="auto"></audio> | ||
|
||
<script> | ||
const canvas = document.getElementById("credits"); | ||
const ctx = canvas.getContext("2d"); | ||
ctx.save(); //for resetting the context later | ||
var scrollY = 0; | ||
|
||
// Credits Text | ||
function text(text, yOffset, modifiers) { | ||
ctx.restore(); | ||
if (modifiers == null){ //default | ||
ctx.font = "14px Arial"; | ||
ctx.textAlign = "center" | ||
ctx.fillStyle = "white"; | ||
} | ||
else{ //if the object exists | ||
for(const [key,value] of Object.entries(modifiers)){ //loop through entries | ||
ctx[key]=value; //set the contexts change (ex:{fillStyle:"red"} will set ctx.fillStyle to red) | ||
} | ||
} | ||
ctx.fillText(text,canvas.width/2,scrollY-yOffset); //draw text at middle, and draw y with scroll and offset | ||
}; | ||
function addText() { //Text,Offset | ||
text("Created By", 0); | ||
text("Sean Nakagawa", 50); | ||
var gradient = ctx.createLinearGradient(0,0,canvas.width,canvas.height); //create a gradient starting top left, ending bottom right | ||
gradient.addColorStop(0.25,"blue"); //add colors | ||
gradient.addColorStop(.5,"white"); | ||
gradient.addColorStop(.75,"blue"); | ||
text("Trystan Schmits", 100, {font:"700 24px cursive",fillStyle:gradient}); | ||
text("Zafeer Ahmed", 150); | ||
text("Spencer Lyons", 200); | ||
}; | ||
var fps = 24; | ||
function update() { | ||
ctx.clearRect(0,0,canvas.width,canvas.height); | ||
addText(); | ||
scrollY += 1; | ||
setTimeout(requestAnimationFrame(update),1000/(fps)); | ||
}; | ||
startButton.addEventListener("click", function() { | ||
startButton.style.display = "none"; | ||
audio.play(); | ||
update(); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters