Koppelingen in nieuw tabblad openen
    • Werkrapport
    • E-mail
    • Herschrijven
    • Spraak
    • Titelgenerator
    • Slim antwoord
    • Gedicht
    • Opstel
    • Grap
    • Instagram-post
    • X-post
    • Facebook-post
    • Verhaal
    • Begeleidende brief
    • Hervatten
    • Taakbeschrijving
    • Aanbevelingsbrief
    • Ontslagbrief
    • Uitnodigingsbrief
    • Begroetingsbericht
    • Meer sjablonen proberen
  1. Creating a Mario game in JavaScript involves using HTML5 Canvas for rendering and JavaScript for game logic. Below is an example of how to set up a basic Mario game.

    Example

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Mario Game</title>
    <style>
    canvas {
    display: block;
    margin: 0 auto;
    background: #5c94fc;
    }
    </style>
    </head>
    <body>
    <canvas id="gameCanvas" width="800" height="400"></canvas>
    <script>
    const canvas = document.getElementById('gameCanvas');
    const ctx = canvas.getContext('2d');

    const mario = {
    x: 50,
    y: 300,
    width: 40,
    height: 40,
    speed: 5,
    dx: 0,
    dy: 0
    };

    function drawMario() {
    ctx.fillStyle = 'red';
    ctx.fillRect(mario.x, mario.y, mario.width, mario.height);
    }

    function clear() {
    ctx.clearRect(0, 0, canvas.width, canvas.height);
    }

    function newPos() {
    mario.x += mario.dx;
    mario.y += mario.dy;

    detectWalls();
    }

    function detectWalls() {
    if (mario.x < 0) {
    mario.x = 0;
    }

    if (mario.x + mario.width > canvas.width) {
    mario.x = canvas.width - mario.width;
    }

    if (mario.y < 0) {
    mario.y = 0;
    }

    if (mario.y + mario.height > canvas.height) {
    mario.y = canvas.height - mario.height;
    }
    }

    function update() {
    clear();
    drawMario();
    newPos();

    requestAnimationFrame(update);
    }

    function moveRight() {
    mario.dx = mario.speed;
    }

    function moveLeft() {
    mario.dx = -mario.speed;
    }

    function moveUp() {
    mario.dy = -mario.speed;
    }

    function moveDown() {
    mario.dy = mario.speed;
    }

    function keyDown(e) {
    if (e.key === 'ArrowRight' || e.key === 'd') {
    moveRight();
    } else if (e.key === 'ArrowLeft' || e.key === 'a') {
    moveLeft();
    } else if (e.key === 'ArrowUp' || e.key === 'w') {
    moveUp();
    } else if (e.key === 'ArrowDown' || e.key === 's') {
    moveDown();
    }
    }

    function keyUp(e) {
    if (
    e.key === 'ArrowRight' ||
    e.key === 'd' ||
    e.key === 'ArrowLeft' ||
    e.key === 'a' ||
    e.key === 'ArrowUp' ||
    e.key === 'w' ||
    e.key === 'ArrowDown' ||
    e.key === 's'
    ) {
    mario.dx = 0;
    mario.dy = 0;
    }
    }

    document.addEventListener('keydown', keyDown);
    document.addEventListener('keyup', keyUp);

    update();
    </script>
    </body>
    </html>
    Gekopieerd.
    Feedback
  2. GitHub - tylerreichle/mario_js: Super Mario Bros. Level 1-1 in ...

    Mario JS was build using the following technologies:
    •Vanilla JavaScript used for overall game structure and logic.
    Overview

    Super Mario Bros Level 1-1 recreated in JavaScript

    Play Now!

    Mario runs through each level trying to reach the castle on the other side to save the princess. Each level contains various enemies, coins to collect, and mushrooms to power-up Mario. Mario's primary form of attack is jumping on top of enemies but to…

    Technical Details

    Game viewport updates to follow Mario based of his current x-position on the canvas. Render will only draw entities currently in the viewport, preventing unnessesary usage of resources and memory.

    Bonus features

    There are many additional feature that could be added in the future. Some anticipated updates are:
    •Add the ability to grab flower power-ups and shoot fireballs at enemies.
    •Underground portion of level.

  3. [連載]ć‚¹ćƒ¼ćƒ‘ćƒ¼ćƒžćƒŖć‚Ŗēš„ćŖć‚²ćƒ¼ćƒ ć‚’javascriptで作ってみ …

    19 dec. 2023 · ęœ¬é€£č¼‰ć«ć¤ć„ć¦ ćƒ—ćƒ­ć‚°ćƒ©ćƒŸćƒ³ć‚°åˆåæƒč€…ćŒć‚¹ćƒ¼ćƒ‘ćƒ¼ćƒžćƒŖć‚Ŗēš„ćŖć‚²ćƒ¼ćƒ ć‚’ä½œęˆć™ć‚‹ć®ć«ęƒ…å ±ć‚’ć¾ćØć‚ćŸć‚‚ć®ć§ć™ äøę˜Žē‚¹ć‚„äøå‚™ć‚ć‚Œć°ć€ć°ć—ć°ć—ć‚³ćƒ” …

  4. Mario JS (Vanilla) - CodePen

    html, body { font-family: 'Press Start 2P', cursive; height: 100%; width: 100%; overflow:hidden; margin: 0; padding: 0; } .mario-game { position: fixed; top: 0; left: …

  5. A javascript clone of Super Mario Bros. for the NES

    #Mario Mario.js is a clone of Super Mario Bros. for the Nintendo Entertainment System, implemented in Javascript. It implements a hand-built game engine …

  6. gistlib - make a mario game in javascript

    This tutorial will cover the basics of creating a scrolling 2D platformer game with Mario as the main character. Here are the steps to create a simple Mario game in …

  7. javascriptć§ćƒžćƒŖć‚Ŗć‚’ä½œć‚‹ - gamecorder

    javascriptć§ćƒžćƒŖć‚Ŗć‚’ä½œć‚‹ å°Žå…„ē·Ø 1.ē§ćØćƒžćƒŖć‚Ŗ 2.ćƒžćƒŖć‚Ŗć‚’ć©ć†ć‚„ć£ć¦ä½œć‚‹ć‹ 3.html5とjavascriptć§ć‚²ćƒ¼ćƒ ć‚’ä½œć‚‹ęŗ–å‚™ 4.ć‚²ćƒ¼ćƒ ćƒ«ćƒ¼ćƒ—ćØcanvas 5.javascriptć§ć‚­ćƒ¼ćƒœćƒ¼ćƒ‰ć®å€¤ć‚’å—ć‘å–ć‚‹ 6.ć‚Æćƒ©ć‚¹ć‚’ä½œć‚‹ …

  8. Super-Mario-World | Recreating a level of Super Mario …

    Recreating a level of Super Mario World with Vanilla Javascript and HTML Canvas. Incorporated Object oriented programming principles to create fun and …

  9. Mario Clone Game Using HTML & CSS in JavaScript with …

    13 mei 2025 · Play a Mario-like game built with JavaScript. Navigate stages, overcome obstacles, and rescue the princess using keyboard controls. Learn …

  10. [連載]ć‚¹ćƒ¼ćƒ‘ćƒ¼ćƒžćƒŖć‚Ŗēš„ćŖć‚²ćƒ¼ćƒ ć‚’javascriptで作ってみ …

    23 jul. 2022 · ꦂ要 javascriptć§ć‚¹ćƒ¼ćƒ‘ćƒ¼ćƒžćƒŖć‚Ŗēš„ćŖć‚²ćƒ¼ćƒ ć‚’ä½œć‚Šć¾ć™ (ć‚¤ćƒ”ćƒ¼ć‚øćÆä»„äø‹å‚ē…§) ćƒ—ćƒ­ć‚°ćƒ©ćƒŸćƒ³ć‚°ęœŖēµŒéØ“č€…ć¾ćŸćÆć”ć‚‡ć£ćØć‹ć˜ć£ćŸć“ćØćŒć‚ć‚‹äŗŗå‘ć‘ …

Door deze website te gebruiken, gaat u akkoord met ons gebruik van cookies voor analysedoeleinden, inhoud die is aangepast aan uw persoonlijke voorkeur en advertenties.Meer informatie over cookies van derden|Privacybeleid van Microsoft