Documentation de la bibliothèque MLV-2.0.2

beginner/06_keyboard.c

Ce programme montre comment il est possible d'utiliser le clavier.

#include <MLV/MLV_all.h>
//
// Attention !
// Pour pouvoir compiler ce programme sous windows et sous macintosh,
// il faut, pour la déclaration du main, respecter strictement la syntaxe
// suivante :
//
int main(int argc, char *argv[]){
//
// Déclaration de la variable qui représentera le code de la touche qui
// sera appuyée par l'utilisateur.
//
//
// Créé et affiche la fenêtre
//
MLV_create_window( "beginner - 6 - keyboard", "keyboard", 640, 480 );
//
// Affiche la consigne
//
MLV_draw_text( 10, 10, "Appuyez sur la touche k", MLV_COLOR_GREEN );
//
// Attendre que l'utilisateur appuie sur une touche du clavier
//
MLV_wait_keyboard( &touche, NULL, NULL );
//
// Affiche "Bien !" si l'utilisateur a appuyer sur la touche k sinon
// affiche un message d'erreur.
//
if( touche == MLV_KEYBOARD_k ){
MLV_draw_text( 10, 30, "Bien !", MLV_COLOR_GREEN );
}else{
10, 30, "Vous n'avez pas appuyé sur la touche k",
);
}
//
// Attend 2 seconde avant la fin du programme.
//
//
// Ferme la fenêtre
//
return 0;
}
/*
* This file is part of the MLV Library.
*
* Copyright (C) 2010,2011,2012,2013 Adrien Boussicault, Marc Zipstein
*
*
* This Library is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this Library. If not, see <http://www.gnu.org/licenses/>.
*/