tipografia

main
fanta 2 weeks ago
parent 9ff0a6e442
commit cce931853b

BIN
bocm

Binary file not shown.

@ -3,7 +3,7 @@
int main(int argc, char** argv) {
initWindow();
loadLogo();
loadFont();
windowLoop();
destroy();
}

@ -3,7 +3,8 @@
SDL_Window* window;
SDL_Renderer* renderer;
SDL_Surface* surface;
SDL_Texture* texture;
SDL_Texture* font;
const int screenWidth = 800;
const int screenHeight = 600;
@ -26,17 +27,17 @@ int initWindow(void){
return throw_sdl_err("Could not create new window and renderer: %s");
}
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
SDL_SetWindowTitle(window, "BOCM 0.1");
SDL_SetWindowTitle(window, "Fanta 0.1");
return 0;
}
int loadLogo(void){
surface = SDL_LoadBMP("imgs/bocm.bmp");
int loadFont(void){
surface = SDL_LoadBMP("imgs/font.bmp");
if (!surface) {
return throw_sdl_err("Could not load BMP image: %s");
}
texture = SDL_CreateTextureFromSurface(renderer, surface);
if (!texture) {
font = SDL_CreateTextureFromSurface(renderer, surface);
if (!font) {
return throw_sdl_err("Could not create new texture from surface: %s");
}
SDL_FreeSurface(surface);
@ -44,25 +45,174 @@ int loadLogo(void){
}
int loadBackgroundColor(void){
SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
SDL_RenderClear(renderer);
return 0;
}
void locLogo(int x, int y){
SDL_Rect srcrect = {0, 0, 100, 73};
SDL_Rect dstrect = {x, y, 100, 73};
SDL_RenderCopy(renderer, texture, &srcrect, &dstrect);
}
void putChar(int x, int y, int size, char value){
if (value=='a'){
SDL_Rect srcrect = {0, 0, 14, 14};
SDL_Rect dstrect = {x, y, size, size};
SDL_RenderCopy(renderer, font, &srcrect, &dstrect);
}
if (value=='b'){
SDL_Rect srcrect = {16, 0, 14, 14};
SDL_Rect dstrect = {x, y, size, size};
SDL_RenderCopy(renderer, font, &srcrect, &dstrect);
}
if (value=='c'){
SDL_Rect srcrect = {32, 0, 14, 14};
SDL_Rect dstrect = {x, y, size, size};
SDL_RenderCopy(renderer, font, &srcrect, &dstrect);
}
if (value=='d'){
SDL_Rect srcrect = {48, 0, 14, 14};
SDL_Rect dstrect = {x, y, size, size};
SDL_RenderCopy(renderer, font, &srcrect, &dstrect);
}
if (value=='e'){
SDL_Rect srcrect = {64, 0, 14, 14};
SDL_Rect dstrect = {x, y, size, size};
SDL_RenderCopy(renderer, font, &srcrect, &dstrect);
}
if (value=='f'){
SDL_Rect srcrect = {80, 0, 14, 14};
SDL_Rect dstrect = {x, y, size, size};
SDL_RenderCopy(renderer, font, &srcrect, &dstrect);
}
if (value=='g'){
SDL_Rect srcrect = {96, 0, 14, 14};
SDL_Rect dstrect = {x, y, size, size};
SDL_RenderCopy(renderer, font, &srcrect, &dstrect);
}
if (value=='h'){
SDL_Rect srcrect = {112, 0, 14, 14};
SDL_Rect dstrect = {x, y, size, size};
SDL_RenderCopy(renderer, font, &srcrect, &dstrect);
}
if (value=='i'){
SDL_Rect srcrect = {128, 0, 14, 14};
SDL_Rect dstrect = {x, y, size, size};
SDL_RenderCopy(renderer, font, &srcrect, &dstrect);
}
if (value=='j'){
SDL_Rect srcrect = {144, 0, 14, 14};
SDL_Rect dstrect = {x, y, size, size};
SDL_RenderCopy(renderer, font, &srcrect, &dstrect);
}
if (value=='k'){
SDL_Rect srcrect = {160, 0, 14, 14};
SDL_Rect dstrect = {x, y, size, size};
SDL_RenderCopy(renderer, font, &srcrect, &dstrect);
}
if (value=='l'){
SDL_Rect srcrect = {176, 0, 14, 14};
SDL_Rect dstrect = {x, y, size, size};
SDL_RenderCopy(renderer, font, &srcrect, &dstrect);
}
if (value=='m'){
SDL_Rect srcrect = {192, 0, 14, 14};
SDL_Rect dstrect = {x, y, size, size};
SDL_RenderCopy(renderer, font, &srcrect, &dstrect);
}
if (value=='n'){
SDL_Rect srcrect = {208, 0, 14, 14};
SDL_Rect dstrect = {x, y, size, size};
SDL_RenderCopy(renderer, font, &srcrect, &dstrect);
}
if (value=='o'){
SDL_Rect srcrect = {224, 0, 14, 14};
SDL_Rect dstrect = {x, y, size, size};
SDL_RenderCopy(renderer, font, &srcrect, &dstrect);
}
if (value=='p'){
SDL_Rect srcrect = {240, 0, 14, 14};
SDL_Rect dstrect = {x, y, size, size};
SDL_RenderCopy(renderer, font, &srcrect, &dstrect);
}
if (value=='q'){
SDL_Rect srcrect = {256, 0, 14, 14};
SDL_Rect dstrect = {x, y, size, size};
SDL_RenderCopy(renderer, font, &srcrect, &dstrect);
}
if (value=='r'){
SDL_Rect srcrect = {272, 0, 14, 14};
SDL_Rect dstrect = {x, y, size, size};
SDL_RenderCopy(renderer, font, &srcrect, &dstrect);
}
if (value=='s'){
SDL_Rect srcrect = {288, 0, 14, 14};
SDL_Rect dstrect = {x, y, size, size};
SDL_RenderCopy(renderer, font, &srcrect, &dstrect);
}
if (value=='t'){
SDL_Rect srcrect = {304, 0, 14, 14};
SDL_Rect dstrect = {x, y, size, size};
SDL_RenderCopy(renderer, font, &srcrect, &dstrect);
}
if (value=='u'){
SDL_Rect srcrect = {0, 17, 14, 14};
SDL_Rect dstrect = {x, y, size, size};
SDL_RenderCopy(renderer, font, &srcrect, &dstrect);
}
if (value=='v'){
SDL_Rect srcrect = {16, 17, 14, 14};
SDL_Rect dstrect = {x, y, size, size};
SDL_RenderCopy(renderer, font, &srcrect, &dstrect);
}
if (value=='w'){
SDL_Rect srcrect = {32, 17, 14, 14};
SDL_Rect dstrect = {x, y, size, size};
SDL_RenderCopy(renderer, font, &srcrect, &dstrect);
}
if (value=='x'){
SDL_Rect srcrect = {48, 17, 14, 14};
SDL_Rect dstrect = {x, y, size, size};
SDL_RenderCopy(renderer, font, &srcrect, &dstrect);
}
if (value=='y'){
SDL_Rect srcrect = {64, 17, 14, 14};
SDL_Rect dstrect = {x, y, size, size};
SDL_RenderCopy(renderer, font, &srcrect, &dstrect);
}
if (value=='z'){
SDL_Rect srcrect = {80, 17, 14, 14};
SDL_Rect dstrect = {x, y, size, size};
SDL_RenderCopy(renderer, font, &srcrect, &dstrect);
}
void locStars(int x, int y){
SDL_Rect srcrect = {1, 32, 22, 21};
SDL_Rect dstrect = {x, y, 22, 21};
SDL_RenderCopy(renderer, texture, &srcrect, &dstrect);
}
int destroy(void){
SDL_DestroyTexture(texture);
SDL_DestroyTexture(font);
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

@ -10,13 +10,18 @@ int windowLoop(void){
}
loadBackgroundColor();
locLogo(10,10);
locStars(135,43);
locStars(135,83);
locStars(135,123);
locStars(135,163);
locLogo(200,200);
char text[5] = "fanta"; // El texto que quiero mostrar
int x = 10; // posición x inicial
int y = 10; // posición y de todos los caracteres
int size = 40; // tamaño
int space = 45; // Espaciado entre letra y letra
for (int i = 0; i < strlen(text); i++){
putChar(x,y,size,text[i]);
x = x + space;
}
SDL_RenderPresent(renderer);
}
return 0;

Loading…
Cancel
Save