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
SESSION SILVERLIGHT 5 3D : SLIDES ET DEMOSSESSION SILVERLIGHT 5 3D : SLIDES ET DEMOS par Groc
Durant les techdays, j'ai eu le plaisir d'animer une session sur Silverlight 5 et la 3D avec Simon Ferquel. Comme promis, voici nos slides et mes démos (celles avec le viper BSG) ici et là. Pour mémoire, les démos utilisent toutes le viper BSG...
Cliquez pour lire la suite de l'article par Groc [TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES[TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES par gpommier
Suite à la session que j'ai présenté sur WebMatrix 2, vous pouvez trouver les slides ici, ainsi que les démos en packages nuget : démos1 et démos2 J'en profite pour remercier chaleureusement tous ceux qui sont venus très nombreux à cette sess...
Cliquez pour lire la suite de l'article par gpommier [SHAREPOINT] LES SESSIONS TECHDAYS 2012.[SHAREPOINT] LES SESSIONS TECHDAYS 2012. par Patrick Guimonet
Voici donc pour ceux qui n'ont pas pu venir, ou ceux qui n'ont pas pu toutes les suivre la liste des sessions SharePoint aux TechDays 2012, que je mettrais à jour dès que les liens des vidéo seront disponibles. Ou ici : http...
Cliquez pour lire la suite de l'article par Patrick Guimonet TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3 par ROMELARD Fabrice
Speaker: Bernard Ourghanlian Cette session est comme chaque jour transmise en live par BrainSonic, et j'ai donc suivi cette troisième pleinière par ce moyen sur mon iPad . Elle est dédiée comme chaque année à la mise en perspective de l'é...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE !MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE ! par Vko
Hier durant une session dédiée aux Techdays 2012, j'ai eu le plaisir d'annoncer la sortie de la Béta 2 de Mishra Reader. C'est quoi ? Pour les utilisateurs, c'est une vraie expérience de lecture de flux RSS sur Windows. Rien à voir avec les produit...
Cliquez pour lire la suite de l'article par Vko
Logiciels
Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning
|