Skip to content

Instantly share code, notes, and snippets.

Avatar
🤔
Thinking

Alisson Nunes Alynva

🤔
Thinking
View GitHub Profile
@Alynva
Alynva / colors.cpp
Last active Feb 10, 2017
Changing de output color on Windows terminal
View colors.cpp
#include <iostream>
#include <windows.h>
using namespace std;
int main() {
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
// you can loop k higher to see more color choices
for(int k = 0; k <= 255; k++) {
// pick the colorattribute k you want
@Alynva
Alynva / Input.c
Created Feb 10, 2017
Exemplifies the usage of a mouse in console environment. Purely coded in C using gcc compiler (MinGW, to be more precise)
View Input.c
#include <windows.h>
#define MAXCONSOLEINPUTS 20
//This is the input module. It can handle not only Mouse but keyboard also.
HANDLE rHnd, wHnd; //Handles for reading and writing to the console.
//The Mouse Handle function. Or to be more precise, the pointer to the function
int (*handler) (int x, int y, int button,int state);
int initializecontrols();
int addmousehandler(int (*func) (int x, int y, int button,int state));
@Alynva
Alynva / converMedidas.c
Last active Feb 11, 2017
Programa em CGI para converter unidades de medida
View converMedidas.c
#include <stdio.h>
#include <stdlib.h>
int main() {
char* dados = NULL;
int input1 = 0, convert = 0, i;
double result1 = 0.0;
char erro[50] = {'\n'};
char select[7][70] = {'\n'};
View jogo-da-forca-theWord.c
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
int main() {
int i;
char *dados = NULL;
char theWord[50] = {'\n'};
@Alynva
Alynva / jogo-da-memoria.c
Created Feb 11, 2017
Jogo da Memória em CGI
View jogo-da-memoria.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define QTDNUMBERS 5
void getName(char[], char[]);
int main() {
@Alynva
Alynva / jogo-da-velha.c
Created Feb 11, 2017
Jogo da Velha em CGI
View jogo-da-velha.c
#include <stdio.h>
#include <stdlib.h>
int main() {
// 0 = não jogado
// 1 = jogado o "O"
// 2 = jogado o "X"
char* dados = NULL;
@Alynva
Alynva / jogo-de-pintar.c
Created Feb 11, 2017
Jogo de Pintar (Paint) em CGI
View jogo-de-pintar.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#define MAXPIXELSTRING 71910
#define MAXPIXEL 4794
int main() {
int i = 0;
int j, k;
@Alynva
Alynva / SDL Message Box.cpp
Created Apr 8, 2017
A little example of SDL Message Box
View SDL Message Box.cpp
#include "SDL.h"
#include <windows.h>
int main(int argc, char *argv[]) {
const SDL_MessageBoxButtonData buttons[] = {
{ /* .flags, .buttonid, .text */ 0, 0, "no" },
{ SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, "yes" },
{ SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 2, "cancel" },
};
const SDL_MessageBoxColorScheme colorScheme = {
@Alynva
Alynva / funcs.cpp
Created May 21, 2017
A function as a parameter of another function
View funcs.cpp
#include <iostream>
using namespace std;
int f1(int n) {
return n * 3;
}
int f2(int f(int), int n) {
return f(n) - 2;
@Alynva
Alynva / teste_fps.cpp
Created Jun 1, 2017
Um código simples pra testar o framerate no SDL
View teste_fps.cpp
#include "SDL2/SDL.h"
#include <stdio.h>
// How many frames time values to keep
// The higher the value the smoother the result is...
// Don't make it 0 or less :)
#define FRAME_VALUES 10
// An array to store frame times:
Uint32 frametimes[FRAME_VALUES];