Skip to content

Commit

Permalink
Initializing the v1.1.4
Browse files Browse the repository at this point in the history
Fix :
- Fix Assets Hierarchy & update names
  • Loading branch information
EthanCarollo committed May 3, 2023
1 parent e5799b6 commit 3a38f6c
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 2 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<script src = "src/assetsLoading.js"></script>
<script src = "src/langManager.js"></script>

<script src = "src/uiToolManager.js"></script>
<script src = "src/uiUtils.js"></script>

<script src = "src/sceneManager/transitionEngineManager.js"></script>
<script src = "src/tutorialManager.js"></script>
Expand Down
46 changes: 45 additions & 1 deletion json/engineOne/sprites.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,51 @@
{
"id" : "0",
"name" : "Void",
"path" : "assets/sprites/topDownSprite/testsprite/MainCharacter.png",
"path" : "assets/sprites/topDownSprite/void/MainCharacter.png",
"nb" : "1",
"image" : "null"
},
{
"id" : "1",
"name" : "Bob",
"path" : "assets/sprites/topDownSprite/bob/BobSpriteSheet.png",
"nb" : "1",
"image" : "null"
},
{
"id" : "2",
"name" : "DarkWoaf",
"path" : "assets/sprites/topDownSprite/darkWoaf/darkWoafSpriteSheet.png",
"nb" : "1",
"image" : "null"
},{
"id" : "3",
"name" : "Salatonion",
"path" : "assets/sprites/topDownSprite/salatonion/salatonionSprite.png",
"nb" : "1",
"image" : "null"
},{
"id" : "4",
"name" : "MainAi",
"path" : "assets/sprites/topDownSprite/ai/MainAi.png",
"nb" : "1",
"image" : "null"
},{
"id" : "5",
"name" : "FightAi",
"path" : "assets/sprites/topDownSprite/ai/MainAiFight.png",
"nb" : "1",
"image" : "null"
},{
"id" : "6",
"name" : "RedWoaf",
"path" : "assets/sprites/topDownSprite/redwoafsprite/redWoaf.png",
"nb" : "1",
"image" : "null"
},{
"id" : "7",
"name" : "BabyBob",
"path" : "assets/sprites/topDownSprite/babyBob/babyBob.png",
"nb" : "1",
"image" : "null"
},
Expand Down
86 changes: 86 additions & 0 deletions src/uiUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/**
*
* @param {int} xStartButton
* @param {int} yStartButton
* @param {int} sizeXButton
* @param {int} sizeYButton
* @param {function} callbackFunction automatically set to errorCallbackFunctionButton who just send a specific error for that case
*/
const createInputButtonWithCallback = (xStartButton, yStartButton, sizeXButton, sizeYButton, callbackFunction = errorCallbackFunctionButton) => { // callback function is naturally an error !
/**
* * To make it works, i use mouseReleased lied to the canvas, with that i can easily do
* * a onMouseUp isntead of a onMouseDown and it takes much less codes!
*/

if( mouseIsHover(xStartButton, yStartButton, sizeXButton, sizeYButton) )
{
cursor('pointer') // Changing the cursor into a pointer if pointer is in the button
}

if( mouseIsHover(xStartButton, yStartButton, sizeXButton, sizeYButton) && mouseIsPressed === true )
{
canvas.mouseReleased(callbackFunction)
}
}



// ! This function is used nowhere and i don't think i will use it
const createShowTextOnHover = (xStartButton, yStartButton, sizeXButton, sizeYButton, textToShow = "Hovered", fontSize = 16) => { // callback function is naturally an error !
if( mouseIsHover(xStartButton, yStartButton, sizeXButton, sizeYButton) )
{
fill(255,255,255)

textSize(fontSize)
textAlign(CENTER,CENTER);

drawingContext.shadowBlur = 10;
drawingContext.shadowColor = 'black';

text(textToShow, mouseX, mouseY-10)

drawingContext.shadowBlur = 0;

}
}



/**
* @param {int} xStartButton
* @param {int} yStartButton
* @param {float} sizeXButton
* @param {float} sizeYButton
* @param {int} red tint of red in rgb
* @param {int} green tint of green in rgb
* @param {int} blue tint of blue in rgb
*/
const changeFillOnHover = (xStartButton, yStartButton, sizeXButton, sizeYButton, red = 255, green = 255, blue = 255) => {
if( mouseIsHover(xStartButton, yStartButton, sizeXButton, sizeYButton) )
{
/**
* * Just set the color on hover a button
*/
fill(red,green,blue)
}
}



/**
*
* @param {*} xStartButton
* @param {*} yStartButton
* @param {*} sizeXButton
* @param {*} sizeYButton
* @returns {boolean} if the player is hover or not the position and the size
*/
const mouseIsHover = (xStartButton, yStartButton, sizeXButton, sizeYButton) => mouseX > xStartButton && mouseY > yStartButton && mouseX < xStartButton + sizeXButton && mouseY < yStartButton + sizeYButton


const errorCallbackFunctionButton = () => {
/**
* * Default callback when we createInputButtonWithCallback
*/
throw new Error("This Button doesn't have a Function! (uiManagerEngineOne.js --> const createInputButtonWithCallback) Don't forget createInputButtonWithWallback takes 5 parameters")
}

0 comments on commit 3a38f6c

Please sign in to comment.