Skip to content

Commit

Permalink
Some refactoring, almost done.
Browse files Browse the repository at this point in the history
  • Loading branch information
conorpo committed Dec 24, 2023
1 parent 9bcea30 commit a51a4de
Show file tree
Hide file tree
Showing 61 changed files with 199 additions and 178 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
out
./assets
.assets/
docs/
3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

10 changes: 8 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"problemMatcher": [],
"tasks": [
{
"label": "Compress Images",
"type": "shell",
"command": ".assets/compress_images.sh",

},
{
"label": "JSDOC",
"type": "shell",
"command": "jsdoc ./js/*",
"problemMatcher": []
"command": "jsdoc ./js/* -d ./docs",
}
]
}
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
# conorpo.github.io
Conor's collection of games and various other things.
Conor's collection of games and various other things.

Site: https://conorpo.github.io/

Docs: https://conorpo.github.io/docs/

```
TODO
Make Card Hand System More Dynamic (swap around cards, place cards in spots that make sense)
If mouse movement isnt fixed in Firefox, switch to manual smoothing.
Edit about page after contact card is taken
```
Binary file added assets/background.webp
Binary file not shown.
Binary file removed assets/card_backing_temp.jpg
Binary file not shown.
Binary file removed assets/card_slot.png
Binary file not shown.
Binary file removed assets/cards/about.jpg
Binary file not shown.
Binary file removed assets/cards/about.png
Binary file not shown.
Binary file added assets/cards/about.webp
Binary file not shown.
Binary file removed assets/cards/card_backing.jpg
Binary file not shown.
Binary file removed assets/cards/card_backing.png
Binary file not shown.
Binary file added assets/cards/card_backing.webp
Binary file not shown.
Binary file removed assets/cards/climbing.jpg
Binary file not shown.
Binary file removed assets/cards/climbing.png
Binary file not shown.
Binary file added assets/cards/climbing.webp
Binary file not shown.
Binary file removed assets/cards/contact.jpg
Binary file not shown.
Binary file removed assets/cards/contact.png
Binary file not shown.
Binary file added assets/cards/contact.webp
Binary file not shown.
Binary file removed assets/cards/mandelbulb.jpg
Binary file not shown.
Binary file removed assets/cards/mandelbulb.png
Binary file not shown.
Binary file added assets/cards/mandelbulb.webp
Binary file not shown.
Binary file removed assets/cards/projects.jpg
Binary file not shown.
Binary file removed assets/cards/projects.png
Binary file not shown.
Binary file added assets/cards/projects.webp
Binary file not shown.
Binary file removed assets/cards/resume.jpg
Binary file not shown.
Binary file removed assets/cards/resume.png
Binary file not shown.
Binary file added assets/cards/resume.webp
Binary file not shown.
Binary file removed assets/cards/thisSite.jpg
Binary file not shown.
Binary file removed assets/cards/thisSite.png
Binary file not shown.
Binary file added assets/cards/thisSite.webp
Binary file not shown.
Binary file removed assets/combinepdf.pdf
Binary file not shown.
2 changes: 0 additions & 2 deletions assets/desktop.ini

This file was deleted.

Binary file removed assets/paper_texture.jpg
Binary file not shown.
Binary file removed assets/pictures/about_me_1.jpg
Binary file not shown.
Binary file removed assets/pictures/about_me_1.png
Binary file not shown.
Binary file added assets/pictures/about_me_1.webp
Binary file not shown.
Binary file removed assets/pictures/about_me_2.jpg
Binary file not shown.
Binary file removed assets/pictures/about_me_2.png
Binary file not shown.
Binary file added assets/pictures/about_me_2.webp
Binary file not shown.
Binary file removed assets/pictures/about_me_3.PNG
Binary file not shown.
Binary file removed assets/pictures/instructions.png
Binary file not shown.
Binary file removed assets/proposal.pdf
Binary file not shown.
Binary file removed assets/title.png
Diff not rendered.
Binary file added assets/ui/card_slot.webp
Binary file not shown.
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added assets/ui/title.webp
Binary file not shown.
Binary file removed assets/wood-background.jpg
Diff not rendered.
28 changes: 9 additions & 19 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@
<body>
<div class="global-container start" id="globalContainer">

<img src="./assets/title.png" class="title" alt="conorpo.github.io">
<img src="./assets/ui/title.webp" class="title" alt="conorpo.github.io">
<div class="title title-text"><span>conorpo</span>.<span>github</span>.<span>io</span></div>

<img src="./assets/corner.svg" class="corner bottom-right" alt="">
<img src="./assets/corner.svg" class="corner bottom-left"alt="">
<img src="./assets/corner2.svg" class="corner top-left"alt="">
<img src="./assets/corner.svg" class="corner top-right"alt="">
<img src="./assets/ui/corner.svg" class="corner bottom-right" alt="">
<img src="./assets/ui/corner.svg" class="corner bottom-left"alt="">
<img src="./assets/ui/corner2.svg" class="corner top-left"alt="">
<img src="./assets/ui/corner.svg" class="corner top-right"alt="">
<span class="footer">Made from scratch in HTML / CSS / Javascript</span>
<div class="playing-area" id="playingArea">
<img src="./assets/card_slot.png" class="card-slot" id="cardSlot" alt="">
<img src="./assets/ui/card_slot.webp" class="card-slot" id="cardSlot" alt="">
</div>
<img src="./assets/line.svg" alt="" class="divider">
<img src="./assets/ui/line.svg" alt="" class="divider">
<div class="info-area" id="infoArea">
<div id="aboutInfo" class="info about hidden" data-cardsheld="contact climbing">
<img src="./assets/pictures/about_me_1.png" alt="" class="aboutImage1">
<img src="./assets/pictures/about_me_2.png" alt="" class="aboutImage2">
<img src="./assets/pictures/about_me_1.webp" alt="" class="aboutImage1">
<img src="./assets/pictures/about_me_2.webp" alt="" class="aboutImage2">
<div class="aboutText">
<h1>About Me</h1>
<div>
Expand Down Expand Up @@ -75,16 +75,6 @@ <h1 class="personal">Personal</h1>
<iframe id="marchingcubes-iframe"></iframe>
</div>
</div>

<div id="marchingcubesCard" data-cardname="marchingcubes" data-cardindex=9 class="card-container down hidden" style="transform: translate(50vw,40vh) rotate(10deg);"></div>
<div id="knightHacksCard" data-cardname="knightHacks" data-cardindex=8 class="card-container down hidden" style="transform: translate(50vw,40vh) rotate(10deg);"></div>
<div id="contactCard" data-cardname="contact" data-cardindex=7 class="card-container down hidden" style="transform: translate(77.3vw,58vh) rotate(90deg);"></div>
<div id="climbingCard" data-cardname="climbing" data-cardindex=6 class="card-container down hidden" style="transform: translate(38vw,44vh) rotate(-10deg);"></div>
<div id="thisSiteCard" data-cardname="thisSite" data-cardindex=5 class="card-container down hidden" style="transform: translate(40vw,30vh) rotate(-10deg);"></div>
<div id="mandelbulbCard" data-cardname="mandelbulb" data-cardindex=4 class="card-container down hidden" style="transform: translate(42vw,40vh) rotate(30deg);"></div>
<div id="resumeCard" data-cardname="resume" data-cardindex=3 class="card-container down" style="transform: translate(52vw,46vh) rotate(-20deg);"></div>
<div id="projectsCard" data-cardname="projects" data-cardindex=2 class="card-container down" style="transform: translate(40vw,41vh) rotate(30deg);"></div>
<div id="aboutCard" data-cardname="about" data-cardindex=1 class="card-container down" style="transform: translate(47vw,35vh) rotate(-5deg);"></div>
</div>
<div id="soundContainer"></div>
</body>
Expand Down
155 changes: 98 additions & 57 deletions js/Card.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,42 @@ import {elements} from './elements.js';
* */


/** @typedef {Object} Card
* @property {number} index The index of the card in the hand
/**
* @typedef {Object} Card
* @property {string} name The name of the card
* @property {number} status The status of the card (0 is in hand, 1 is dragging, 2 is in active slot)
*
* @property {HTMLElement} element The actual HTML element of the card
* @property {HTMLElement} infoElement The corresponding html info element that is revealed when card is active
* @property {boolean} hasIframe Whether the info element has an iframe
* @property {HTMLIFrameElement} iframeElement The iframe element
* @property {number} iframeTimeout The timeout for the iframe
* @property {function} iframeSrcFunc The function to get the iframe src
*
* @property {function} activate Activates the card
* @property {function} setStatus Sets the status of the card
*
* @property {function} pickUp Picks up the card
* @property {function} backToHand Returns the card to the hand
*
* @property {function} showInfo Shows the info element
* @property {function} hideInfo Hides the info element
* @property {function} sameAs Checks if the card is the same as another card
* The card object
*
* @property {function} updateTransform Updates the transform of the card
* @description The card object
* */


/** @type {Card} */
const card_proto = {
// Assigned in create_card
name: null,
status: null,

element: null,
infoElement: null,
iframeElement: null,
iframeTimeout: null,
iframeSrcFunc: null,

activate() {
this.status = 2;

Expand All @@ -45,13 +59,6 @@ const card_proto = {

window.location.hash = `#${this.name}`;
},
/**
* Status setter so that optional chaning can be used
* @param {number} code The code to set, (0 is in hand, 1 is dragging, 2 is in active slot)
*/
setStatus(code){
this.status = code;
},
pickUp(){
sounds.get("pickup").play();

Expand All @@ -71,85 +78,119 @@ const card_proto = {
},
backToHand(){
this.status = 0;
state.mouse_over_card = null;
this.element.classList.remove("active");
this.element.classList.remove("drag");
},
showInfo(){
if(this.hasIframe){
clearTimeout(this.iframeTimeout);
this.infoElement.lastElementChild.src = this.iframeSrcFunc();
this.infoElement.classList.remove("hidden");

if(this.iframeElement){
if(this.iframeTimeout) clearTimeout(this.iframeTimeout);
this.iframeElement.src = this.iframeSrcFunc();
}

this.infoElement.classList.remove("hidden");
this.infoElement.getAttribute("data-cardsheld")?.split(" ").forEach(str => {
console.log(str);
document.getElementById(str+"Card")?.classList.remove("hidden");
info_card_map.get(this)?.forEach(card => {
card.element.classList.remove("hidden");
});
},
hideInfo(){
if(this.hasIframe){
this.infoElement.classList.add("hidden");

if(this.iframeElement){
this.iframeTimeout = setTimeout(() => {
this.infoElement.lastElementChild.src = "";
this.iframeElement.src = "";
}, 500);
}

this.infoElement.classList.add("hidden");
this.infoElement.getAttribute("data-cardsheld")?.split(" ").forEach(str => {
document.getElementById(str+"Card")?.classList.add("hidden");
info_card_map.get(this)?.forEach(card => {
card.element.classList.add("hidden");
});
},
sameAs(other){
if(other == null || other == undefined) return false;
return this.index == other.getAttribute("data-cardindex");
updateTransform(string){
this.element.style.transform = string;
}
}


// <div id="marchingcubesCard" data-cardname="marchingcubes" data-cardindex=9 class="card-container down hidden" style="transform: translate(50vw,40vh) rotate(10deg);"></div>
// <div id="knightHacksCard" data-cardname="knightHacks" data-cardindex=8 class="card-container down hidden" style="transform: translate(50vw,40vh) rotate(10deg);"></div>
// <div id="contactCard" data-cardname="contact" data-cardindex=7 class="card-container down hidden" style="transform: translate(77.3vw,58vh) rotate(90deg);"></div>
// <div id="climbingCard" data-cardname="climbing" data-cardindex=6 class="card-container down hidden" style="transform: translate(38vw,44vh) rotate(-10deg);"></div>
// <div id="thisSiteCard" data-cardname="thisSite" data-cardindex=5 class="card-container down hidden" style="transform: translate(40vw,30vh) rotate(-10deg);"></div>
// <div id="mandelbulbCard" data-cardname="mandelbulb" data-cardindex=4 class="card-container down hidden" style="transform: translate(42vw,40vh) rotate(30deg);"></div>
// <div id="resumeCard" data-cardname="resume" data-cardindex=3 class="card-container down" style="transform: translate(52vw,46vh) rotate(-20deg);"></div>
// <div id="projectsCard" data-cardname="projects" data-cardindex=2 class="card-container down" style="transform: translate(40vw,41vh) rotate(30deg);"></div>
// <div id="aboutCard" data-cardname="about" data-cardindex=1 class="card-container down" style="transform: translate(47vw,35vh) rotate(-5deg);"></div>

/**
* @type {Object<string, Card>}
* @description A map of the card names to the card objects
*/
export const cards = {};

/**
* @type {Map<HTMLElement, Card>}
* @description A map of the card elements to the card objects
*/
export const element_card_map = new Map();

/**
* @type {Map<Card, Array<Card>>}
* @description A map of the info elements to the card objects that they contain
*/
const info_card_map = new Map();

/**
* All cards on the site are defined here (order is defined here too)
*/
export function create_cards(){
const cards = [];
cards.push()
return cards;
}
cards.about = create_card("about")
cards.projects = create_card("projects")
cards.resume = create_card("resume", () => "./assets/resume.pdf")
cards.mandelbulb = create_card("mandelbulb", () => "https://conorpo.github.io/webgl_mandelbulb/")
cards.thisSite = create_card("thisSite", () => `index.html?${!location.search ? 1 : Number(location.search.split("?").pop()) + 1}`)
cards.climbing = create_card("climbing")
cards.contact = create_card("contact")
cards.knightHacks = create_card("knightHacks")
cards.marchingcubes = create_card("marchingcubes", () => "https://conorpo.github.io/marching-cubes-webgpu")

info_card_map.set(cards.about, [cards.contact, cards.climbing, cards.resume]);
info_card_map.set(cards.projects, [cards.mandelbulb, cards.thisSite, cards.knightHacks, cards.marchingcubes]);
};

/**
* Creates a card object
* @param {string} name The name of the card
* @param {number} index The index of the card in the hand
* @param {function} iframeSrcFunc The function to get the iframe src
* @param {function} [iframeSrcFunc] The function to get the iframe src (if this is not included, it is assumed that the card does not have an iframe)
* @returns {Card} The card object
*/

export function create_card(name, index, iframeSrcFunc) {
function create_card(name, iframeSrcFunc) {
/** @type {Card} */
const card = Object.create(card_proto);
card.index = index;

card.name = name;
card.iframeSrcFunc = iframeSrcFunc;
card.status = 0; //0 is not found, 2 is in hand, 3 is dragging, 4 is in active slot

card.setStatus(0);

/** The actual HTML element of the card */
card.element = document.createElement("DIV");
card.element.hidden = true;

card.element.classList.add("card-container");
card.element.style.setProperty('--image-url', `center/100% url(assets/cards/${card.name}.jpg)`);
card.element.classList.add("hand");
card.element.classList.remove("down");
// card.element.hidden = true;
card.element.classList.add("down");
card.element.style.setProperty('--image-url', `center/100% url(assets/cards/${card.name}.webp)`);
card.element.addEventListener("mousedown", () => {card.pickUp()});
card.element.addEventListener("mouseup", () => {if(card.status == 2) {elements.get("playingArea").dispatchEvent(new Event('mouseup'))}});

/** The corresponding html info element that is revealed when card is active */
card.infoElement = document.getElementById(card.name+"Info");
card.hasIframe = card.infoElement?.lastElementChild?.tagName?.toLowerCase() == "iframe";
card.iframeTimeout = null;

/** Remove the Card from any assocaited info elements */
if(state.activeCard){
let cardsHeldString = state.activeCard?.infoElement.getAttribute("data-cardsheld");
cardsHeldString = cardsHeldString.replace(card.name,"").replace(" "," ").trim();
state.activeCard?.infoElement.setAttribute("data-cardsheld", cardsHeldString);
}
card.infoElement = document.getElementById(`${card.name}Info}`);
if(!(card.infoElement instanceof HTMLElement)) throw new ReferenceError(`Info element for card ${card.name} not found`);
const _iframeElement = document.getElementById(`${card.name}Iframe`);
card.iframeElement = (iframeSrcFunc && _iframeElement instanceof HTMLIFrameElement) ? _iframeElement : null;
if(!iframeSrcFunc != !card.iframeElement) throw new Error(`Either iframeSrcFunc or iframeElement is not defined for card ${card.name}`);

/** Add it to the dom and cards object*/
elements.get("globalContainer").appendChild(card.element);
cards[card.name] = card;
element_card_map.set(card.element, card);

return card;
}
17 changes: 7 additions & 10 deletions js/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,13 @@ export const config = {
wobbleSpeed: 3,

activeScale: 1.20,

thisSite: () => `index.html?${!location.search ? 1 : Number(location.search.split("?").pop()) + 1}`,
mandelbulb: () => `https://conorpo.github.io/webgl_mandelbulb/`,
projects: () => `https://github.com/conorpo`,
resume: () => `./assets/resume.pdf`,

/** Updates */
updateCSS() {
document.documentElement.style.setProperty('--cardWidth', this.cardWidth + "px");
document.documentElement.style.setProperty('--cardHeight', this.cardHeight + "px");
document.documentElement.style.setProperty('--activeScale', this.activeScale);
document.documentElement.style.setProperty('--cardWidth', `${this.cardWidth}px`);
document.documentElement.style.setProperty('--cardHeight', `${this.cardHeight}px`);
document.documentElement.style.setProperty('--activeScale', `${this.activeScale}`);
}
};
};

// @ts-ignore
window.config = config;
2 changes: 1 addition & 1 deletion js/elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @module elements
* @description Gets elements from the DOM
*/
*/

/** @type {Map<String,HTMLElement>} */
export const elements = new Map();
Expand Down
Loading

0 comments on commit a51a4de

Please sign in to comment.