Results 1 to 2 of 2
  1. #1
    thescoutoftf2's Avatar
    Join Date
    Feb 2017
    Gender
    male
    Posts
    55
    Reputation
    10
    Thanks
    6
    My Mood
    Amazed

    Unhappy need help while creating a simple game

    hello
    so... this is the first time i used canvas and i really need help solving this one

    this is what the game should look like :
    https://imgur.com/a/G3RsB

    and this is how it ended:
    https://imgur.com/a/uCqlu



    this is my html code:
    <!DOCTYPE html>
    <html>
    <head>
    <title>EXercice 5</title>
    <meta charset="utf-8">
    <script src="it.js" type="text/javascript"></script>
    <link rel = "stylesheet" type = "text/css" href = "css.css" />
    </head>
    <body>
    <p>détection du déplacement.(deplacer l'image) </p>
    <h2> les billes dans les boites </h2>
    <p id="info"></p>
    <div id="boite1"></div>
    <div id="boite2"></div>
    <canvas id="billes1" width="40" height="40" draggable="true">
    Texte pour les navigateur qui ne supportent pas canvas
    </canvas>
    <canvas id="billes2" width="40" height="40" draggable="true">
    Texte pour les navigateur qui ne supportent pas canvas
    </canvas>
    <canvas id="billes3" width="40" height="40" draggable="true">
    Texte pour les navigateur qui ne supportent pas canvas
    </canvas>
    <canvas id="billes4" width="40" height="40" draggable="true">
    Texte pour les navigateur qui ne supportent pas canvas
    </canvas>
    <canvas id="billes5" width="40" height="40" draggable="true">
    Texte pour les navigateur qui ne supportent pas canvas
    </canvas>
    </style>
    <img id="image1" src="logo.png" draggable="true" ondragstart="fonction_dragstart(event)" width="100" height="100">
    <p id="info"><p>
    <img id="image1" src="logoo.png" draggable="true" width="100" height="100">
    </body>
    </html>





    my javascript code:
    var image = document.getElementById('image1')
    image.addEventListener('dragstart',fonction_dragst art,false);
    image;addEventListener('dragend',fonction_dragend, false);
    function fonction_dragstart(ev){
    var id = ev.target.id;
    document.getElementById('info').innerHTML="deplace ment de"+id;
    this.style.opacity=0.2;
    this.style.borderStyle='dashed';
    ev.dataTransfer.setData("Text",ev.target.id);
    }
    function fonction_dragend(ev){
    var id = ev.target.id;
    document.getElementById('info').innerHTML="fin de deplacement de"+id;
    this.style.opacity=1;
    this.style.borderStyle='none';
    }
    var cible = document.getElementById('cible')
    cible.addEventListener('dragover',fonction_dragove r,false);
    cible.addEventListener('drop',fonction_drop,false) ;
    function fonction_dragover(ev){
    ev.preventDefault();
    }
    function fonction_drop(ev){
    var data=ev.dataTransfer.getData("Text");
    ev.target.apprendChild(document.getElementById(dat a));
    }





    and my css


    #boite1, #boite2 {
    display: :inline-block;
    width: 200px;height: 200px;border: 1px solid #aaaaaa;
    }



    been 2 weeks trying to solve this
    Last edited by thescoutoftf2; 05-06-2017 at 04:44 AM.

  2. #2
    Hackinet's Avatar
    Join Date
    Jun 2014
    Gender
    male
    Posts
    525
    Reputation
    260
    Thanks
    1,024
    @thescoutoftf2 ,made this for you https://jsfiddle.net/Hackinet/hQTLa/40/ , hope it helps

  3. The Following 3 Users Say Thank You to Hackinet For This Useful Post:

    prohacku (06-15-2017),thxtesting (06-15-2017),thxtesting2 (06-15-2017)

Similar Threads

  1. [Help Request] Need help for creating a rotmg pserv on linux.
    By nathan_hh in forum Realm of the Mad God Private Servers Help
    Replies: 2
    Last Post: 03-14-2015, 10:19 AM
  2. [Visual Basics Tutorial] Need help for creating 2d games
    By mkn16 in forum Programming Tutorial Requests
    Replies: 0
    Last Post: 02-11-2014, 12:31 AM
  3. [Help Request] Need help learning to crack multiple games(paying)
    By mjrr1998 in forum Minecraft Help
    Replies: 4
    Last Post: 08-22-2013, 03:12 AM
  4. [help request]i need help te creat a server of a game
    By Xxbatrik in forum Suggestions, Requests & General Help
    Replies: 0
    Last Post: 05-06-2013, 01:25 AM
  5. [Request] it's not request for hack i just need help to creat an account game KR
    By kazuma-san in forum General Game Hacking
    Replies: 0
    Last Post: 10-16-2012, 11:18 AM