IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Caml Discussion :

Développement d'un jeu d'allumettes


Sujet :

Caml

  1. #1
    Nouveau Candidat au Club
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Novembre 2015
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Doubs (Franche Comté)

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Novembre 2015
    Messages : 2
    Points : 1
    Points
    1
    Par défaut Développement d'un jeu d'allumettes
    Bonjour, je fais un jeux d'allumettes je voudrais savoir comment faire pour creer un enregistrement de tableau en ocaml. J'ai déjà fait mon enregistrement d'allumettes.

  2. #2
    Membre habitué
    Profil pro
    Inscrit en
    Octobre 2010
    Messages
    87
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2010
    Messages : 87
    Points : 172
    Points
    172
    Par défaut
    Bonsoir, nous ne pouvons pas vous aider si vous ne mettez aucune autre information. Il faudrait déjà qu'on puisse voir ce que vous avez déjà fait

    Cordialement

  3. #3
    Nouveau Candidat au Club
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Novembre 2015
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Doubs (Franche Comté)

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Novembre 2015
    Messages : 2
    Points : 1
    Points
    1
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    type tete = {
       mutable cx      : int;
       mutable cy      : int;
       mutable rayon   : int;
       mutable teteCol : Graphics.color
    };;
     
    type tige = {
       mutable tx       : int;
       mutable ty       : int;
       mutable tLargeur : int;
       mutable tHauteur : int;
       mutable tigeCol  : Graphics.color 
     };;
     
    type allumette = {
       mutable haut   : tete;
       mutable bas    : tige;
       mutable  choisi : bool
    };;
     
    type joueur = Humain | Ordinateur ;;
     
    type jeux ={
       allumettes      : allumette array;
       nbAlluTotal     : int;
       nbAlluRestant   : int;
       nbMaxARetirer   : int ;
       mutable joueur1 : joueur;
       mutable joueur2 : joueur;
       tourJoueur      : bool;
    };;
     
    type status = {
      	mouse_x : int;	
      	mouse_y : int;	
      	button : bool;
      	keypressed : bool;
      	key : char;
    };;
     
    type event = |Button_down | Button_up |Key_pressed | Mouse_motion | Poll ;;
     
    #load "graphics.cma" ;;
    Graphics.open_graph " 800x440";;
    Graphics.set_window_title "Jeu de Batonnets";;
    let vertforet = Graphics.rgb 0 128 0;;
    Graphics.set_color vertforet;
    Graphics.fill_rect 0 70 800 300;
    Graphics.set_color Graphics.red;
    Graphics.draw_rect 0 69 801 301;
    Graphics.moveto 0 69; Graphics.lineto 0 0; Graphics.lineto 801 0;
    Graphics.lineto 801 69; Graphics.moveto 0 301; Graphics.lineto 0 440;
    Graphics.lineto 801 440; Graphics.lineto 801 301;Graphics.moveto 25 40;
    Graphics.draw_string "Batons";Graphics.moveto 20 20;
    Graphics.draw_string "restants :";Graphics.moveto 110 50;
    Graphics.draw_string "Maximum de";Graphics.moveto 105 40;
    Graphics.draw_string "batons que vous:"
    ;;
     
    let allum= {bas = {tx = 20; ty = 200; tLargeur = 2; tHauteur = 40; tigeCol = Graphics.white}; haut = {cx = 21; cy = 240; rayon = 4; teteCol = Graphics.red}; choisi = true };;
     
    let dessiner allu = 
      Graphics.set_color allu.bas.tigeCol;
      Graphics.fill_rect allu.bas.tx allu.bas.ty allu.bas.tLargeur allu.bas.tHauteur;
      Graphics.set_color allu.haut.teteCol;
      Graphics.fill_circle allu.haut.cx allu.haut.cy allu.haut.rayon;;
     
    let v = Array.make 20 allum;;
    for i = 1 to Array.length v - 1 do
      v.(i) <- {bas={tx=20 + i*(760/20); ty=200; tLargeur=2; tHauteur=40; tigeCol=Graphics.white}; haut ={cx=(21 + 1) + i*(760/20);cy=240; rayon=4; teteCol=Graphics.red}; choisi=true};
    done;;
    for i=0 to 19 do
    dessiner v.(i);
    done;;

    Voici le code que j'ai fait maintenant je veux faire bouger les alllumettes mais je ne sais pas comment faire pour integrer la gestion des évènements. Par exemple faire bouger une allumettes par clic de la souris

  4. #4
    Membre habitué
    Profil pro
    Inscrit en
    Octobre 2010
    Messages
    87
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2010
    Messages : 87
    Points : 172
    Points
    172
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    type tete = {
      mutable cx      : int;
      mutable cy      : int;
      mutable rayon   : int;
      mutable teteCol : Graphics.color
    }
     
    type tige = {
      mutable tx       : int;
      mutable ty       : int;
      mutable tLargeur : int;
      mutable tHauteur : int;
      mutable tigeCol  : Graphics.color 
    }
     
    type allumette = {
      mutable haut   : tete;
      mutable bas    : tige;
      mutable  choisi : bool
    }
     
    type joueur = Humain | Ordinateur 
     
    type jeux ={
      allumettes      : allumette array;
      nbAlluTotal     : int;
      nbAlluRestant   : int;
      nbMaxARetirer   : int ;
      mutable joueur1 : joueur;
      mutable joueur2 : joueur;
      tourJoueur      : bool;
    }
     
    let vertforet = Graphics.rgb 0 128 0
     
    let allum= 
      {bas = {tx = 20; ty = 200; tLargeur = 2; tHauteur = 40; 
              tigeCol = Graphics.white}; 
       haut = {cx = 21; cy = 240; rayon = 4; teteCol = Graphics.red}; 
       choisi = true}
     
    let dessiner allu = 
      Graphics.set_color allu.bas.tigeCol;
      Graphics.fill_rect allu.bas.tx allu.bas.ty 
        allu.bas.tLargeur allu.bas.tHauteur;
      Graphics.set_color allu.haut.teteCol;
      Graphics.fill_circle allu.haut.cx allu.haut.cy allu.haut.rayon
     
    let () =
      Graphics.open_graph " 800x440";
      Graphics.set_window_title "Jeu de Batonnets";
      Graphics.set_color vertforet;
      Graphics.fill_rect 0 70 800 300;
      Graphics.set_color Graphics.red;
      Graphics.draw_rect 0 69 801 301;
      Graphics.moveto 0 69; Graphics.lineto 0 0; Graphics.lineto 801 0;
      Graphics.lineto 801 69; Graphics.moveto 0 301; Graphics.lineto 0 440;
      Graphics.lineto 801 440; Graphics.lineto 801 301;Graphics.moveto 25 40;
      Graphics.draw_string "Batons";Graphics.moveto 20 20;
      Graphics.draw_string "restants :";Graphics.moveto 110 50;
      Graphics.draw_string "Maximum de";Graphics.moveto 105 40;
      Graphics.draw_string "batons que vous:";
      let v = Array.make 20 allum in
      for i = 1 to Array.length v - 1 do
        v.(i) <- {bas={tx=20 + i*(760/20); ty=200; tLargeur=2; 
                       tHauteur=40; tigeCol=Graphics.white}; 
                  haut ={cx=(21 + 1) + i*(760/20);cy=240; rayon=4; 
                         teteCol=Graphics.red}; 
                  choisi=true};
      done;
      for i=0 to 19 do
        dessiner v.(i);
      done;
      ignore (Graphics.read_key ())
    Premièrement, vous n'avez pas besoin de redéfinir les types event et status étant donné qu'ils sont dans Graphics. De plus, je vous invite à regarder les fonctions
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    val wait_next_event : event list -> status
     
    Wait until one of the events specified in the given event list occurs, and return the status of the mouse and keyboard at that time. If Poll is given in the event list, return immediately with the current status. If the mouse cursor is outside of the graphics window, the mouse_x and mouse_y fields of the event are outside the range 0..size_x()-1, 0..size_y()-1. Keypresses are queued, and dequeued one by one when the Key_pressed event is specified.
     
    val loop_at_exit : event list -> (status -> unit) -> unit
     
    Loop before exiting the program, the list given as argument is the list of handlers and the events on which these handlers are called. To exit cleanly the loop, the handler should raise Exit. Any other exception will be propagated outside of the loop.
    Since 4.01
    Une fois que vous aurez essayé de les manipuler, nous verrons si vous avez encore des questions.

    Cordialement.

    P.S. Il semble que vous fassiez tout cela dans le toplevel (donc l'interpréteur ocaml). Il faudrait penser à créer un fichier .ml et à le compiler. La directive de compilation est
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    ocamlc -o monexec graphics.cma monfichier.ml
    [EDIT] J'ai réécrit votre code, ça me faisait trop mal

Discussions similaires

  1. [Lazarus] Jeu d'allumettes (affichage)
    Par 'ti programmeur dans le forum Lazarus
    Réponses: 4
    Dernier message: 21/02/2007, 18h20
  2. Réponses: 5
    Dernier message: 05/09/2006, 20h08
  3. Choix important pour développement d'un jeu
    Par thecyril dans le forum Autres éditeurs
    Réponses: 4
    Dernier message: 13/02/2006, 19h32
  4. [Methodologie] Methode de développement d'un jeu en réseau
    Par gamerome dans le forum Développement 2D, 3D et Jeux
    Réponses: 7
    Dernier message: 26/01/2006, 13h10
  5. développement d'un jeu vidéo...
    Par youp_db dans le forum Développement 2D, 3D et Jeux
    Réponses: 3
    Dernier message: 30/10/2005, 17h09

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo