Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipBuresh authored Nov 5, 2023
1 parent d87b021 commit 05f3cab
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 33 deletions.
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# Leap-and-Run
<b>[Play!](https://philipburesh.github.io/Leap-and-Run/)</b><br>
Last Update: <br>
- Opravené animace hráče<br>
- Přidaný GHOST<br>
- Přidané PORTALS<br>
- Předělaná testovací mapa<br>
![gifmaker_me (1)](https://github.com/PhilipBuresh/Leap-and-Run/assets/114904886/09267e17-b068-4c68-b405-ee9257f0aeda)
Základní fyzika hry
Binary file added res/img/block_back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/img/bookshelf_back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/img/chain_back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/img/lantern.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/img/torch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/img/torch1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
105 changes: 78 additions & 27 deletions res/js/script.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const canvas = document.getElementById('cnv');
const g = canvas.getContext('2d');
const p = canvas.getContext('2d');
const c = canvas.getContext('2d');
const p = canvas.getContext('2d'); //Platform
const c = canvas.getContext('2d'); //Character
const text = document.getElementById("text");
const wasd = document.getElementById("wasd");

Expand Down Expand Up @@ -50,21 +49,21 @@ let portalCordsY2 = 0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, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 9, 9, 17, 7, 7, 17, 9, 1, 3, 3, 3, 3, 3, 1,
7, 7, 7, 7, 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,]

//1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Expand Down Expand Up @@ -113,6 +112,21 @@ portal1Image.src = "./res/img/portal1.png";
const portal2Image = new Image();
portal2Image.src = "./res/img/portal2.png";

const blockBackImage = new Image();
blockBackImage.src = "./res/img/block_back.png";

const lanternImage = new Image();
lanternImage.src = "./res/img/lantern.png";

const chainBackImage = new Image();
chainBackImage.src = "./res/img/chain_back.png";

const torchImage = new Image();
torchImage.src = "./res/img/torch.png"

const bookshelfBackImage = new Image();
bookshelfBackImage.src = "./res/img/bookshelf_back.png"

let currentFrame = 0;
let currentFramePunch = 0;

Expand Down Expand Up @@ -177,7 +191,7 @@ let cordsPortalY1 = 0;
let cordsPortalX2 = 0;
let cordsPortalY2 = 0;

let drawPlatform = () => {
const drawPlatform = () => {
xBlock = 0;
yBlock = 0;
for (let index = 0; index < platformLevel1.length; index++) {
Expand Down Expand Up @@ -221,12 +235,34 @@ let drawPlatform = () => {
yBlock += 32;
}else{
xBlock += 32;
}

}
}
}
drawPlatform()

const drawBackBlocks = () => {
xBlock = 0;
yBlock = 0;
for (let index = 0; index < platformLevel1.length; index++) {
if(platformLevel1[index] == 13){
p.drawImage(blockBackImage, xBlock, yBlock, 32, 32)
}else if(platformLevel1[index] == 14){
p.drawImage(lanternImage, xBlock, yBlock, 32, 32)
}else if(platformLevel1[index] == 15){
p.drawImage(chainBackImage, xBlock, yBlock, 32, 32)
}else if(platformLevel1[index] == 16){
p.drawImage(torchImage, xBlock, yBlock, 32, 32)
}else if(platformLevel1[index] == 17){
p.drawImage(bookshelfBackImage, xBlock, yBlock, 32, 32)
}
if((index + 1) % 32 == 0){
xBlock = 0;
yBlock += 32;
}else{
xBlock += 32;
}
}

}
//----------------------------------------Vykreslení Hráče a Ducha

let playerImage = new Image();
Expand Down Expand Up @@ -266,9 +302,9 @@ const drawGhost = () => {
ghostImage.src = "./res/img/ghost.png";
xGhost += ghostVelocity;
if(ghostVelocity == 0.25){
g.drawImage(ghostImage, ghostFrame1 * 30, 0 * 40, 30, 40, xGhost, yGhost, 30, 40);
c.drawImage(ghostImage, ghostFrame1 * 30, 0 * 40, 30, 40, xGhost, yGhost, 30, 40);
}else{
g.drawImage(ghostImage, ghostFrame2 * 30, 0 * 40, 30, 40, xGhost, yGhost, 30, 40);
c.drawImage(ghostImage, ghostFrame2 * 30, 0 * 40, 30, 40, xGhost, yGhost, 30, 40);
}
for (let i = 0; i < platformLevel1.length; i++) {
if (platformLevel1[i] == 1 || platformLevel1[i] == 2 || platformLevel1[i] == 6 || platformLevel1[i] == 7 || platformLevel1[i] == 9) {
Expand Down Expand Up @@ -302,8 +338,9 @@ const drawGhost = () => {

setInterval(() => {
//Hráč
drawPlayer();
//Ghost
drawPlayer();
//Platformy
drawPlatform();
//Lava
intervalLava++;
if(intervalLava == 70){
Expand Down Expand Up @@ -392,59 +429,73 @@ let drawPlayer = () => {
playerImage.src = "./res/img/player.png";
if(velocity == 0 && velocityJump == 0 && !isMovingRight && !isMovingLeft && turnedRight && !punched && !crouched){ //Right Stand
c.clearRect(0, 0, canvas.width, canvas.height);
drawBackBlocks();
c.drawImage(playerImage, currentFrame * sX, 0 * sY, sWidth, sHeight, x, y, frameWidth, frameHeight);
animate24();
}else if(velocity == 0 && velocityJump == 0 && !isMovingRight && !isMovingLeft && turnedLeft && !punched && !crouched){ //Left Stand
c.clearRect(0, 0, canvas.width, canvas.height);
drawBackBlocks();
c.drawImage(playerImage, currentFrame * sX, 1 * sY, sWidth, sHeight, x, y, frameWidth, frameHeight);
animate24();
}else if(velocity > 0 && turnedRight && !punched && !crouched){ //Right Fall
c.clearRect(0, 0, canvas.width, canvas.height);
drawBackBlocks();
c.drawImage(playerImage, 0 * sX, 0 * sY, sWidth, sHeight, x, y, frameWidth, frameHeight);
}else if(velocity > 0 && turnedLeft && !punched && !crouched){ //Left Fall
c.clearRect(0, 0, canvas.width, canvas.height);
drawBackBlocks();
c.drawImage(playerImage, 0 * sX, 1 * sY, sWidth, sHeight, x, y, frameWidth, frameHeight);
}else if(velocityJump > 0 && turnedRight && !punched && !crouched){ //Right Jump
c.clearRect(0, 0, canvas.width, canvas.height);
drawBackBlocks();
c.drawImage(playerImage, 0 * sX, 4 * sY, sWidth, sHeight, x, y, frameWidth, frameHeight);
}else if(velocityJump > 0 && turnedLeft && !punched && !crouched){ //Left Jump
c.clearRect(0, 0, canvas.width, canvas.height);
drawBackBlocks();
c.drawImage(playerImage, 0 * sX, 5 * sY, sWidth, sHeight, x, y, frameWidth, frameHeight);
}else if(velocity == 0 && velocityJump == 0 && isMovingRight && !punched && !crouched ){ //Right Run
c.clearRect(0, 0, canvas.width, canvas.height);
drawBackBlocks();
c.drawImage(playerImage, currentFrame * sX, 2 * sY, sWidth, sHeight, x, y, frameWidth, frameHeight);
animate8();
}else if(velocity == 0 && velocityJump == 0 && isMovingLeft && !punched && !crouched){ //Left Run
c.clearRect(0, 0, canvas.width, canvas.height);
drawBackBlocks();
c.drawImage(playerImage, currentFrame * sX, 3 * sY, sWidth, sHeight, x, y, frameWidth, frameHeight);
animate8();
}else if(punched && turnedRight){ //Right Punch
c.clearRect(0, 0, canvas.width, canvas.height);
drawBackBlocks();
c.drawImage(playerImage, currentFramePunch * sX, 8 * sY, sWidth, sHeight, x, y, frameWidth, frameHeight);
animate6();
}else if(punched && turnedLeft){ //Left Punch
c.clearRect(0, 0, canvas.width, canvas.height);
drawBackBlocks();
c.drawImage(playerImage, currentFramePunch * sX, 9 * sY, sWidth, sHeight, x, y, frameWidth, frameHeight);
animate6();
}else if(crouched && !isMovingRight && !isMovingLeft && turnedRight){ //Crouched Right
c.clearRect(0, 0, canvas.width, canvas.height);
drawBackBlocks();
c.drawImage(playerImage, 0 * sX, 6 * sY, sWidth, sHeight, x, y - height, frameWidth, frameHeight);
}else if(crouched && !isMovingRight && !isMovingLeft && turnedLeft){ //Crouched Left
c.clearRect(0, 0, canvas.width, canvas.height);
drawBackBlocks();
c.drawImage(playerImage, 0 * sX, 7 * sY, sWidth, sHeight, x, y - height, frameWidth, frameHeight);
}else if(crouched && isMovingRight && !isMovingLeft){ //Crouched Right Moving
c.clearRect(0, 0, canvas.width, canvas.height);
drawBackBlocks();
c.drawImage(playerImage, currentFrame * sX, 6 * sY, sWidth, sHeight, x, y - height, frameWidth, frameHeight);
animate4();
}else if(crouched && isMovingLeft && !isMovingRight){ //Crouched Left Moving
c.clearRect(0, 0, canvas.width, canvas.height);
drawBackBlocks();
c.drawImage(playerImage, currentFrame * sX, 7 * sY, sWidth, sHeight, x, y - height, frameWidth, frameHeight);
animate4();
}
drawPlatform();
drawGhost();
objectsCollision();
orbCollision();
drawPlatform();
};
//----------------------------------------SHAKE funkce

Expand Down

0 comments on commit 05f3cab

Please sign in to comment.