begin process at 2012 02 12 10:17:21
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Graphique

 > SCREENSAVER HYPNOTISEUR

SCREENSAVER HYPNOTISEUR


 Description

Cliquez pour voir la capture en taille normale
Bonjour
Un screensaver en SDL pas du tout assez optimisé, je m'en excuse mais sur un pentium 4 il tournera quand même ^^
disons qu'il économise pas beaucoup le processeur

le but du jeu c'est de tenir le plus longtemps possible devant, et/ou trouver comment il fonctionne

Source

  • #define WW 800
  • #define HH 600
  • #include <stdio.h>
  • #include <stdlib.h>
  • #include <SDL/SDL.h>
  • #include <math.h>
  • static SDL_Surface * init(int w, int h, int bpp);
  • static void loop(SDL_Surface * s);
  • static void manageEvents(SDL_Surface * s);
  • static void draw(SDL_Surface * s);
  • static void SDL_Rotate(SDL_Surface *src,SDL_Surface *dst, double rotation, int x, int y);
  • int main(int argc, char ** argv) {
  • SDL_Surface * s;
  • s = init(WW, HH, 32);
  • loop(s);
  • return 0;
  • }
  • static SDL_Surface * init(int w, int h, int bpp) {
  • SDL_Surface * s;
  • if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
  • exit(1);
  • }
  • if ( (s = SDL_SetVideoMode(w, h, bpp, SDL_SWSURFACE | SDL_HWSURFACE |SDL_FULLSCREEN )) == NULL ) {
  • exit(1);
  • }
  • int i; Uint32 *t = s->pixels; for (i=0; i < WW*HH; i++) t[i] = 0xFFFFFFFF;
  • atexit(SDL_Quit);
  • return s;
  • }
  • static void loop(SDL_Surface * s) {
  • SDL_Surface *s2 = SDL_CreateRGBSurface(SDL_HWSURFACE, WW*2, HH*2, 32, 0, 0, 0, 0);
  • static int i,j;
  • Uint32 *t = s2->pixels;
  • static int count = 0;
  • static int yesorno = 0;
  • static double rotation3 = M_PI/2000;
  • static SDL_Event event;
  • static double rotation2 = 2.1543;
  • for (i=0; i < WW*2; i++) for (j=0; j < HH*2; j++) t[j*WW+i] = 0;
  • for(;;) {
  • if (yesorno) rotation3 /= 1.3;
  • else rotation3 *= 1.2;
  • if (rotation3 < M_PI/500000) { yesorno = !yesorno; rotation3 = M_PI/500000; }
  • if (rotation3 > M_PI/1000) { yesorno = !yesorno; rotation3 = M_PI/1000; }
  • rotation2 += rotation3;
  • while (rotation2 >= 2*M_PI) rotation2 -= 2*M_PI;
  • SDL_Rotate(s2,s,rotation2,WW,HH);
  • SDL_UpdateRect(s, 0, 0, WW, HH);
  • SDL_Delay(1);
  • if(SDL_PollEvent(&event) && event.type == SDL_KEYDOWN) exit(0);
  • }
  • }
  • static void SDL_Rotate(SDL_Surface *src,SDL_Surface *dst, double rotation, int x, int y) {
  • Uint32 *t1 = src->pixels, *t2 = dst->pixels;
  • static int i,j,i2,j2,i3,j3;
  • static double vi, vj;
  • vi = cos(rotation); vj = sin(rotation);
  • for (i=0; i < WW*HH; i++) t2[i] = 0xFFFFFFFF;
  • for (i=0; i < WW*2; i++)
  • for (j=0; j < HH*2; j++) {
  • i3 = i - x; j3 = j - y;
  • i2 = (double)i3*vi - (double)j3*vj + x - WW/2; j2 = (double)i3*vj + (double)j3*vi + y - HH/2;
  • if (i2 >=0 && j2 >= 0 && i2 < WW && j2 < HH)
  • t2[j2 * WW + i2] = t1[j * WW + i];
  • }
  • }
#define WW 800
#define HH 600
#include <stdio.h>
#include <stdlib.h>
#include <SDL/SDL.h>
#include <math.h>

static SDL_Surface * init(int w, int h, int bpp);
static void          loop(SDL_Surface * s);
static void          manageEvents(SDL_Surface * s);
static void          draw(SDL_Surface * s);
static void SDL_Rotate(SDL_Surface *src,SDL_Surface *dst, double rotation, int x, int y);


int main(int argc, char ** argv) {
  SDL_Surface * s;
  s = init(WW, HH, 32);
  loop(s);
  return 0;
}

static SDL_Surface * init(int w, int h, int bpp) {
  SDL_Surface * s;
  if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
    exit(1);
  }
  if ( (s = SDL_SetVideoMode(w, h, bpp, SDL_SWSURFACE | SDL_HWSURFACE |SDL_FULLSCREEN )) == NULL ) {
    exit(1);
  }
  int i; Uint32 *t = s->pixels; for (i=0; i < WW*HH; i++) t[i] = 0xFFFFFFFF;
  atexit(SDL_Quit);
  return s;
}


static void loop(SDL_Surface * s) {
  SDL_Surface *s2 = SDL_CreateRGBSurface(SDL_HWSURFACE, WW*2, HH*2, 32, 0, 0, 0, 0);
  static int i,j;
  Uint32 *t = s2->pixels;
  static int count = 0;
  static int yesorno = 0;
  static double rotation3 = M_PI/2000;
  static SDL_Event event;
  static double rotation2 = 2.1543;
  for (i=0; i < WW*2; i++) for (j=0; j < HH*2; j++) t[j*WW+i] = 0;
  for(;;) {
    if (yesorno) rotation3 /= 1.3;
    else rotation3 *= 1.2;
    if (rotation3 < M_PI/500000) { yesorno = !yesorno; rotation3 = M_PI/500000; }
    if (rotation3 > M_PI/1000) { yesorno = !yesorno; rotation3 = M_PI/1000; }
    rotation2 += rotation3;
    while (rotation2 >= 2*M_PI) rotation2 -= 2*M_PI;
    SDL_Rotate(s2,s,rotation2,WW,HH);
    SDL_UpdateRect(s, 0, 0, WW, HH);
    SDL_Delay(1);
    if(SDL_PollEvent(&event) && event.type == SDL_KEYDOWN) exit(0);
  }
}

static void SDL_Rotate(SDL_Surface *src,SDL_Surface *dst, double rotation, int x, int y) {
    Uint32 *t1 = src->pixels, *t2 = dst->pixels;
    static int i,j,i2,j2,i3,j3;
    static double vi, vj;
    vi = cos(rotation); vj = sin(rotation);
    for (i=0; i < WW*HH; i++) t2[i] = 0xFFFFFFFF;
    for (i=0; i < WW*2; i++)
        for (j=0; j < HH*2; j++) {
            i3 = i - x; j3 = j - y;
            i2 = (double)i3*vi - (double)j3*vj + x - WW/2; j2 = (double)i3*vj + (double)j3*vi + y - HH/2;
            if (i2 >=0 && j2 >= 0 && i2 < WW && j2 < HH)
                t2[j2 * WW + i2] = t1[j * WW + i];
        }
}


 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !
  • screensaver.cTélécharger ce fichier [Réservé aux membres club]Voir ce fichier2 410 octets
  • screensaver.cbpTélécharger ce fichier [Réservé aux membres club]811 octets
  • screensaver.scrTélécharger ce fichier [Réservé aux membres club]221 863 octets
  • SDL.dllTélécharger ce fichier [Réservé aux membres club]258 048 octets

Télécharger le zip


 Sources du même auteur

Source avec une capture OPENGL - JEU DE BILLARD EN 3D PAS FINI
Source avec Zip (WIN32) PARSER DU LANGAGE C AVEC YACC
Source avec Zip Source avec une capture BIEN EXPLIQUE: EXEMPLE DE RESEAU DE NEURONE
Source avec Zip OPENGL: CLASSE CAMERA QUI GÈRE LE GLULOOKAT
Source avec Zip LABYRINTHE EN 3D

 Sources de la même categorie

Source avec Zip APPLICATION DE DESSIN DE QUELQUES FIGURES par laguchori
Source avec Zip Source avec une capture HDR EXPOSURE FUSION par mecrosoft
Source avec Zip Source avec une capture IRC CLIENT MULTISERVEUR EN MFC (TXIRC) par TeniX
Source avec Zip ENTETE DU FICHIER BMP (BIPMAP) par k.Lutchi
Source avec Zip Source avec une capture XCOUPE : COUPE 2D par pop70

 Sources en rapport avec celle ci

Source avec Zip Source avec une capture JEUX SERPENT par antho974
Source avec Zip Source avec une capture PENDU EN SDL par Damsou91
CASSE BRIQUE SDL MODIFICATION par Vardosh
Source avec Zip Source avec une capture BOMBERMAN 4 PLAYERS LAN (C & SDL) par c1702
Source avec Zip ECRAN DE VEILLE (LOAD IMAGE REPERTOIRE) par taureau23

Commentaires et avis

Commentaire de acx01b le 03/03/2007 18:53:53

personne ne laisse de commentaire ?

Commentaire de aze555666 le 05/03/2007 12:57:00

Patience^^
Le petit probleme pour ce qui est des commentaires constructifs avec moi c'est que je ne connais rien au C (je sais seulement le lire un peu car je connais sufisemment d'autres languages pour ça).
Pour info, j'ai tenu 5 minutes, et j'aurais pu faire plus seulement rester des jours devant simplement pour établir un record ne m'interesse pas. Mais c'est vrai que c'est assez énervant à regarder!

 Ajouter un commentaire


Discussions en rapport avec ce code source dans le forum

SDL : comment rafraichir l'ecran? [ par smilandfly ] Bonsoir'je viens de mettre sous sdl (que je viens de decouvrir) mon awale programmé en C++ en mode texte.J'ai 2 problemes qui ne sont sans doute pas t [SDL] Defilement de l'ecran [ par hoxid ] Ben voila je voulais savoir comment faire defiler l'ecran, avec SDL.J'y arrive, mais quand le perso arrive au milieu, il bloque. De plus, quand il va economiseur d'ecran [ par philippexxx ] philippeje souhaite savoir la difference entre un programme graphique simple en visual c++ et un economiseur d'ecranoucomment transformer un programme probleme vitesse scrolling [ par gusdark ] bonjour , j'ai lu pas mal de topics sur le scrolling dans le forum, ce qui m'a permis de comprendre le principe.Mais j'ai cependant un problème que je SDL [ par lushkah ] bjr, j'ai un pb avec la SDL  en C, je débutes et j'ai passer la nuit a essayer de faire une disparition en fondu, j'essayes de programmer un jeu de da Message d'erreur avec SL [ par Maximi ] Bonjour je débute avec C++ et SDL, je travaille avec VC++ 6.J'ai fait un tout petit programme et mon problème, est le suivant :je compile le code et c aide moi dans la SDL [ par iliassh ] je veux vos aide pour cree mon jeux en SDL,et je suis trop charger pourque je le rend avant la fin du mois courantje vai l'aide de qq de votre part po programmation lecteur mp3 [ par dr971 ] Bonjour,je souhaite realiser un lecteur mp3 en c grace à la librairie fmod mais j'ai un probleme. En fait je souhaite qu'en appuyant sur la touche p d Probleme en prog SDL.h [ par sieuzac ] Salut a tous.Je voudrez savoir pourquoi mon va plus vite au TEMP 2 qu'au TEMP 1#include &lt;SDL/SDL.h&gt;#include &lt;stdio.h&gt;#include &lt;time.h&g


Nos sponsors


Sondage...

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,920 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales