Skip to content

Commit

Permalink
made a simplified verson of the endCredits
Browse files Browse the repository at this point in the history
  • Loading branch information
Trystan-Schmits committed Oct 29, 2023
1 parent a3c3e26 commit a2852f2
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 4 deletions.
4 changes: 1 addition & 3 deletions _posts/2023-10-25-Game.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ var fps = 24;
var active = true;
var currentFrame = 0;
var sec = 0;


function Room1frame(){
currentFrame = (currentFrame+1)%fps;
if (currentFrame == 0){sec+=1}
Expand Down Expand Up @@ -213,7 +211,7 @@ function start(){
mainDisplay.draw(0);
//play audio
menuAudio.play();



// Run the game on click
Expand Down
66 changes: 66 additions & 0 deletions _posts/2023-10-27-SimpilfiedEndCredits.md
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>
1 change: 0 additions & 1 deletion _posts/2023-10-27-endCredits.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ description: For the end of the game
type: tangibles
courses: {'compsci': {'week': 6}}
categories: ['C4.1']
permalink: /tangibles/credits
---

<html>
Expand Down

0 comments on commit a2852f2

Please sign in to comment.