GithubHelp home page GithubHelp logo

meth-meth-method / super-mario Goto Github PK

View Code? Open in Web Editor NEW
646.0 646.0 152.0 3.1 MB

Create a Super Mario game in vanilla JS from scratch.

Home Page: http://bit.ly/2i7u5ks

HTML 0.33% JavaScript 99.31% CSS 0.35%

super-mario's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

super-mario's Issues

Why are `level.backgrounds.ranges` arrays?

I'm curious why you chose to define level.background.ranges as arrays rather than objects with x1, x2, y1, and y2 properties?

I do like the use of destructuring into named variables in:

background.ranges.forEach(([x1, x2, y1, y2]) => { // ...

... but you could still use object destructuring, with the object's properties:

background.ranges.forEach(({ x1, x2, y1, y2 }) => { // ...

Enjoyed the video. Thanks!

Create entity Piranha plant.

Create piranha plant, emerging from pipes.
Plant should not emerge when mario is next to or on top of a pipe.
Can be killed with fire balls.

Screenshot 2020-06-12 at 00 59 29

Animate mario after Bowser dies.

When jumped on the axe and Bowser dies, Mario should animate down into the room behind Bowser, print text on the screen and progress to the next level.

Dependant on #98

Screenshot 2020-06-12 at 01 04 53

Moving platforms.

We need 4 types of moving platforms.

1, one that goes on a track in one direction, as seen in level 1-2.

Screenshot 2020-06-01 at 22 54 15

2, one that goes up and down in a pendulum move, as seen in level 1-3.

Screenshot 2020-06-01 at 22 55 18

3, one that is suspended from ropes and move the other platform, and breaks loose both platforms when maxum bottom is reached, as seen in level 4-3.

Screenshot 2020-06-01 at 22 58 41

4, one that goes from side to side as seen in castle

Screenshot 2020-06-08 at 20 30 10

Firefox: RequestAnimationFrame timing issue

I had a problem with the timing on Firefox. It was driving me crazy : "Why it's working perfectly fine on chrome, but not in FF ??". In chrome the jump was smooth, but in FF it's was like Mario started near the end of the jump.

Firefox doesn't start as quickly as Chrome, so each time a launched the timer, mario was already near the end when it rendered the canvas.

First start - time : 746 (FF), 117 (Chrome), so i came up with :
it needed to render 42 Frames for Firefox vs 7 Frames for chrome.

this.updateProxy = (time) => {
	if (lastTime != 0) {
		accumulatedTime += (time - lastTime) / 1000;		
		while(accumulatedTime > deltaTime) {
			this.update(deltaTime);
			accumulatedTime -= deltaTime;
		}
	}
	
	lastTime = time;
	this.enqueue();
}

Design level : .png VS .json

use the pixels of a .png image to build the design of the levels. for example a red pixel for a brick and a blue pixel for a turtle. With image analysis rather than level json

Create pendulium "fly" trait.

Koopa paratroopa needs a trait that makes him fly.
He will fly up and down within a given min and max on the Y axis.

Create "fake" Bowser entity.

Fake Bowser sits in the end of each *-4 level.
He jumps, open his mouth and spits fire.

64x64 sprite.

Can be killed with 5 fireballs, revealing its true enemy upon death or by stomping the axe, removing the bridge and falls down into lava.

1-4: Little Goomba - fire
2-4: Green Koopa Troopa - fire
3-4: Buzzy Beetle - fire
4-4: Spiny - fire
5-4: Lakitu - fire
6-4: Bloober - fire + hammer
7-4: Hammer Brother - fire + hammer

Screenshot 2020-06-12 at 18 43 17

Video of all bowsers: https://www.youtube.com/watch?v=2Wr4G1_L1mM

Create firebar entity.

Castles has a firebar, consisting of fireballs.

A firebar consists of 6 or 12 animated fireballs, and rotate either clockwise or counter clockwise, around the center of a tile, shown or not.

Screenshot 2020-06-12 at 18 32 23

Screenshot 2020-06-12 at 18 35 18

Only level 5-4 uses the 12-length firebar.

Screenshot 2020-06-12 at 18 39 33

Make mario die

Mario should die when small upon contact with enemies, deadly things and when timer is up.
He should jump off the screen using "die" sprite, and play audio/music/die.ogg.

Screenshot 2020-06-01 at 23 06 24

Create "no-fall" trait.

Red Koopa needs a trait, perhaps a flag to pendulumwalk, that prevents him from fall down from blocks.

Collect mushrooms, fireflowers and coins.

Mario should be able to collect mushrooms, fireflowers and coins from chance blocks.

Screenshot 2020-06-08 at 20 34 00

Screenshot 2020-06-08 at 20 34 30

Mario should also be able to collect power-ups from "hidden" and "invisible" blocks.

unwanted bounce

us.pendulumMove.speed = 0;

If you kill goomba by stomping on it you bounce of. Thats the right behavior.
But until the goomba leaves the level (the 2 seconds the flat animation is active) you bounce over and over again - and thats not right.

If you add
us.canCollide = false
to this position it won't happen anymore the dead goomba falls right through the level.

So you have to split up the canCollide property on the Entity class to

  • canCollideWithBackground and
  • canCollideWithOtherEntity

You have to Update the Level update function:

  public update(deltaTime: number) {
    this.entities.forEach(entity => {
      entity.update(deltaTime, this);

      entity.position.x += entity.velocity.x * deltaTime;
      if (entity.canCollideWithBackground) {
        this.tileCollider.checkX(entity);
      }

      entity.position.y += entity.velocity.y * deltaTime;
      if (entity.canCollideWithBackground) {
        this.tileCollider.checkY(entity);
      }

      entity.velocity.y += this.gravity * deltaTime;
    });

    this.entities.forEach(entity => {
      if (entity.canCollideWithOtherEntity) {
        this.entityCollider.check(entity);
      }
    });

    this.totalTime += deltaTime;
  }

You have to update the EntityCollider check function:

  public check(subject: Entity) {
    this.entities.forEach(candidate => {
      if (subject === candidate || !candidate.canCollideWithOtherEntity) {
        return;
      }

      if (subject.boundingBox.overlaps(candidate.boundingBox)) {
        subject.collides(candidate);
        candidate.collides(subject);
      }
    })
  }

Unnecessary Painting?

level.comp.draw(context, camera);

Hello,

The purpose of the timer is to decouple the physics from the frame rate. If the frame rate drops, Mario's jumping arc should still stay the same.

The code as its written certainly does that, but I think it is causing many unnecessary repaints.
If the frame rate drops to 1 frame a second it'll still force 60 repaints, even though all but the 60th one will not be see on the screen.

I think you should have an extension to the Timer, maybe:

const timer = new Timer(1/60)
timer.update = (deltaTime, visible) => {
  //physics update logic goes here
  if (visible) {
    comp.draw(context)
  }
}
timer.start()

I love this Youtube Channel. Also, the Megaman graphics at the beginning makes me hope that one day you'll do one of those later. :)

Cheers

  • Allain

Add animated coin to dashboard.

There should be an animated coin in dashboard in front of the coin counter.

Screenshot 2020-06-07 at 20 40 22

The 8x8 sprites is located at:

overword: [96, 200], [104, 200], [112, 200]
underworld: [120, 200], [128 200], [136, 200]
castle: [144, 200], [152, 200], [160, 200]
underwater: [168, 200], [176, 200], [184, 200]

Make koopa shell deadly for enemies + sounds.

The kicked koopa shell should be deadly for both enemies and mario.
Kicking the shell should play /audio/fx/kick.ogg
The shell should play /audio/fx/brick-bump.ogg when colliding with tiles.

Make Mario grow into large Mario.

Mario should be able to grow to large mario when collecting a mushroom.
Sprite definitions ready, animation to be done.
Should play /audio/fx/power-up-consume.ogg

Collecting points

Mario should be able to collect points from stomping / killing enemies in various ways.
Points is also collected when collecting coins from bricks.
Points is using the 4x8 font located in points.png

Screenshot 2020-06-02 at 10 52 39

Screenshot 2020-06-02 at 11 04 12

Mario should be able to shrink.

When Mario is large, he should be able to shrink when in contact with enemies and deadly things.
He should use shrink animation (yet to be done), and also be invincible for x amount of time, indicated by "transparency" simulated by omitting every 2nd frame.

He should play /audio/fx/pipe.ogg when shrinking. (perhaps rename this sound into something more general.

Create trampoline entity and trampolineTraveller trait

Mario should be able to jump on trampolines.
Jumping can only happen when trampoline is compressed to its maximum.
Mario should bounce on the trampoline when no user input is given.
When jumping sprite run-1 should be used.

Screenshot 2020-06-12 at 19 34 45

Ending level / ride the flag pole

Mario should be able to end the level by riding the flag pole and collect points depending on where on the flag he touches, and then autowalk #61 to the castle.

Screenshot 2020-06-02 at 10 48 29

Proposal: Setup ESlint and style-guides.

If you allow me to jump in and implement ESlint and style-guide based on "standard", I could fork your project and make a PR for you.

I'm enjoying your channel) You do amazing job. Waiting each new episode. Thank you!
Would love to participate)

As I see, you are using Sublime text editor for super-mario development.
I used it for many years, but now switched to Atom. It has better plugins and development experience, and evolving much faster than Sublime.

Entering/exiting from pipes.

Mario should be able to enter and exit from pipes and activate a trigger (inside the pipe?) and exit to any of the defined checkpoints in a level. This will be used to transition to underground coin rooms, transfer levels and warp zones.

Screenshot 2020-06-02 at 10 46 53

Fire mario

Mario should be able to shoot bouncing animated fireballs.
Fireballs play the explosion animation upon hitting targets and blocks.
The fireball is using 4 8x8 sprites in sequence from sprites.png.
Explosion is using 3 16x16 sprites from sprites.png.
Certain enemies are immune to this fire.

Screenshot 2020-06-02 at 11 07 13

Will you refactor the main.js?

Hi, I really love the series so far.
Just a quick question, will you reorganize "main.js"?
Also, should Mario's initial position be in the JSON file for the levels.

I love everything you're doing! It is very interesting to see the code evolve from episode to episode and to look back at previous episodes and see the changes.

  • Eitan

Relative paths

Great project.
I noticed that You are using absolute paths in certain places and relative in others. I think it should be relative everywhere.
This is a list of absolute paths in files:
index.html line 18
js/loaders.js line 20
js/loaders/level.js line 37
sprites/goomba.json line 2
sprites/koopa.json line 2
sprites/mario.json line 2
sprites/overworld.json line 2
sprites/underworld.json line 2

Good luck in the project.

Create "swim" trait.

Mario should be able to swim and emit bubbles.
Bubble sprite 8x8 located in sprites.png at 144 / 208.

Perhaps the swim trait should be applied automatically from an environment key in levelspec.

Screenshot 2020-06-02 at 10 38 09

Create fish "cheep cheep" entity

Create fish entity "cheep cheep".
Unaffected by ground or corals.

4 different types:

  • one red, fast - swims in a straight pattern
  • one red, fast - swims in a triangle wave form pattern
  • one grey, slow - swims in a straight pattern
  • one grey, slow - swims in a triangle wave form pattern
  • one jumping one for overworld levels

Issue partly resolved with #122

Screenshot 2020-06-12 at 19 52 34

Screenshot 2020-06-12 at 20 04 59

Climbing vine

Mario should be able to climb a vine emerging from a block.
Animates using climb-1 and climb-2 sprites.
Playes vine.ogg when appears.

Exists in both overwold and underworld.

Screenshot 2020-05-15 at 08 35 29

Screenshot 2020-05-15 at 08 35 47

all entity collisions are doubled

on entity collider we have both subject.collides(candidate) and candidate.collides(subject) and entity nested loops cause every subject != candidate pair go to this.
As result, on collision, for example mario.collides(goomba) is called with subject === mario and candidate == goomba and then with subject === goomba and candidate === mario.

With such a loop nesting calling only subject.collides(candidate) is enough.

Create red koopa

Red koopa is the same as green koopa but with an added trait that don't permits him to fall down from a tile.

This issue is dependant on #55

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.