Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions js/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,30 @@ var player = new Mario.Player([0,0]);
//Cool!
//TODO: Automatically scale the game to work and look good on widescreen.
//TODO: fiddling with scaled sprites looks BETTER, but not perfect. Hmm.
canvas.width = 762;
canvas.height = 720;
ctx.scale(3,3);

//added this to make the game look better on widescreen. -mightyowl866
// Widescreen aspect ratio
var aspectRatio = 16 / 9;

// Screen dimensions
var screenWidth = window.innerWidth;
var screenHeight = window.innerHeight;

// Set canvas dimensions based on aspect ratio
canvas.width = screenWidth;
canvas.height = screenHeight;

// Set viewport dimensions based on aspect ratio
vWidth = screenWidth / 3; // Adjust this value as needed
vHeight = vWidth / aspectRatio;

// Scale the context
ctx.scale(screenWidth / vWidth, screenHeight / vHeight);
document.body.appendChild(canvas);

//viewport
var vX = 0,
vY = 0,
vWidth = 256,
vHeight = 240;
vY = 0

//load our images
resources.load([
Expand Down Expand Up @@ -190,7 +204,8 @@ function render() {

//scenery gets drawn first to get layering right.
for(var i = 0; i < 15; i++) {
for (var j = Math.floor(vX / 16) - 1; j < Math.floor(vX / 16) + 20; j++){
//changed this to 50 to fix the right side of the screen. -mightyowl866
for (var j = Math.floor(vX / 16) - 1; j < Math.floor(vX / 16) + 50; j++){
if (level.scenery[i][j]) {
renderEntity(level.scenery[i][j]);
}
Expand All @@ -214,7 +229,8 @@ function render() {

//then we draw every static object.
for(var i = 0; i < 15; i++) {
for (var j = Math.floor(vX / 16) - 1; j < Math.floor(vX / 16) + 20; j++){
//changed this to 50 to fix the right side of the screen. -mightyowl866
for (var j = Math.floor(vX / 16) - 1; j < Math.floor(vX / 16) + 50; j++){
if (level.statics[i][j]) {
renderEntity(level.statics[i][j]);
}
Expand Down
5 changes: 3 additions & 2 deletions js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
Mario.Util.inherits(Player, Mario.Entity);

Player.prototype.run = function() {
this.maxSpeed = 2.5;
this.maxSpeed = 2.2;
if (this.power == 2 && !this.runheld) {
this.shoot();
}
Expand All @@ -44,7 +44,8 @@
}

Player.prototype.noRun = function() {
this.maxSpeed = 1.5;
//lowered mario's speed for easier control. --mightyowl866
this.maxSpeed = 1.1;
this.moveAcc = 0.07;
this.runheld = false;
}
Expand Down