Skip to content

Commit

Permalink
Merge pull request #99 from Tvick22/main
Browse files Browse the repository at this point in the history
Settings Rework, Sprite Animation Fix, Titan Fix
  • Loading branch information
Tvick22 authored May 28, 2024
2 parents 89dea30 + 83a9910 commit a0ed226
Show file tree
Hide file tree
Showing 7 changed files with 873 additions and 474 deletions.
2 changes: 1 addition & 1 deletion assets/js/platformer3x/GameSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ class GameSet {

}

export default GameSet;
export default GameSet;
2 changes: 1 addition & 1 deletion assets/js/platformer3x/GameSetterEnd.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ const GameSetterEnd = {
objects: objects
};

export default GameSetterEnd;
export default GameSetterEnd;
23 changes: 6 additions & 17 deletions assets/js/platformer3x/GameSetterSkibidi.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Laser from './Laser.js';
import SkibidiToilet from './SkibidiToilet.js';
import PlayerSkibidi from './PlayerSkibidi.js';
import FinishLine from './FinishLine.js';
import PlayerBaseOneD from './PlayerBaseOneD.js';

const assets = {
obstacles: {
Expand Down Expand Up @@ -176,24 +177,12 @@ const assets = {
height: 140,
scaleSize: 150,
speedRatio: 0.7,
animationSpeed: 8,
animationSpeed: 4,
///animationspeed:6
idle: {
left: { row: 0, frames: 5 },
right: { row: 0, frames: 5},
},
walk: {
left: { row: 1, frames: 6 },
right: { row: 1, frames: 6 },
},
run: {
left: { row: 2, frames: 7 },
right: { row: 2, frames: 7 },
},
jump: {
left: { row: 3, frames: 8 },
right: { row: 3, frames: 8 },
},
idle: {row: 0, frames: 5 },
walk: { row: 1, frames: 6 },
run: { row: 2, frames: 7 },
jump: {row: 3, frames: 8 },
hitbox: { widthPercentage: 0.3, heightPercentage: 0.8 }
},
whitemario: {
Expand Down
3 changes: 3 additions & 0 deletions assets/js/platformer3x/PlayerBaseOneD.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ export class PlayerBaseOneD extends Character {
// Increase the player's x position according to run or walk animation and related speed
this.setX(this.x + (this.state.animation === 'run' ? this.runSpeed : this.speed));
}
GameEnv.PlayerPosition.playerX = this.x
GameEnv.PlayerPosition.playerY = this.y
}
}

Expand All @@ -145,6 +147,7 @@ export class PlayerBaseOneD extends Character {
updateAnimation() {
switch (this.state.animation) {
case 'idle':
console.log(this.playerData.idle)
if(this.state.direction == "left"){
this.canvas.style.transform = 'scaleX(-1)';
}
Expand Down
21 changes: 20 additions & 1 deletion assets/js/platformer3x/PlayerSkibidi.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import GameEnv from './GameEnv.js';
import PlayerBase from './PlayerBase.js';
import GameControl from './GameControl.js';
import PlayerBaseOneD from './PlayerBaseOneD.js'; ///With this you can change the direction of the sprite sheet with just the sprite rows.

/**
* @class PlayerSkibidi class
Expand All @@ -12,7 +13,7 @@ import GameControl from './GameControl.js';
*
* @extends PlayerBase
*/
export class PlayerSkibidi extends PlayerBase {
export class PlayerSkibidi extends PlayerBaseOneD { /// Using PlayerBaseOneD added the sprite mirror but deleted the sprite not showing the animations

/** GameObject instantiation: constructor for PlayerSkibidi object
* @extends Character
Expand All @@ -23,6 +24,8 @@ export class PlayerSkibidi extends PlayerBase {
constructor(canvas, image, data) {
super(canvas, image, data);

this.animationSpeed = data?.animationSpeed;
this.counter = this.animationSpeed;
// Goomba variables, deprecate?
this.timer = false;
GameEnv.invincible = false; // Player is not invincible
Expand All @@ -44,6 +47,21 @@ export class PlayerSkibidi extends PlayerBase {
this.setY(this.y - (this.bottom * jumpHeightFactor));
}

updateFrameX(){
if (this.frameX < this.maxFrame) {
if(this.counter > 0){
this.frameX = this.frameX;
this.counter--;
}
else{
this.frameX++;
this.counter = this.animationSpeed;
}
} else {
this.frameX = this.minFrame;
}
}

/**
* @override
* gameLoop: Watch for Player collision events
Expand All @@ -56,6 +74,7 @@ export class PlayerSkibidi extends PlayerBase {
this.handleCollisionEvent("laser");
}


/**
* @override
* gameloop: Handles additional Player reaction / state updates to the collision for game level
Expand Down
Loading

0 comments on commit a0ed226

Please sign in to comment.