Skip to content

Commit

Permalink
fix somethings
Browse files Browse the repository at this point in the history
  • Loading branch information
Viet281101 committed Dec 16, 2023
1 parent 5d457c7 commit d263f2f
Show file tree
Hide file tree
Showing 27 changed files with 39 additions and 91 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ Link play : https://viet281101.github.io/CastlevaniaJS/
- Viet Nguyen
- Damien Geoffroy
- Wilfried Ben Brahim
- Alexandre L'humeau
- Jonny Mathanaruban
63 changes: 0 additions & 63 deletions assets/Characters/Bitterfly/Hitbox_Bitterfly.txt

This file was deleted.

Binary file added assets/Characters/Bitterfly/bitterfly.ase
Binary file not shown.
Binary file modified assets/Characters/Bitterfly/bitterfly.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 assets/Characters/Bitterfly/bitterfly_sheet.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 removed assets/Characters/Bitterfly/death/death1.png
Binary file not shown.
Binary file removed assets/Characters/Bitterfly/death/death2.png
Binary file not shown.
Binary file removed assets/Characters/Bitterfly/death/death3.png
Binary file not shown.
Binary file removed assets/Characters/Bitterfly/death/death4.png
Binary file not shown.
Binary file removed assets/Characters/Bitterfly/death/death5.png
Binary file not shown.
Binary file removed assets/Characters/Bitterfly/death/death6.png
Binary file not shown.
Binary file removed assets/Characters/Bitterfly/death/death7.png
Binary file not shown.
Binary file removed assets/Characters/Bitterfly/death/death8.png
Binary file not shown.
Binary file removed assets/Characters/Bitterfly/moving/moving1.png
Binary file not shown.
Binary file removed assets/Characters/Bitterfly/moving/moving2.png
Binary file not shown.
Binary file removed assets/Characters/Bitterfly/moving/moving3.png
Binary file not shown.
Binary file removed assets/Characters/Bitterfly/moving/moving4.png
Binary file not shown.
Binary file removed assets/Characters/Bitterfly/moving/moving5.png
Binary file not shown.
Binary file removed assets/Characters/Bitterfly/moving/moving6.png
Binary file not shown.
Binary file removed assets/Characters/Bitterfly/waking_up/waking_up1.png
Binary file not shown.
Binary file removed assets/Characters/Bitterfly/waking_up/waking_up2.png
Binary file not shown.
Binary file removed assets/Characters/Bitterfly/waking_up/waking_up3.png
Binary file not shown.
Binary file removed assets/Characters/Bitterfly/waking_up/waking_up4.png
Binary file not shown.
Binary file removed assets/Characters/Bitterfly/waking_up/waking_up5.png
Binary file not shown.
Binary file removed assets/Characters/Bitterfly/waking_up/waking_up6.png
Binary file not shown.
Binary file removed assets/Characters/Bitterfly/waking_up/waking_up7.png
Binary file not shown.
65 changes: 38 additions & 27 deletions js/game/lvl1/game-01.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ const Game = function() {
};
Game.prototype = { constructor : Game };

Game.Animator = function(frame_set, delay) {
Game.Animator = function(frame_set, delay, mode = "loop") {
this.count = 0;
this.delay = (delay >= 1) ? delay : 1;
this.frame_set = frame_set;
this.frame_index = 0;
this.frame_value = frame_set[0];
this.mode = "pause";
this.mode = mode;
};
Game.Animator.prototype = {
constructor:Game.Animator,
Expand Down Expand Up @@ -66,7 +66,6 @@ const Game = function() {
};

Game.Collider = function() {
/* I changed this so all the checks happen in y first order. */
this.collide = function(value, object, tile_x, tile_y, tile_size) {
switch(value) {
case 1: this.collidePlatformTop (object, tile_y ); break;
Expand Down Expand Up @@ -101,8 +100,8 @@ const Game = function() {
if (this.collidePlatformBottom (object, tile_y + tile_size)) return;
if (this.collidePlatformLeft (object, tile_x )) return;
this.collidePlatformRight (object, tile_x + tile_size); break;
case 16: this.collideSlopeTopRight (object, tile_x + tile_size, tile_y, tile_size); break;
case 17: this.collideSlopeTopLeft (object, tile_x, tile_y, tile_size); break;
case 16: this.collideSlopeRight (object, tile_x + tile_size, tile_y, tile_size); break;
case 17: this.collideSlopeLeft (object, tile_x, tile_y, tile_size); break;
}
}
};
Expand Down Expand Up @@ -149,30 +148,42 @@ const Game = function() {
} return false;
},

collideSlopeTopLeft:function(object, tile_left, tile_right, tile_top) {
let y = tile_top - (object.getRight() - tile_left) - 1;

if (object.getTop() < y && object.getOldTop() >= y) {

object.setTop(y);
object.velocity_y = 0;
object.jumping = false;
return true;

} return false;
collideSlopeLeft:function(object, tile_x, tile_y, tile_size) {
var tile_bottom = tile_y + tile_size;
var tile_right = tile_x + tile_size;

var object_bottom = object.getBottom();
var object_right = object.getRight();

if (object_bottom > tile_y && object_right > tile_x) {
var slope = (tile_bottom - object.getTop()) / (tile_right - object.getLeft());
if (slope > 1) {
object.setBottom(tile_bottom);
object.velocity_y = 0;
} else if (slope < 1) {
object.setRight(tile_right);
object.velocity_x = 0;
}
}
},

collideSlopeTopRight:function(object, tile_left, tile_right, tile_top) {
let y = tile_top - (tile_right - object.getLeft()) - 1;

if (object.getTop() < y && object.getOldTop() >= y) {

object.setTop(y);
object.velocity_y = 0;
object.jumping = false;
return true;

} return false;
collideSlopeRight:function(object, tile_x, tile_y, tile_size) {
var tile_bottom = tile_y + tile_size;
var tile_left = tile_x;

var object_bottom = object.getBottom();
var object_left = object.getLeft();

if (object_bottom > tile_y && object_left < tile_x) {
var slope = (tile_bottom - object.getTop()) / (object.getRight() - tile_left);
if (slope > 1) {
object.setBottom(tile_bottom);
object.velocity_y = 0;
} else if (slope < 1) {
object.setLeft(tile_left - object.width);
object.velocity_x = 0;
}
}
},
};

Expand Down

0 comments on commit d263f2f

Please sign in to comment.