-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathkeyParse.js
More file actions
28 lines (26 loc) · 977 Bytes
/
Copy pathkeyParse.js
File metadata and controls
28 lines (26 loc) · 977 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
let emojiBet = {};
/**
* Use this function in the preload to load all the sprites without causing any issues
*/
function loadKeySprites() {
let charactersToLoad = "abcdefghijklmnopqrstuvwxyz1234567890";
for (let i = 0; i < charactersToLoad.length; i++) {
let char = charactersToLoad.charAt(i);
emojiBet[char] = loadImage("./keys/"+char+".png");
}
}
/**
* Converts normal text to emoji's
*
* @param {String} text The text that is to be converted
* @param {Number} startX The starting top left x coordinate
* @param {Number} startY The starting top left y coordinate
* @param {Number} font Font size of the text [default is 50]
*/
function printEmojiText(text, startX, startY, font = 50) {
for (let i = 0; i < text.length; i++){
if (text.charAt(i) != " " && text.charAt(i) != "_"){
image(emojiBet[text.charAt(i).toLowerCase()], startX + (i * font), startY, font, font);
}
}
}