Accueil > > > SCREENSAVER HYPNOTISEUR
SCREENSAVER HYPNOTISEUR
Information sur la source
Description
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];
}
}
Sources du même auteur
Sources de la même categorie
Commentaires et avis
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 <SDL/SDL.h>#include <stdio.h>#include <time.h&g
|
Derniers Blogs
[MIX10] KEYNOTE DEUXIèME JOURNéE - INTERNET EXPLORER 9, HTML5, VISUAL STUDIO 2010, ODATA[MIX10] KEYNOTE DEUXIèME JOURNéE - INTERNET EXPLORER 9, HTML5, VISUAL STUDIO 2010, ODATA par cyril
Le deuxième keynote du mix fut très riche en contenu. Internet Explorer 9 Juste un après le lancement de Internet Explorer 8, Microsoft a dévoilé les nouveautés de Internet Explorer 9. Désormais, IE supportera HTML5, SVG et CSS3. L'élément ...
Cliquez pour lire la suite de l'article par cyril CERTIFICATIONS BETA .NET 4CERTIFICATIONS BETA .NET 4 par KooKiz
Les inscriptions pour les certifications beta .NET 4 ont commencé. L'inscription est offerte pour les examens suivants : - 71-511, TS: Windows Applications Development with Microsoft .NET Framework 4 - 71-515, TS: Web Applications Development with...
Cliquez pour lire la suite de l'article par KooKiz [MIX 2010] - MICROSOFT TRANSLATOR TECHNOLOGY PREVIEW V2[MIX 2010] - MICROSOFT TRANSLATOR TECHNOLOGY PREVIEW V2 par redo
J'imagine que la plupart d'entre vous connaissent bien et utilisent le service de traduction de Google, mais connaissez-vous celui de Microsoft . Microsoft Translator ? Effectivement, Microsoft nous annoncé le lancement version 2 de la Technologie Preview...
Cliquez pour lire la suite de l'article par redo LANCEMENT EN PREVIEW DE CYCLONE LORS DES TECHDAYS 2010!LANCEMENT EN PREVIEW DE CYCLONE LORS DES TECHDAYS 2010! par MPOWARE
Toutes les vidéos de ce lancement sont en ligne!
Partie I - Intro
http://www.youtube.com/watch?v=LkQzTQ8T6CA
Partie II - Démo 1
http://www.youtube.com/watch?v=drAhYQ7lqvo
Partie III - Démo 2
http://www.youtube.com/watch?v=c8KM_1Gqybc...
Cliquez pour lire la suite de l'article par MPOWARE
Forum
TABLEAU DE LISTETABLEAU DE LISTE par help26
Cliquez pour lire la suite par help26
Logiciels
Academy System (10.9.4.0)ACADEMY SYSTEM (10.9.4.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Xilisoft Convertisseur Vidéo Ultimate (5.1.39.0305)XILISOFT CONVERTISSEUR VIDéO ULTIMATE (5.1.39.0305)Xilisoft Convertisseur Vidéo Ultimate est un outil puissant de conversion vidéo, facile à utilise... Cliquez pour télécharger Xilisoft Convertisseur Vidéo Ultimate Xilisoft DVD Ripper Ultimate (5.0.64.0304)XILISOFT DVD RIPPER ULTIMATE (5.0.64.0304)Xilisoft DVD Ripper Ultimate est un logiciel excellent pour copier et convertir DVD vers presque ... Cliquez pour télécharger Xilisoft DVD Ripper Ultimate Rigs of Rods (63.3)RIGS OF RODS (63.3)c'est un jeu de multi-simulation camions,autobus voitures, avions, bateaux, hélicoptère avec défo... Cliquez pour télécharger Rigs of Rods
|